From: Stefan Monnier Date: Fri, 14 Sep 2018 15:25:16 +0000 (-0400) Subject: * lisp/progmodes/ada-mode.el (comment-region): Avoid defadvice X-Git-Tag: emacs-27.0.90~4416 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e6380c43338fe4f8ca2df78eb549f96b14275ffc;p=emacs.git * lisp/progmodes/ada-mode.el (comment-region): Avoid defadvice Don't load 'advice' if it won't be used! --- diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el index 76c9be93d03..fd6a2b0b2da 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.