summaryrefslogtreecommitdiff
path: root/lisp/add-log.el
diff options
context:
space:
mode:
authorErik Naggum <erik@naggum.no>1997-05-21 20:07:20 +0000
committerErik Naggum <erik@naggum.no>1997-05-21 20:07:20 +0000
commitfb644f48cf436270c8dc18554527bc90203bd0d7 (patch)
tree152e37aae26c5c148889b6e5512c41a8b89e0b8f /lisp/add-log.el
parenta1d713ef1e3ceb84375872513767ea82aafd36a5 (diff)
downloademacs-fb644f48cf436270c8dc18554527bc90203bd0d7.tar.gz
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
New variables. (add-log-current-defun): Use them instead of constant lists.
Diffstat (limited to 'lisp/add-log.el')
-rw-r--r--lisp/add-log.el42
1 files changed, 27 insertions, 15 deletions
diff --git a/lisp/add-log.el b/lisp/add-log.el
index 4dbea700940..27ace80f219 100644
--- a/lisp/add-log.el
+++ b/lisp/add-log.el
@@ -387,6 +387,21 @@ Prefix arg means justify as well."
:group 'change-log)
;;;###autoload
+(defvar add-log-lisp-like-modes
+ '(emacs-lisp-mode lisp-mode scheme-mode lisp-interaction-mode)
+ "*Modes that look like Lisp to `add-log-current-defun'.")
+
+;;;###autoload
+(defvar add-log-c-like-modes
+ '(c-mode c++-mode c++-c-mode objc-mode)
+ "*Modes that look like C to `add-log-current-defun'.")
+
+;;;###autoload
+(defvar add-log-tex-like-modes
+ '(TeX-mode plain-TeX-mode LaTeX-mode plain-tex-mode latex-mode)
+ "*Modes that look like TeX to `add-log-current-defun'.")
+
+;;;###autoload
(defun add-log-current-defun ()
"Return name of function definition point is in, or nil.
@@ -402,8 +417,7 @@ Has a preference of looking backwards."
(condition-case nil
(save-excursion
(let ((location (point)))
- (cond ((memq major-mode '(emacs-lisp-mode lisp-mode scheme-mode
- lisp-interaction-mode))
+ (cond ((memq major-mode add-log-lisp-like-modes)
;; If we are now precisely at the beginning of a defun,
;; make sure beginning-of-defun finds that one
;; rather than the previous one.
@@ -422,14 +436,15 @@ Has a preference of looking backwards."
(skip-chars-forward " '")
(buffer-substring (point)
(progn (forward-sexp 1) (point))))))
- ((and (memq major-mode '(c-mode c++-mode c++-c-mode objc-mode))
- (save-excursion (beginning-of-line)
- ;; Use eq instead of = here to avoid
- ;; error when at bob and char-after
- ;; returns nil.
- (while (eq (char-after (- (point) 2)) ?\\)
- (forward-line -1))
- (looking-at "[ \t]*#[ \t]*define[ \t]")))
+ ((and (memq major-mode add-log-c-like-modes)
+ (save-excursion
+ (beginning-of-line)
+ ;; Use eq instead of = here to avoid
+ ;; error when at bob and char-after
+ ;; returns nil.
+ (while (eq (char-after (- (point) 2)) ?\\)
+ (forward-line -1))
+ (looking-at "[ \t]*#[ \t]*define[ \t]")))
;; Handle a C macro definition.
(beginning-of-line)
(while (eq (char-after (- (point) 2)) ?\\) ;not =; note above
@@ -438,7 +453,7 @@ Has a preference of looking backwards."
(skip-chars-forward " \t")
(buffer-substring (point)
(progn (forward-sexp 1) (point))))
- ((memq major-mode '(c-mode c++-mode c++-c-mode objc-mode))
+ ((memq major-mode add-log-c-like-modes)
(beginning-of-line)
;; See if we are in the beginning part of a function,
;; before the open brace. If so, advance forward.
@@ -533,10 +548,7 @@ Has a preference of looking backwards."
(looking-at "struct \\|union \\|class ")
(setq middle (point)))
(buffer-substring middle end)))))))))
- ((memq major-mode
- '(TeX-mode plain-TeX-mode LaTeX-mode;; tex-mode.el
- plain-tex-mode latex-mode;; cmutex.el
- ))
+ ((memq major-mode add-log-tex-like-modes)
(if (re-search-backward
"\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t)
(progn