emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master e6380c4: * lisp/progmodes/ada-mode.el (comment-regi


From: Stefan Monnier
Subject: [Emacs-diffs] master e6380c4: * lisp/progmodes/ada-mode.el (comment-region): Avoid defadvice
Date: Fri, 14 Sep 2018 11:25:19 -0400 (EDT)

branch: master
commit e6380c43338fe4f8ca2df78eb549f96b14275ffc
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp/progmodes/ada-mode.el (comment-region): Avoid defadvice
    
    Don't load 'advice' if it won't be used!
---
 lisp/progmodes/ada-mode.el | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el
index 76c9be9..fd6a2b0 100644
--- a/lisp/progmodes/ada-mode.el
+++ b/lisp/progmodes/ada-mode.el
@@ -4519,6 +4519,7 @@ Moves to `begin' if in a declarative part."
   (define-key ada-mode-map "\C-c\C-n" 'ada-make-subprogram-body)
 
   ;; Use predefined function of Emacs19 for comments (RE)
+  ;; FIXME: Made redundant with Emacs-21's standard comment-dwim binding on M-;
   (define-key ada-mode-map "\C-c;"    'comment-region)
   (define-key ada-mode-map "\C-c:"    'ada-uncomment-region)
 
@@ -4756,16 +4757,17 @@ Moves to `begin' if in a declarative part."
 ;;  function for justifying the comments.
 ;; -------------------------------------------------------
 
-(defadvice comment-region (before ada-uncomment-anywhere disable)
-  (if (and (consp arg)  ;;  a prefix with \C-u is of the form '(4), whereas
-                      ;;  \C-u 2  sets arg to '2'  (fixed by S.Leake)
-          (derived-mode-p 'ada-mode))
-      (save-excursion
-       (let ((cs (concat "^[ \t]*" (regexp-quote comment-start))))
-         (goto-char beg)
-         (while (re-search-forward cs end t)
-           (replace-match comment-start))
-         ))))
+(when (or (<= emacs-major-version 20) (featurep 'xemacs))
+  (defadvice comment-region (before ada-uncomment-anywhere disable)
+    (if (and (consp arg) ;;  a prefix with \C-u is of the form '(4), whereas
+            ;;  \C-u 2  sets arg to '2'  (fixed by S.Leake)
+            (derived-mode-p 'ada-mode))
+        (save-excursion
+         (let ((cs (concat "^[ \t]*" (regexp-quote comment-start))))
+           (goto-char beg)
+           (while (re-search-forward cs end t)
+             (replace-match comment-start))
+           )))))
 
 (defun ada-uncomment-region (beg end &optional arg)
   "Uncomment region BEG .. END.



reply via email to

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