From 0ada66e5c5b62af4f25b97b21e69bfe587912a81 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 25 Oct 2008 20:12:14 +0000 Subject: Update the compatibility and compiler warning suppression hacks for Emacs 22. The byte-code compiler of GNU Emacs 22 is now clever enough to detect and flag (funcall 'an-undefined-function ...), so use `autoload' for the newcomment.el routines instead. There may be other functions that should be autoloaded, such as `comment-kill' and `comment-indent'. Currently GNU Emacs 22 signals no warnings about these, however. I don't know whether these changes works in GNU Emacs 21 or XEmacs, but they probably do. darcs-hash:20081025201214-00fcc-350188c1285ba0519aa7bf20fbab0209c1ee21df --- paredit.el | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'paredit.el') diff --git a/paredit.el b/paredit.el index 28c6b7b..6c705a0 100644 --- a/paredit.el +++ b/paredit.el @@ -988,6 +988,29 @@ If the point is in a string or a comment, fill the paragraph instead, ;;;; Comment Insertion +;;; This is all a horrible, horrible hack, primarily for GNU Emacs 21, +;;; in which there is no `comment-or-uncomment-region'. + +(autoload 'comment-forward "newcomment") +(autoload 'comment-normalize-vars "newcomment") +(autoload 'comment-region "newcomment") +(autoload 'comment-search-forward "newcomment") +(autoload 'uncomment-region "newcomment") + +(defun paredit-initialize-comment-dwim () + (require 'newcomment) + (if (not (fboundp 'comment-or-uncomment-region)) + (defalias 'comment-or-uncomment-region + (lambda (beginning end &optional argument) + (interactive "*r\nP") + (if (save-excursion (goto-char beginning) + (comment-forward (point-max)) + (<= end (point))) + (uncomment-region beginning end argument) + (comment-region beginning end argument))))) + (defalias 'paredit-initialize-comment-dwim 'comment-normalize-vars) + (comment-normalize-vars)) + (defun paredit-comment-dwim (&optional argument) "Call the Lisp comment command you want (Do What I Mean). This is like `comment-dwim', but it is specialized for Lisp editing. @@ -1016,27 +1039,6 @@ At the top level, where indentation is calculated to be at column 0, (comment-kill (if (integerp argument) argument nil)) (comment-indent))) (t (paredit-insert-comment)))) - -;;; This is all a horrible, horrible hack, primarily for GNU Emacs 21, -;;; in which there is no `comment-or-uncomment-region'. - -(defun paredit-initialize-comment-dwim () - (require 'newcomment) - (if (not (fboundp 'comment-or-uncomment-region)) - (defalias 'comment-or-uncomment-region - (lambda (beginning end &optional argument) - (interactive "*r\nP") - (funcall (if (save-excursion (goto-char beginning) - ;; This is undefined until `newcomment' - ;; is loaded. Using `funcall' with a - ;; symbol shuts up the compiler. - (funcall 'comment-forward (point-max)) - (<= end (point))) - 'uncomment-region - 'comment-region) - beginning end argument)))) - (defalias 'paredit-initialize-comment-dwim 'comment-normalize-vars) - (comment-normalize-vars)) (defun paredit-comment-on-line-p () "True if there is a comment on the line following point. @@ -1049,7 +1051,7 @@ This is expected to be called only in `paredit-comment-dwim'; do not ;; COMMENT-P to true; if not, it will be nil. (while (progn (setq comment-p ;t -> no error - (funcall 'comment-search-forward (point-at-eol) t)) + (comment-search-forward (point-at-eol) t)) (and comment-p (or (paredit-in-string-p) (paredit-in-char-p (1- (point)))))) -- cgit v1.2.1