diff options
| author | Chong Yidong | 2012-12-01 12:57:07 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-12-01 12:57:07 +0800 |
| commit | ba03d0d932888f687ae9c9fb12e20908c6b0620f (patch) | |
| tree | 7acf98ce6c8fa50bbe21266b29ace526e19f13b2 /lisp/textmodes | |
| parent | 92eadba57fe86a49d67a7e3d797e3180ca0f6ae7 (diff) | |
| download | emacs-ba03d0d932888f687ae9c9fb12e20908c6b0620f.tar.gz emacs-ba03d0d932888f687ae9c9fb12e20908c6b0620f.zip | |
Modularize add-log-current-defun.
Suggested by Jari Aalto.
* lisp/emacs-lisp/lisp-mode.el (lisp-current-defun-name): New.
(lisp-mode-variables): Use it.
* lisp/progmodes/cc-mode.el (c-common-init):
* lisp/progmodes/cperl-mode.el (cperl-mode): Set a value for
add-log-current-defun-function.
* lisp/progmodes/m4-mode.el (m4-current-defun-name): New function.
(m4-mode): Use it.
* lisp/progmodes/perl-mode.el (perl-current-defun-name): New.
(perl-mode): Use it.
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode): Use
lisp-current-defun-name.
* lisp/textmodes/tex-mode.el (tex-current-defun-name): New.
(tex-common-initialization): Use it.
* lisp/textmodes/texinfo.el (texinfo-current-defun-name): New.
(texinfo-mode): Use it.
* lisp/vc/add-log.el (add-log-current-defun-function): Doc fix.
(add-log-current-defun): Move mode-specific code to other files.
(add-log-lisp-like-modes, add-log-c-like-modes)
(add-log-tex-like-modes): Variables deleted.
Fixes: debbugs:2224
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/tex-mode.el | 11 | ||||
| -rw-r--r-- | lisp/textmodes/texinfo.el | 12 |
2 files changed, 21 insertions, 2 deletions
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index c4fe0d629b4..966fa60e6de 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el | |||
| @@ -421,6 +421,16 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 421 | (if (looking-at latex-outline-regexp) | 421 | (if (looking-at latex-outline-regexp) |
| 422 | (1+ (or (cdr (assoc (match-string 1) latex-section-alist)) -1)) | 422 | (1+ (or (cdr (assoc (match-string 1) latex-section-alist)) -1)) |
| 423 | 1000)) | 423 | 1000)) |
| 424 | |||
| 425 | (defun tex-current-defun-name () | ||
| 426 | "Return the name of the TeX section/paragraph/chapter at point, or nil." | ||
| 427 | (when (re-search-backward | ||
| 428 | "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" | ||
| 429 | nil t) | ||
| 430 | (goto-char (match-beginning 0)) | ||
| 431 | (buffer-substring-no-properties | ||
| 432 | (1+ (point)) ; without initial backslash | ||
| 433 | (line-end-position)))) | ||
| 424 | 434 | ||
| 425 | ;;;; | 435 | ;;;; |
| 426 | ;;;; Font-Lock support | 436 | ;;;; Font-Lock support |
| @@ -1202,6 +1212,7 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook | |||
| 1202 | ;; A line starting with $$ starts a paragraph, | 1212 | ;; A line starting with $$ starts a paragraph, |
| 1203 | ;; but does not separate paragraphs if it has more stuff on it. | 1213 | ;; but does not separate paragraphs if it has more stuff on it. |
| 1204 | (setq-local paragraph-separate "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$[ \t]*$") | 1214 | (setq-local paragraph-separate "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$[ \t]*$") |
| 1215 | (setq-local add-log-current-defun-function #'tex-current-defun-name) | ||
| 1205 | (setq-local comment-start "%") | 1216 | (setq-local comment-start "%") |
| 1206 | (setq-local comment-add 1) | 1217 | (setq-local comment-add 1) |
| 1207 | (setq-local comment-start-skip | 1218 | (setq-local comment-start-skip |
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index 91405ba0744..0e45b603c1a 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el | |||
| @@ -511,6 +511,11 @@ Subexpression 1 is what goes into the corresponding `@end' statement.") | |||
| 511 | (regexp-opt (texinfo-filter 2 texinfo-section-list)) | 511 | (regexp-opt (texinfo-filter 2 texinfo-section-list)) |
| 512 | "Regular expression matching just the Texinfo chapter level headings.") | 512 | "Regular expression matching just the Texinfo chapter level headings.") |
| 513 | 513 | ||
| 514 | (defun texinfo-current-defun-name () | ||
| 515 | "Return the name of the Texinfo node at point, or nil." | ||
| 516 | (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t) | ||
| 517 | (match-string-no-properties 1))) | ||
| 518 | |||
| 514 | ;;; Texinfo mode | 519 | ;;; Texinfo mode |
| 515 | 520 | ||
| 516 | ;;;###autoload | 521 | ;;;###autoload |
| @@ -587,8 +592,10 @@ value of `texinfo-mode-hook'." | |||
| 587 | (setq-local require-final-newline mode-require-final-newline) | 592 | (setq-local require-final-newline mode-require-final-newline) |
| 588 | (setq-local indent-tabs-mode nil) | 593 | (setq-local indent-tabs-mode nil) |
| 589 | (setq-local paragraph-separate | 594 | (setq-local paragraph-separate |
| 590 | (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-separate)) | 595 | (concat "\b\\|@[a-zA-Z]*[ \n]\\|" |
| 591 | (setq-local paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-start)) | 596 | paragraph-separate)) |
| 597 | (setq-local paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" | ||
| 598 | paragraph-start)) | ||
| 592 | (setq-local sentence-end-base "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*") | 599 | (setq-local sentence-end-base "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*") |
| 593 | (setq-local fill-column 70) | 600 | (setq-local fill-column 70) |
| 594 | (setq-local comment-start "@c ") | 601 | (setq-local comment-start "@c ") |
| @@ -600,6 +607,7 @@ value of `texinfo-mode-hook'." | |||
| 600 | '(texinfo-font-lock-keywords nil nil nil backward-paragraph)) | 607 | '(texinfo-font-lock-keywords nil nil nil backward-paragraph)) |
| 601 | (setq-local syntax-propertize-function texinfo-syntax-propertize-function) | 608 | (setq-local syntax-propertize-function texinfo-syntax-propertize-function) |
| 602 | (setq-local parse-sexp-lookup-properties t) | 609 | (setq-local parse-sexp-lookup-properties t) |
| 610 | (setq-local add-log-current-defun-function #'texinfo-current-defun-name) | ||
| 603 | 611 | ||
| 604 | ;; Outline settings. | 612 | ;; Outline settings. |
| 605 | (setq-local outline-heading-alist | 613 | (setq-local outline-heading-alist |