aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Naggum1997-05-21 20:07:20 +0000
committerErik Naggum1997-05-21 20:07:20 +0000
commitfb644f48cf436270c8dc18554527bc90203bd0d7 (patch)
tree152e37aae26c5c148889b6e5512c41a8b89e0b8f
parenta1d713ef1e3ceb84375872513767ea82aafd36a5 (diff)
downloademacs-fb644f48cf436270c8dc18554527bc90203bd0d7.tar.gz
emacs-fb644f48cf436270c8dc18554527bc90203bd0d7.zip
(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.
-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."
387 :group 'change-log) 387 :group 'change-log)
388 388
389;;;###autoload 389;;;###autoload
390(defvar add-log-lisp-like-modes
391 '(emacs-lisp-mode lisp-mode scheme-mode lisp-interaction-mode)
392 "*Modes that look like Lisp to `add-log-current-defun'.")
393
394;;;###autoload
395(defvar add-log-c-like-modes
396 '(c-mode c++-mode c++-c-mode objc-mode)
397 "*Modes that look like C to `add-log-current-defun'.")
398
399;;;###autoload
400(defvar add-log-tex-like-modes
401 '(TeX-mode plain-TeX-mode LaTeX-mode plain-tex-mode latex-mode)
402 "*Modes that look like TeX to `add-log-current-defun'.")
403
404;;;###autoload
390(defun add-log-current-defun () 405(defun add-log-current-defun ()
391 "Return name of function definition point is in, or nil. 406 "Return name of function definition point is in, or nil.
392 407
@@ -402,8 +417,7 @@ Has a preference of looking backwards."
402 (condition-case nil 417 (condition-case nil
403 (save-excursion 418 (save-excursion
404 (let ((location (point))) 419 (let ((location (point)))
405 (cond ((memq major-mode '(emacs-lisp-mode lisp-mode scheme-mode 420 (cond ((memq major-mode add-log-lisp-like-modes)
406 lisp-interaction-mode))
407 ;; If we are now precisely at the beginning of a defun, 421 ;; If we are now precisely at the beginning of a defun,
408 ;; make sure beginning-of-defun finds that one 422 ;; make sure beginning-of-defun finds that one
409 ;; rather than the previous one. 423 ;; rather than the previous one.
@@ -422,14 +436,15 @@ Has a preference of looking backwards."
422 (skip-chars-forward " '") 436 (skip-chars-forward " '")
423 (buffer-substring (point) 437 (buffer-substring (point)
424 (progn (forward-sexp 1) (point)))))) 438 (progn (forward-sexp 1) (point))))))
425 ((and (memq major-mode '(c-mode c++-mode c++-c-mode objc-mode)) 439 ((and (memq major-mode add-log-c-like-modes)
426 (save-excursion (beginning-of-line) 440 (save-excursion
427 ;; Use eq instead of = here to avoid 441 (beginning-of-line)
428 ;; error when at bob and char-after 442 ;; Use eq instead of = here to avoid
429 ;; returns nil. 443 ;; error when at bob and char-after
430 (while (eq (char-after (- (point) 2)) ?\\) 444 ;; returns nil.
431 (forward-line -1)) 445 (while (eq (char-after (- (point) 2)) ?\\)
432 (looking-at "[ \t]*#[ \t]*define[ \t]"))) 446 (forward-line -1))
447 (looking-at "[ \t]*#[ \t]*define[ \t]")))
433 ;; Handle a C macro definition. 448 ;; Handle a C macro definition.
434 (beginning-of-line) 449 (beginning-of-line)
435 (while (eq (char-after (- (point) 2)) ?\\) ;not =; note above 450 (while (eq (char-after (- (point) 2)) ?\\) ;not =; note above
@@ -438,7 +453,7 @@ Has a preference of looking backwards."
438 (skip-chars-forward " \t") 453 (skip-chars-forward " \t")
439 (buffer-substring (point) 454 (buffer-substring (point)
440 (progn (forward-sexp 1) (point)))) 455 (progn (forward-sexp 1) (point))))
441 ((memq major-mode '(c-mode c++-mode c++-c-mode objc-mode)) 456 ((memq major-mode add-log-c-like-modes)
442 (beginning-of-line) 457 (beginning-of-line)
443 ;; See if we are in the beginning part of a function, 458 ;; See if we are in the beginning part of a function,
444 ;; before the open brace. If so, advance forward. 459 ;; before the open brace. If so, advance forward.
@@ -533,10 +548,7 @@ Has a preference of looking backwards."
533 (looking-at "struct \\|union \\|class ") 548 (looking-at "struct \\|union \\|class ")
534 (setq middle (point))) 549 (setq middle (point)))
535 (buffer-substring middle end))))))))) 550 (buffer-substring middle end)))))))))
536 ((memq major-mode 551 ((memq major-mode add-log-tex-like-modes)
537 '(TeX-mode plain-TeX-mode LaTeX-mode;; tex-mode.el
538 plain-tex-mode latex-mode;; cmutex.el
539 ))
540 (if (re-search-backward 552 (if (re-search-backward
541 "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t) 553 "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t)
542 (progn 554 (progn