emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r116650: * lisp/electric.el (electric-indent-mode-ha


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r116650: * lisp/electric.el (electric-indent-mode-has-been-called): Remove.
Date: Tue, 04 Mar 2014 04:03:41 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116650
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2014-03-03 23:03:34 -0500
message:
  * 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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/electric.el               electric.el-20091113204419-o5vbwnq5f7feedwu-47
  lisp/progmodes/cc-mode.el      ccmode.el-20091113204419-o5vbwnq5f7feedwu-1230
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-03-04 03:26:17 +0000
+++ b/lisp/ChangeLog    2014-03-04 04:03:34 +0000
@@ -1,5 +1,17 @@
 2014-03-04  Stefan Monnier  <address@hidden>
 
+       * 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.
+
+       * electric.el (electric-indent-mode-has-been-called): Remove.
+       (electric-indent-mode): Fix accordingly.
+
        * files.el (hack-local-variables): Mention file name in warning.
 
        * htmlfontify.el (hfy-fontify-buffer): Drop `invis-range' message.

=== modified file 'lisp/electric.el'
--- a/lisp/electric.el  2014-02-21 14:29:28 +0000
+++ b/lisp/electric.el  2014-03-04 04:03:34 +0000
@@ -286,9 +286,7 @@
   (let ((electric-indent-mode nil))
     (newline arg 'interactive)))
 
-(defvar electric-indent-mode-has-been-called 0
-  "How many times has `electric-indent-mode' been called?
-It's > 1 if it's been called at least once by the user.")
+
 ;;;###autoload
 (define-minor-mode electric-indent-mode
   "Toggle on-the-fly reindentation (Electric Indent mode).
@@ -302,8 +300,6 @@
   :global t :group 'electricity
   :initialize 'custom-initialize-delay
   :init-value t
-  (setq electric-indent-mode-has-been-called
-       (1+ electric-indent-mode-has-been-called))
   (if (not electric-indent-mode)
       (progn
         (when (eq (lookup-key global-map [?\C-j])

=== modified file 'lisp/progmodes/cc-mode.el'
--- a/lisp/progmodes/cc-mode.el 2014-02-17 18:16:32 +0000
+++ b/lisp/progmodes/cc-mode.el 2014-03-04 04:03:34 +0000
@@ -75,7 +75,7 @@
 
 ;; For Emacs < 22.2.
 (eval-and-compile
-  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest _r))))
 
 (eval-when-compile
   (let ((load-path
@@ -190,11 +190,10 @@
            (add-hook 'change-major-mode-hook 'c-leave-cc-mode-mode)
            (setq c-initialization-ok t)
            ;; Connect up with Emacs's electric-indent-mode, for >= Emacs 24.4
-           (when (fboundp 'electric-indent-mode)
+            (when (fboundp 'electric-indent-local-mode)
              (add-hook 'electric-indent-mode-hook 'c-electric-indent-mode-hook)
-             (when (fboundp 'electric-indent-local-mode)
-               (add-hook 'electric-indent-local-mode-hook
-                           'c-electric-indent-local-mode-hook))))
+              (add-hook 'electric-indent-local-mode-hook
+                        'c-electric-indent-local-mode-hook)))
        ;; Will try initialization hooks again if they failed.
        (put 'c-initialize-cc-mode initprop c-initialization-ok))))
 
@@ -588,8 +587,9 @@
   ;; messing up CC Mode's, and set `c-electric-flag' if `electric-indent-mode'
   ;; has been called by the user.
   (when (boundp 'electric-indent-inhibit) (setq electric-indent-inhibit t))
-  (when (and (boundp 'electric-indent-mode-has-been-called)
-            (> electric-indent-mode-has-been-called 1))
+  ;; CC-mode should obey Emacs's generic preferences, tho only do it if
+  ;; Emacs's generic preferences can be set per-buffer (Emacs>=24.4).
+  (when (fboundp 'electric-indent-local-mode)
     (setq c-electric-flag electric-indent-mode))
 
 ;;   ;; Put submode indicators onto minor-mode-alist, but only once.
@@ -1165,7 +1165,7 @@
       (backward-char))
     new-pos))                          ; back over (, [, <.
 
-(defun c-change-set-fl-decl-start (beg end old-len)
+(defun c-change-set-fl-decl-start (_beg _end _old-len)
   ;; Set c-new-BEG to the beginning of a "local" declaration if it('s BOL) is
   ;; inside one.  This is called from an after-change-function, but the
   ;; parameters BEG END and OLD-LEN are ignored.  See `c-set-fl-decl-start'
@@ -1239,7 +1239,7 @@
       (make-local-hook 'font-lock-mode-hook))
   (add-hook 'font-lock-mode-hook 'c-after-font-lock-init nil t))
 
-(defun c-extend-after-change-region (beg end old-len)
+(defun c-extend-after-change-region (_beg _end _old-len)
   "Extend the region to be fontified, if necessary."
   ;; Note: the parameters are ignored here.  This somewhat indirect
   ;; implementation exists because it is minimally different from the
@@ -1256,15 +1256,13 @@
 (defun c-electric-indent-mode-hook ()
   ;; Emacs has en/disabled `electric-indent-mode'.  Propagate this through to
   ;; each CC Mode buffer.
-  (when (and (boundp 'electric-indent-mode-has-been-called)
-            (> electric-indent-mode-has-been-called 1))
-    (mapc (lambda (buf)
-           (with-current-buffer buf
-             (when c-buffer-is-cc-mode
-               ;; Don't use `c-toggle-electric-state' here due to recursion.
-               (setq c-electric-flag electric-indent-mode)
-               (c-update-modeline))))
-         (buffer-list))))
+  (mapc (lambda (buf)
+          (with-current-buffer buf
+            (when c-buffer-is-cc-mode
+              ;; Don't use `c-toggle-electric-state' here due to recursion.
+              (setq c-electric-flag electric-indent-mode)
+              (c-update-modeline))))
+        (buffer-list)))
 
 (defun c-electric-indent-local-mode-hook ()
   ;; Emacs has en/disabled `electric-indent-local-mode' for this buffer.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]