diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/electric.el | 6 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 34 |
3 files changed, 29 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2585d41bbb4..e75f2cc3190 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,17 @@ | |||
| 1 | 2014-03-04 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2014-03-04 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * progmodes/cc-mode.el (c-initialize-cc-mode): Only hook into | ||
| 4 | electric-indent-mode-hook if we obey electric-indent-mode. | ||
| 5 | (c-basic-common-init): Use (fboundp 'electric-indent-local-mode) to | ||
| 6 | decide whether we obey electric-indent-mode. | ||
| 7 | (c-change-set-fl-decl-start, c-extend-after-change-region): | ||
| 8 | Silence warnings. | ||
| 9 | (c-electric-indent-mode-hook): Assume we do want to obey | ||
| 10 | electric-indent-mode. | ||
| 11 | |||
| 12 | * electric.el (electric-indent-mode-has-been-called): Remove. | ||
| 13 | (electric-indent-mode): Fix accordingly. | ||
| 14 | |||
| 3 | * files.el (hack-local-variables): Mention file name in warning. | 15 | * files.el (hack-local-variables): Mention file name in warning. |
| 4 | 16 | ||
| 5 | * htmlfontify.el (hfy-fontify-buffer): Drop `invis-range' message. | 17 | * htmlfontify.el (hfy-fontify-buffer): Drop `invis-range' message. |
diff --git a/lisp/electric.el b/lisp/electric.el index 992553685e2..3e19d9b23b1 100644 --- a/lisp/electric.el +++ b/lisp/electric.el | |||
| @@ -286,9 +286,7 @@ mode set `electric-indent-inhibit', but this can be used as a workaround.") | |||
| 286 | (let ((electric-indent-mode nil)) | 286 | (let ((electric-indent-mode nil)) |
| 287 | (newline arg 'interactive))) | 287 | (newline arg 'interactive))) |
| 288 | 288 | ||
| 289 | (defvar electric-indent-mode-has-been-called 0 | 289 | |
| 290 | "How many times has `electric-indent-mode' been called? | ||
| 291 | It's > 1 if it's been called at least once by the user.") | ||
| 292 | ;;;###autoload | 290 | ;;;###autoload |
| 293 | (define-minor-mode electric-indent-mode | 291 | (define-minor-mode electric-indent-mode |
| 294 | "Toggle on-the-fly reindentation (Electric Indent mode). | 292 | "Toggle on-the-fly reindentation (Electric Indent mode). |
| @@ -302,8 +300,6 @@ insert a character from `electric-indent-chars'." | |||
| 302 | :global t :group 'electricity | 300 | :global t :group 'electricity |
| 303 | :initialize 'custom-initialize-delay | 301 | :initialize 'custom-initialize-delay |
| 304 | :init-value t | 302 | :init-value t |
| 305 | (setq electric-indent-mode-has-been-called | ||
| 306 | (1+ electric-indent-mode-has-been-called)) | ||
| 307 | (if (not electric-indent-mode) | 303 | (if (not electric-indent-mode) |
| 308 | (progn | 304 | (progn |
| 309 | (when (eq (lookup-key global-map [?\C-j]) | 305 | (when (eq (lookup-key global-map [?\C-j]) |
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 9b18bbf82a9..1ce076734ff 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -75,7 +75,7 @@ | |||
| 75 | 75 | ||
| 76 | ;; For Emacs < 22.2. | 76 | ;; For Emacs < 22.2. |
| 77 | (eval-and-compile | 77 | (eval-and-compile |
| 78 | (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) | 78 | (unless (fboundp 'declare-function) (defmacro declare-function (&rest _r)))) |
| 79 | 79 | ||
| 80 | (eval-when-compile | 80 | (eval-when-compile |
| 81 | (let ((load-path | 81 | (let ((load-path |
| @@ -190,11 +190,10 @@ control). See \"cc-mode.el\" for more info." | |||
| 190 | (add-hook 'change-major-mode-hook 'c-leave-cc-mode-mode) | 190 | (add-hook 'change-major-mode-hook 'c-leave-cc-mode-mode) |
| 191 | (setq c-initialization-ok t) | 191 | (setq c-initialization-ok t) |
| 192 | ;; Connect up with Emacs's electric-indent-mode, for >= Emacs 24.4 | 192 | ;; Connect up with Emacs's electric-indent-mode, for >= Emacs 24.4 |
| 193 | (when (fboundp 'electric-indent-mode) | 193 | (when (fboundp 'electric-indent-local-mode) |
| 194 | (add-hook 'electric-indent-mode-hook 'c-electric-indent-mode-hook) | 194 | (add-hook 'electric-indent-mode-hook 'c-electric-indent-mode-hook) |
| 195 | (when (fboundp 'electric-indent-local-mode) | 195 | (add-hook 'electric-indent-local-mode-hook |
| 196 | (add-hook 'electric-indent-local-mode-hook | 196 | 'c-electric-indent-local-mode-hook))) |
| 197 | 'c-electric-indent-local-mode-hook)))) | ||
| 198 | ;; Will try initialization hooks again if they failed. | 197 | ;; Will try initialization hooks again if they failed. |
| 199 | (put 'c-initialize-cc-mode initprop c-initialization-ok)))) | 198 | (put 'c-initialize-cc-mode initprop c-initialization-ok)))) |
| 200 | 199 | ||
| @@ -588,8 +587,9 @@ that requires a literal mode spec at compile time." | |||
| 588 | ;; messing up CC Mode's, and set `c-electric-flag' if `electric-indent-mode' | 587 | ;; messing up CC Mode's, and set `c-electric-flag' if `electric-indent-mode' |
| 589 | ;; has been called by the user. | 588 | ;; has been called by the user. |
| 590 | (when (boundp 'electric-indent-inhibit) (setq electric-indent-inhibit t)) | 589 | (when (boundp 'electric-indent-inhibit) (setq electric-indent-inhibit t)) |
| 591 | (when (and (boundp 'electric-indent-mode-has-been-called) | 590 | ;; CC-mode should obey Emacs's generic preferences, tho only do it if |
| 592 | (> electric-indent-mode-has-been-called 1)) | 591 | ;; Emacs's generic preferences can be set per-buffer (Emacs>=24.4). |
| 592 | (when (fboundp 'electric-indent-local-mode) | ||
| 593 | (setq c-electric-flag electric-indent-mode)) | 593 | (setq c-electric-flag electric-indent-mode)) |
| 594 | 594 | ||
| 595 | ;; ;; Put submode indicators onto minor-mode-alist, but only once. | 595 | ;; ;; Put submode indicators onto minor-mode-alist, but only once. |
| @@ -1165,7 +1165,7 @@ Note that the style variables are always made local to the buffer." | |||
| 1165 | (backward-char)) | 1165 | (backward-char)) |
| 1166 | new-pos)) ; back over (, [, <. | 1166 | new-pos)) ; back over (, [, <. |
| 1167 | 1167 | ||
| 1168 | (defun c-change-set-fl-decl-start (beg end old-len) | 1168 | (defun c-change-set-fl-decl-start (_beg _end _old-len) |
| 1169 | ;; Set c-new-BEG to the beginning of a "local" declaration if it('s BOL) is | 1169 | ;; Set c-new-BEG to the beginning of a "local" declaration if it('s BOL) is |
| 1170 | ;; inside one. This is called from an after-change-function, but the | 1170 | ;; inside one. This is called from an after-change-function, but the |
| 1171 | ;; parameters BEG END and OLD-LEN are ignored. See `c-set-fl-decl-start' | 1171 | ;; parameters BEG END and OLD-LEN are ignored. See `c-set-fl-decl-start' |
| @@ -1239,7 +1239,7 @@ This function is called from `c-common-init', once per mode initialization." | |||
| 1239 | (make-local-hook 'font-lock-mode-hook)) | 1239 | (make-local-hook 'font-lock-mode-hook)) |
| 1240 | (add-hook 'font-lock-mode-hook 'c-after-font-lock-init nil t)) | 1240 | (add-hook 'font-lock-mode-hook 'c-after-font-lock-init nil t)) |
| 1241 | 1241 | ||
| 1242 | (defun c-extend-after-change-region (beg end old-len) | 1242 | (defun c-extend-after-change-region (_beg _end _old-len) |
| 1243 | "Extend the region to be fontified, if necessary." | 1243 | "Extend the region to be fontified, if necessary." |
| 1244 | ;; Note: the parameters are ignored here. This somewhat indirect | 1244 | ;; Note: the parameters are ignored here. This somewhat indirect |
| 1245 | ;; implementation exists because it is minimally different from the | 1245 | ;; implementation exists because it is minimally different from the |
| @@ -1256,15 +1256,13 @@ This function is called from `c-common-init', once per mode initialization." | |||
| 1256 | (defun c-electric-indent-mode-hook () | 1256 | (defun c-electric-indent-mode-hook () |
| 1257 | ;; Emacs has en/disabled `electric-indent-mode'. Propagate this through to | 1257 | ;; Emacs has en/disabled `electric-indent-mode'. Propagate this through to |
| 1258 | ;; each CC Mode buffer. | 1258 | ;; each CC Mode buffer. |
| 1259 | (when (and (boundp 'electric-indent-mode-has-been-called) | 1259 | (mapc (lambda (buf) |
| 1260 | (> electric-indent-mode-has-been-called 1)) | 1260 | (with-current-buffer buf |
| 1261 | (mapc (lambda (buf) | 1261 | (when c-buffer-is-cc-mode |
| 1262 | (with-current-buffer buf | 1262 | ;; Don't use `c-toggle-electric-state' here due to recursion. |
| 1263 | (when c-buffer-is-cc-mode | 1263 | (setq c-electric-flag electric-indent-mode) |
| 1264 | ;; Don't use `c-toggle-electric-state' here due to recursion. | 1264 | (c-update-modeline)))) |
| 1265 | (setq c-electric-flag electric-indent-mode) | 1265 | (buffer-list))) |
| 1266 | (c-update-modeline)))) | ||
| 1267 | (buffer-list)))) | ||
| 1268 | 1266 | ||
| 1269 | (defun c-electric-indent-local-mode-hook () | 1267 | (defun c-electric-indent-local-mode-hook () |
| 1270 | ;; Emacs has en/disabled `electric-indent-local-mode' for this buffer. | 1268 | ;; Emacs has en/disabled `electric-indent-local-mode' for this buffer. |