diff options
| author | Stefan Monnier | 2014-03-03 23:03:34 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2014-03-03 23:03:34 -0500 |
| commit | 8d4901dc71b59fce4fd2d1591da120270a6bbabb (patch) | |
| tree | f96b4a92497b06de842e2edab72f77ce7381b4a7 /lisp/progmodes | |
| parent | 092c12b25324229235b5fdb6ceaac08b4114603c (diff) | |
| download | emacs-8d4901dc71b59fce4fd2d1591da120270a6bbabb.tar.gz emacs-8d4901dc71b59fce4fd2d1591da120270a6bbabb.zip | |
* lisp/electric.el (electric-indent-mode-has-been-called): Remove.
(electric-indent-mode): Fix accordingly.
* lisp/progmodes/cc-mode.el (c-initialize-cc-mode): Only hook into
electric-indent-mode-hook if we obey electric-indent-mode.
(c-basic-common-init): Use (fboundp 'electric-indent-local-mode) to
decide whether we obey electric-indent-mode.
(c-change-set-fl-decl-start, c-extend-after-change-region):
Silence warnings.
(c-electric-indent-mode-hook): Assume we do want to obey
electric-indent-mode.
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 34 |
1 files changed, 16 insertions, 18 deletions
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. |