diff options
Diffstat (limited to 'lisp/textmodes')
-rw-r--r-- | lisp/textmodes/css-mode.el | 32 | ||||
-rw-r--r-- | lisp/textmodes/fill.el | 6 | ||||
-rw-r--r-- | lisp/textmodes/ispell.el | 311 | ||||
-rw-r--r-- | lisp/textmodes/reftex-parse.el | 2 | ||||
-rw-r--r-- | lisp/textmodes/reftex-toc.el | 2 | ||||
-rw-r--r-- | lisp/textmodes/reftex.el | 24 | ||||
-rw-r--r-- | lisp/textmodes/sgml-mode.el | 134 | ||||
-rw-r--r-- | lisp/textmodes/table.el | 2 | ||||
-rw-r--r-- | lisp/textmodes/tex-mode.el | 113 | ||||
-rw-r--r-- | lisp/textmodes/texinfo.el | 112 |
10 files changed, 415 insertions, 323 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 97b1dcfb238..cb19c018839 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -266,22 +266,22 @@ ;;;###autoload (define-derived-mode css-mode fundamental-mode "CSS" "Major mode to edit Cascading Style Sheets." - (set (make-local-variable 'font-lock-defaults) css-font-lock-defaults) - (set (make-local-variable 'comment-start) "/*") - (set (make-local-variable 'comment-start-skip) "/\\*+[ \t]*") - (set (make-local-variable 'comment-end) "*/") - (set (make-local-variable 'comment-end-skip) "[ \t]*\\*+/") - (set (make-local-variable 'forward-sexp-function) 'css-forward-sexp) - (set (make-local-variable 'parse-sexp-ignore-comments) t) - (set (make-local-variable 'indent-line-function) 'css-indent-line) - (set (make-local-variable 'fill-paragraph-function) - 'css-fill-paragraph) + (setq-local font-lock-defaults css-font-lock-defaults) + (setq-local comment-start "/*") + (setq-local comment-start-skip "/\\*+[ \t]*") + (setq-local comment-end "*/") + (setq-local comment-end-skip "[ \t]*\\*+/") + (setq-local forward-sexp-function 'css-forward-sexp) + (setq-local parse-sexp-ignore-comments t) + (setq-local indent-line-function 'css-indent-line) + (setq-local fill-paragraph-function 'css-fill-paragraph) + (setq-local add-log-current-defun-function #'css-current-defun-name) (when css-electric-keys (let ((fc (make-char-table 'auto-fill-chars))) (set-char-table-parent fc auto-fill-chars) (dolist (c css-electric-keys) (aset fc c 'indent-according-to-mode)) - (set (make-local-variable 'auto-fill-chars) fc)))) + (setq-local auto-fill-chars fc)))) (defvar comment-continue) @@ -481,5 +481,15 @@ (save-excursion (indent-line-to indent)) (indent-line-to indent))))) +(defun css-current-defun-name () + "Return the name of the CSS section at point, or nil." + (save-excursion + (let ((max (max (point-min) (- (point) 1600)))) ; approx 20 lines back + (when (search-backward "{" max t) + (skip-chars-backward " \t\r\n") + (beginning-of-line) + (if (looking-at "^[ \t]*\\([^{\r\n]*[^ {\t\r\n]\\)") + (match-string-no-properties 1)))))) + (provide 'css-mode) ;;; css-mode.el ends here diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index feb2fa6cc73..5b6d5f359e6 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -721,7 +721,11 @@ space does not end a sentence, so don't break a line there." (move-to-column (current-fill-column)) (if (when (< (point) to) ;; Find the position where we'll break the line. - (forward-char 1) ;Use an immediately following space, if any. + ;; Use an immediately following space, if any. + ;; However, note that `move-to-column' may overshoot + ;; if there are wide characters (Bug#3234). + (unless (> (current-column) (current-fill-column)) + (forward-char 1)) (fill-move-to-break-point linebeg) ;; Check again to see if we got to the end of ;; the paragraph. diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 7bdb587c560..067ffdaa1f0 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -357,6 +357,10 @@ Must be greater than 1." "ispell") "Program invoked by \\[ispell-word] and \\[ispell-region] commands." :type 'string + :set (lambda (symbol value) + (set-default symbol value) + (if (featurep 'ispell) + (ispell-set-spellchecker-params))) :group 'ispell) (defcustom ispell-alternate-dictionary @@ -903,6 +907,24 @@ Otherwise returns the library directory name, if that is defined." (setq default-directory (expand-file-name "~/"))) (apply 'call-process-region args))) +(defun ispell-create-debug-buffer (&optional append) + "Create an ispell debug buffer for debugging output. +Use APPEND to append the info to previous buffer if exists, +otherwise is reset. Returns name of ispell debug buffer. +See `ispell-buffer-with-debug' for an example of use." + (let ((ispell-debug-buffer (get-buffer-create "*ispell-debug*"))) + (with-current-buffer ispell-debug-buffer + (if append + (insert + (format "-----------------------------------------------\n")) + (erase-buffer))) + ispell-debug-buffer)) + +(defsubst ispell-print-if-debug (string) + "Print STRING to `ispell-debug-buffer' buffer if enabled." + (if (boundp 'ispell-debug-buffer) + (with-current-buffer ispell-debug-buffer + (insert string)))) ;; The preparation of the menu bar menu must be autoloaded @@ -2627,11 +2649,8 @@ When asynchronous processes are not supported, `run' is always returned." (defun ispell-start-process () "Start the Ispell process, with support for no asynchronous processes. Keeps argument list for future Ispell invocations for no async support." - ;; Local dictionary becomes the global dictionary in use. - (setq ispell-current-dictionary - (or ispell-local-dictionary ispell-dictionary)) - (setq ispell-current-personal-dictionary - (or ispell-local-pdict ispell-personal-dictionary)) + ;; `ispell-current-dictionary' and `ispell-current-personal-dictionary' + ;; are properly set in `ispell-internal-change-dictionary'. (let* ((default-directory (if (and (file-directory-p default-directory) (file-readable-p default-directory)) @@ -2646,8 +2665,7 @@ Keeps argument list for future Ispell invocations for no async support." (list "-d" ispell-current-dictionary)) orig-args (if ispell-current-personal-dictionary ; Use specified pers dict. - (list "-p" - (expand-file-name ispell-current-personal-dictionary))) + (list "-p" ispell-current-personal-dictionary)) ;; If we are using recent aspell or hunspell, make sure we use the ;; right encoding for communication. ispell or older aspell/hunspell ;; does not support this. @@ -2684,6 +2702,9 @@ Keeps argument list for future Ispell invocations for no async support." (let* (;; Basename of dictionary used by the spell-checker (dict-bname (or (car (cdr (member "-d" (ispell-get-ispell-args)))) ispell-current-dictionary)) + ;; The directory where process was started. + (current-ispell-directory default-directory) + ;; The default directory for the process. ;; Use "~/" as default-directory unless using Ispell with per-dir ;; personal dictionaries and not in a minibuffer under XEmacs (default-directory @@ -2874,13 +2895,15 @@ By just answering RET you can find out what the current dictionary is." "Update the dictionary and the personal dictionary used by Ispell. This may kill the Ispell process; if so, a new one will be started when needed." - (let ((dict (or ispell-local-dictionary ispell-dictionary)) - (pdict (or ispell-local-pdict ispell-personal-dictionary))) + (let* ((dict (or ispell-local-dictionary ispell-dictionary)) + (pdict (or ispell-local-pdict ispell-personal-dictionary)) + (expanded-pdict (if pdict (expand-file-name pdict)))) (unless (and (equal ispell-current-dictionary dict) - (equal ispell-current-personal-dictionary pdict)) + (equal ispell-current-personal-dictionary + expanded-pdict)) (ispell-kill-ispell t) (setq ispell-current-dictionary dict - ispell-current-personal-dictionary pdict)))) + ispell-current-personal-dictionary expanded-pdict)))) ;; Avoid error messages when compiling for these dynamic variables. (defvar ispell-start) @@ -2898,114 +2921,142 @@ amount for last line processed." (if (not recheckp) (ispell-accept-buffer-local-defs)) ; set up dictionary, local words, etc. (let ((skip-region-start (make-marker)) - (rstart (make-marker))) - (unwind-protect - (save-excursion - (message "Spell-checking %s using %s with %s dictionary..." - (if (and (= reg-start (point-min)) (= reg-end (point-max))) - (buffer-name) "region") - (file-name-nondirectory ispell-program-name) - (or ispell-current-dictionary "default")) - ;; Returns cursor to original location. - (save-window-excursion - (goto-char reg-start) - (let ((transient-mark-mode) - (case-fold-search case-fold-search) - (query-fcc t) - in-comment key) - (let (message-log-max) - (message "searching for regions to skip")) - (if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t) - (progn - (setq key (match-string-no-properties 0)) - (set-marker skip-region-start (- (point) (length key))) - (goto-char reg-start))) - (let (message-log-max) - (message - "Continuing spelling check using %s with %s dictionary..." - (file-name-nondirectory ispell-program-name) - (or ispell-current-dictionary "default"))) - (set-marker rstart reg-start) - (set-marker ispell-region-end reg-end) - (while (and (not ispell-quit) - (< (point) ispell-region-end)) - ;; spell-check region with skipping - (if (and (marker-position skip-region-start) - (<= skip-region-start (point))) + (rstart (make-marker)) + (region-type (if (and (= reg-start (point-min)) (= reg-end (point-max))) + (buffer-name) "region")) + (program-basename (file-name-nondirectory ispell-program-name)) + (dictionary (or ispell-current-dictionary "default"))) + (unwind-protect + (save-excursion + (message "Spell-checking %s using %s with %s dictionary..." + region-type program-basename dictionary) + ;; Returns cursor to original location. + (save-window-excursion + (goto-char reg-start) + (let ((transient-mark-mode) + (case-fold-search case-fold-search) + (query-fcc t) + in-comment key) + (ispell-print-if-debug + (concat + (format + "ispell-region: (ispell-skip-region-list):\n%s\n" + (ispell-skip-region-list)) + (format + "ispell-region: (ispell-begin-skip-region-regexp):\n%s\n" + (ispell-begin-skip-region-regexp)) + "ispell-region: Search for first region to skip after (ispell-begin-skip-region-regexp)\n")) + (if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t) (progn - ;; If region inside line comment, must keep comment start. - (setq in-comment (point) - in-comment - (and comment-start - (or (null comment-end) (string= "" comment-end)) - (save-excursion - (beginning-of-line) - (re-search-forward comment-start in-comment t)) - comment-start)) - ;; Can change skip-regexps (in ispell-message) - (ispell-skip-region key) ; moves pt past region. - (set-marker rstart (point)) - ;; check for saving large attachments... - (setq query-fcc (and query-fcc - (ispell-ignore-fcc skip-region-start - rstart))) - (if (and (< rstart ispell-region-end) - (re-search-forward - (ispell-begin-skip-region-regexp) - ispell-region-end t)) - (progn - (setq key (match-string-no-properties 0)) - (set-marker skip-region-start - (- (point) (length key))) - (goto-char rstart)) - (set-marker skip-region-start nil)))) - (setq reg-end (max (point) - (if (marker-position skip-region-start) - (min skip-region-start ispell-region-end) - (marker-position ispell-region-end)))) - (let* ((ispell-start (point)) - (ispell-end (min (point-at-eol) reg-end)) - (string (ispell-get-line - ispell-start ispell-end in-comment))) - (if in-comment ; account for comment chars added - (setq ispell-start (- ispell-start (length in-comment)) - in-comment nil)) - (setq ispell-end (point)) ; "end" tracks region retrieved. - (if string ; there is something to spell check! - ;; (special start end) - (setq shift (ispell-process-line string - (and recheckp shift)))) - (goto-char ispell-end))))) - (if ispell-quit - nil - (or shift 0))) - ;; protected - (if (and (not (and recheckp ispell-keep-choices-win)) - (get-buffer ispell-choices-buffer)) - (kill-buffer ispell-choices-buffer)) - (set-marker skip-region-start nil) - (set-marker rstart nil) - (if ispell-quit - (progn - ;; preserve or clear the region for ispell-continue. - (if (not (numberp ispell-quit)) - (set-marker ispell-region-end nil) - ;; Ispell-continue enabled - ispell-region-end is set. - (goto-char ispell-quit)) - ;; Check for aborting - (if (and ispell-checking-message (numberp ispell-quit)) - (progn - (setq ispell-quit nil) - (error "Message send aborted"))) - (if (not recheckp) (setq ispell-quit nil))) - (if (not recheckp) (set-marker ispell-region-end nil)) - ;; Only save if successful exit. - (ispell-pdict-save ispell-silently-savep) - (message "Spell-checking %s using %s with %s dictionary...done" - (if (and (= reg-start (point-min)) (= reg-end (point-max))) - (buffer-name) "region") - (file-name-nondirectory ispell-program-name) - (or ispell-current-dictionary "default")))))) + (setq key (match-string-no-properties 0)) + (set-marker skip-region-start (- (point) (length key))) + (goto-char reg-start) + (ispell-print-if-debug + (format "ispell-region: First skip: %s at (pos,line,column): (%s,%s,%s).\n" + key + (save-excursion (goto-char skip-region-start) (point)) + (line-number-at-pos skip-region-start) + (save-excursion (goto-char skip-region-start) (current-column)))))) + (ispell-print-if-debug + (format + "ispell-region: Continue spell-checking with %s and %s dictionary...\n" + program-basename dictionary)) + (set-marker rstart reg-start) + (set-marker ispell-region-end reg-end) + (while (and (not ispell-quit) + (< (point) ispell-region-end)) + ;; spell-check region with skipping + (if (and (marker-position skip-region-start) + (<= skip-region-start (point))) + (progn + ;; If region inside line comment, must keep comment start. + (setq in-comment (point) + in-comment + (and comment-start + (or (null comment-end) (string= "" comment-end)) + (save-excursion + (beginning-of-line) + (re-search-forward comment-start in-comment t)) + comment-start)) + ;; Can change skip-regexps (in ispell-message) + (ispell-skip-region key) ; moves pt past region. + (set-marker rstart (point)) + ;; check for saving large attachments... + (setq query-fcc (and query-fcc + (ispell-ignore-fcc skip-region-start + rstart))) + (if (and (< rstart ispell-region-end) + (re-search-forward + (ispell-begin-skip-region-regexp) + ispell-region-end t)) + (progn + (setq key (match-string-no-properties 0)) + (set-marker skip-region-start + (- (point) (length key))) + (goto-char rstart) + (ispell-print-if-debug + (format "ispell-region: Next skip: %s at (pos,line,column): (%s,%s,%s).\n" + key + (save-excursion (goto-char skip-region-start) (point)) + (line-number-at-pos skip-region-start) + (save-excursion (goto-char skip-region-start) (current-column))))) + (set-marker skip-region-start nil)))) + (setq reg-end (max (point) + (if (marker-position skip-region-start) + (min skip-region-start ispell-region-end) + (marker-position ispell-region-end)))) + (let* ((ispell-start (point)) + (ispell-end (min (point-at-eol) reg-end)) + ;; See if line must be prefixed by comment string to let ispell know this is + ;; part of a comment string. This is only supported in some modes. + ;; In particular, this is not supported in autoconf mode where adding the + ;; comment string messes everything up because ispell tries to spellcheck the + ;; `dnl' string header causing misalignments in some cases (debbugs.gnu.org: #12768). + (add-comment (and in-comment + (not (string= in-comment "dnl ")) + in-comment)) + (string (ispell-get-line + ispell-start ispell-end add-comment))) + (ispell-print-if-debug + (format + "ispell-region: string pos (%s->%s), eol: %s, [in-comment]: [%s], [add-comment]: [%s], [string]: [%s]\n" + ispell-start ispell-end (point-at-eol) in-comment add-comment string)) + (if add-comment ; account for comment chars added + (setq ispell-start (- ispell-start (length add-comment)) + add-comment nil)) + (setq ispell-end (point)) ; "end" tracks region retrieved. + (if string ; there is something to spell check! + ;; (special start end) + (setq shift (ispell-process-line string + (and recheckp shift)))) + (goto-char ispell-end))))) + (if ispell-quit + nil + (or shift 0))) + ;; protected + (if (and (not (and recheckp ispell-keep-choices-win)) + (get-buffer ispell-choices-buffer)) + (kill-buffer ispell-choices-buffer)) + (set-marker skip-region-start nil) + (set-marker rstart nil) + (if ispell-quit + (progn + ;; preserve or clear the region for ispell-continue. + (if (not (numberp ispell-quit)) + (set-marker ispell-region-end nil) + ;; Ispell-continue enabled - ispell-region-end is set. + (goto-char ispell-quit)) + ;; Check for aborting + (if (and ispell-checking-message (numberp ispell-quit)) + (progn + (setq ispell-quit nil) + (error "Message send aborted"))) + (if (not recheckp) (setq ispell-quit nil))) + (if (not recheckp) (set-marker ispell-region-end nil)) + ;; Only save if successful exit. + (ispell-pdict-save ispell-silently-savep) + (message "Spell-checking %s using %s with %s dictionary...done" + region-type program-basename dictionary))))) (defun ispell-begin-skip-region-regexp () @@ -3252,10 +3303,19 @@ Returns the sum SHIFT due to changes in word replacements." ;; Alignment cannot be tracked and this error will occur when ;; `query-replace' makes multiple corrections on the starting line. (or (ispell-looking-at (car poss)) - ;; This occurs due to filter pipe problems - (error (concat "Ispell misalignment: word " - "`%s' point %d; probably incompatible versions") - (car poss) (marker-position word-start))) + ;; This error occurs due to filter pipe problems + (let* ((ispell-pipe-word (car poss)) + (actual-point (marker-position word-start)) + (actual-line (line-number-at-pos actual-point)) + (actual-column (save-excursion (goto-char actual-point) (current-column)))) + (ispell-print-if-debug + (concat + "ispell-process-line: Ispell misalignment error:\n" + (format " [Word from ispell pipe]: [%s], actual (point,line,column): (%s,%s,%s)\n" + ispell-pipe-word actual-point actual-line actual-column))) + (error (concat "Ispell misalignment: word " + "`%s' point %d; probably incompatible versions") + ispell-pipe-word actual-point))) ;; ispell-cmd-loop can go recursive & change buffer (if ispell-keep-choices-win (setq replace (ispell-command-loop @@ -3389,6 +3449,13 @@ Returns the sum SHIFT due to changes in word replacements." (interactive) (ispell-region (point-min) (point-max))) +;;;###autoload +(defun ispell-buffer-with-debug (&optional append) + "`ispell-buffer' with some output sent to `ispell-debug-buffer' buffer. +Use APPEND to append the info to previous buffer if exists." + (interactive) + (let ((ispell-debug-buffer (ispell-create-debug-buffer append))) + (ispell-buffer))) ;;;###autoload (defun ispell-continue () diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el index 095c5953947..a86b10e21cc 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el @@ -251,7 +251,7 @@ of master file." ;; the next parsing iteration. (when (eq (char-before) ?\\) (backward-char)) ;; Insert in List - (setq toc-entry (reftex-section-info file)) + (setq toc-entry (funcall reftex-section-info-function file)) (when toc-entry ;; It can happen that section info returns nil (setq level (nth 5 toc-entry)) diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el index 2beb3af628b..248e36a5299 100644 --- a/lisp/textmodes/reftex-toc.el +++ b/lisp/textmodes/reftex-toc.el @@ -785,7 +785,7 @@ PRO-OR-DE is assumed to be dynamically scoped into this function." (marker (nth 4 data))) (with-current-buffer (marker-buffer marker) (goto-char (marker-position marker)) - (if (looking-at (concat "\\([ \t]*\\\\\\)" (regexp-quote name))) + (if (looking-at (concat "\\([ \t]*" reftex-section-pre-regexp "\\)" (regexp-quote name))) (replace-match (concat "\\1" newname)) (error "Fatal error during %smotion" pro-or-de))))) diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index d511bf9ff8b..a41409fc897 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el @@ -301,7 +301,9 @@ on the menu bar. (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib) (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib) (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib) - (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib)) + (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib) + + (run-hooks 'reftex-mode-hook)) ;; Mode was turned off (easy-menu-remove reftex-mode-menu))) @@ -664,6 +666,16 @@ will deactivate it." (defvar reftex-find-label-regexp-format nil) (defvar reftex-find-label-regexp-format2 nil) +;; Constants for making RefTeX open to Texinfo hooking +(defvar reftex-section-pre-regexp "\\\\") +;; Including `\' as a character to be matched at the end of the regexp +;; will allow stuff like \begin{foo}\label{bar} to be matched. This +;; will make the parser to advance one char too much. Therefore +;; `reftex-parse-from-file' will step one char back if a section is +;; found. +(defvar reftex-section-post-regexp "\\*?\\(\\[[^]]*\\]\\)?[[{ \t\r\n\\]") +(defvar reftex-section-info-function 'reftex-section-info) + (defvar reftex-memory nil "Memorizes old variable values to indicate changes in these variables.") @@ -1083,16 +1095,10 @@ This enforces rescanning the buffer on next use." reftex-include-file-commands "\\|") "\\)[{ \t]+\\([^} \t\n\r]+\\)")) (section-re - ;; Including `\' as a character to be matched at the end - ;; of the regexp will allow stuff like - ;; \begin{foo}\label{bar} to be matched. This will make - ;; the parser to advance one char too much. Therefore - ;; `reftex-parse-from-file' will step one char back if a - ;; section is found. - (concat wbol "\\\\\\(" + (concat wbol reftex-section-pre-regexp "\\(" (mapconcat (lambda (x) (regexp-quote (car x))) reftex-section-levels-all "\\|") - "\\)\\*?\\(\\[[^]]*\\]\\)?[[{ \t\r\n\\]")) + "\\)" reftex-section-post-regexp)) (appendix-re (concat wbol "\\(\\\\appendix\\)")) (macro-re (if macros-with-labels diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 74b26db1064..a7e44402a26 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -463,47 +463,39 @@ Do \\[describe-key] on the following bindings to discover what they do. ;; A start or end tag by itself on a line separates a paragraph. ;; This is desirable because SGML discards a newline that appears ;; immediately after a start tag or immediately before an end tag. - (set (make-local-variable 'paragraph-start) (concat "[ \t]*$\\|\ + (setq-local paragraph-start (concat "[ \t]*$\\|\ \[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>")) - (set (make-local-variable 'paragraph-separate) - (concat paragraph-start "$")) - (set (make-local-variable 'adaptive-fill-regexp) "[ \t]*") + (setq-local paragraph-separate (concat paragraph-start "$")) + (setq-local adaptive-fill-regexp "[ \t]*") (add-hook 'fill-nobreak-predicate 'sgml-fill-nobreak nil t) - (set (make-local-variable 'indent-line-function) 'sgml-indent-line) - (set (make-local-variable 'comment-start) "<!-- ") - (set (make-local-variable 'comment-end) " -->") - (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent) - (set (make-local-variable 'comment-line-break-function) - 'sgml-comment-indent-new-line) - (set (make-local-variable 'skeleton-further-elements) - '((completion-ignore-case t))) - (set (make-local-variable 'skeleton-end-hook) - (lambda () - (or (eolp) - (not (or (eq v2 '\n) (eq (car-safe v2) '\n))) - (newline-and-indent)))) - (set (make-local-variable 'font-lock-defaults) - '((sgml-font-lock-keywords - sgml-font-lock-keywords-1 - sgml-font-lock-keywords-2) - nil t)) - (set (make-local-variable 'syntax-propertize-function) - sgml-syntax-propertize-function) - (set (make-local-variable 'facemenu-add-face-function) - 'sgml-mode-facemenu-add-face-function) - (set (make-local-variable 'sgml-xml-mode) (sgml-xml-guess)) - (if sgml-xml-mode - () - (set (make-local-variable 'skeleton-transformation-function) - sgml-transformation-function)) + (setq-local indent-line-function 'sgml-indent-line) + (setq-local comment-start "<!-- ") + (setq-local comment-end " -->") + (setq-local comment-indent-function 'sgml-comment-indent) + (setq-local comment-line-break-function 'sgml-comment-indent-new-line) + (setq-local skeleton-further-elements '((completion-ignore-case t))) + (setq-local skeleton-end-hook + (lambda () + (or (eolp) + (not (or (eq v2 '\n) (eq (car-safe v2) '\n))) + (newline-and-indent)))) + (setq font-lock-defaults '((sgml-font-lock-keywords + sgml-font-lock-keywords-1 + sgml-font-lock-keywords-2) + nil t)) + (setq-local syntax-propertize-function sgml-syntax-propertize-function) + (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) + (setq-local sgml-xml-mode (sgml-xml-guess)) + (unless sgml-xml-mode + (setq-local skeleton-transformation-function sgml-transformation-function)) ;; This will allow existing comments within declarations to be ;; recognized. ;; I can't find a clear description of SGML/XML comments, but it seems that ;; the only reliable ones are <!-- ... --> although it's not clear what ;; "..." can contain. It used to accept -- ... -- as well, but that was ;; apparently a mistake. - (set (make-local-variable 'comment-start-skip) "<!--[ \t]*") - (set (make-local-variable 'comment-end-skip) "[ \t]*--[ \t\n]*>") + (setq-local comment-start-skip "<!--[ \t]*") + (setq-local comment-end-skip "[ \t]*--[ \t\n]*>") ;; This definition has an HTML leaning but probably fits well for other modes. (setq imenu-generic-expression `((nil @@ -671,13 +663,13 @@ in your `.emacs': (if (eq v2 t) (setq v2 nil)) ;; We use `identity' to prevent skeleton from passing ;; `str' through `skeleton-transformation-function' a second time. - '(("") v2 _ v2 "</" (identity ',str) ?>)) + '(("") v2 _ v2 "</" (identity ',str) ?> >)) ((eq (car v2) t) (cons '("") (cdr v2))) (t (append '(("") (car v2)) (cdr v2) - '(resume: (car v2) _ "</" (identity ',str) ?>)))))) + '(resume: (car v2) _ "</" (identity ',str) ?> >)))))) (autoload 'skeleton-read "skeleton") @@ -982,10 +974,10 @@ With prefix argument ARG, repeat this ARG times." (unwind-protect (save-excursion (goto-char (point-min)) - (if (set (make-local-variable 'sgml-tags-invisible) - (if arg - (>= (prefix-numeric-value arg) 0) - (not sgml-tags-invisible))) + (if (setq-local sgml-tags-invisible + (if arg + (>= (prefix-numeric-value arg) 0) + (not sgml-tags-invisible))) (while (re-search-forward sgml-tag-name-re nil t) (setq string (cdr (assq (intern-soft (downcase (match-string 1))) @@ -1564,8 +1556,7 @@ Add this to `sgml-mode-hook' for convenience." (goto-char (point-min)) (if (re-search-forward "^\\([ \t]+\\)<" 500 'noerror) (progn - (set (make-local-variable 'sgml-basic-offset) - (1- (current-column))) + (setq-local sgml-basic-offset (1- (current-column))) (message "Guessed sgml-basic-offset = %d" sgml-basic-offset) )))) @@ -1941,6 +1932,19 @@ This takes effect when first loading the library.") (defvar outline-heading-end-regexp) (defvar outline-level) +(defun html-current-defun-name () + "Return the name of the last HTML title or heading, or nil." + (save-excursion + (if (re-search-backward + (concat + "<[ \t\r\n]*" + "\\(?:[hH][0-6]\\|title\\|TITLE\\|Title\\)" + "[^>]*>" + "[ \t\r\n]*" + "\\([^<\r\n]*[^ <\t\r\n]+\\)") + nil t) + (match-string-no-properties 1)))) + ;;;###autoload (define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML") @@ -1979,33 +1983,29 @@ To work around that, do: (eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil)) \\{html-mode-map}" - (set (make-local-variable 'sgml-display-text) html-display-text) - (set (make-local-variable 'sgml-tag-face-alist) html-tag-face-alist) - (make-local-variable 'sgml-tag-alist) - (make-local-variable 'sgml-face-tag-alist) - (make-local-variable 'sgml-tag-help) - (make-local-variable 'outline-regexp) - (make-local-variable 'outline-heading-end-regexp) - (make-local-variable 'outline-level) - (make-local-variable 'sentence-end-base) - (setq sentence-end-base "[.?!][]\"'”)}]*\\(<[^>]*>\\)*" - sgml-tag-alist html-tag-alist - sgml-face-tag-alist html-face-tag-alist - sgml-tag-help html-tag-help - outline-regexp "^.*<[Hh][1-6]\\>" - outline-heading-end-regexp "</[Hh][1-6]>" - outline-level (lambda () - (char-before (match-end 0)))) + (setq-local sgml-display-text html-display-text) + (setq-local sgml-tag-face-alist html-tag-face-alist) + (setq-local sgml-tag-alist html-tag-alist) + (setq-local sgml-face-tag-alist html-face-tag-alist) + (setq-local sgml-tag-help html-tag-help) + (setq-local outline-regexp "^.*<[Hh][1-6]\\>") + (setq-local outline-heading-end-regexp "</[Hh][1-6]>") + (setq-local outline-level + (lambda () (char-before (match-end 0)))) + (setq-local add-log-current-defun-function #'html-current-defun-name) + (setq-local sentence-end-base "[.?!][]\"'”)}]*\\(<[^>]*>\\)*") + (setq imenu-create-index-function 'html-imenu-index) - (set (make-local-variable 'sgml-empty-tags) - ;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd', - ;; plus manual addition of "wbr". - '("area" "base" "basefont" "br" "col" "frame" "hr" "img" "input" - "isindex" "link" "meta" "param" "wbr")) - (set (make-local-variable 'sgml-unclosed-tags) - ;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd'. - '("body" "colgroup" "dd" "dt" "head" "html" "li" "option" - "p" "tbody" "td" "tfoot" "th" "thead" "tr")) + + (setq-local sgml-empty-tags + ;; From HTML-4.01's loose.dtd, parsed with + ;; `sgml-parse-dtd', plus manual addition of "wbr". + '("area" "base" "basefont" "br" "col" "frame" "hr" "img" "input" + "isindex" "link" "meta" "param" "wbr")) + (setq-local sgml-unclosed-tags + ;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd'. + '("body" "colgroup" "dd" "dt" "head" "html" "li" "option" + "p" "tbody" "td" "tfoot" "th" "thead" "tr")) ;; It's for the user to decide if it defeats it or not -stef ;; (make-local-variable 'imenu-sort-function) ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el index 411604088ae..4d8a74323c7 100644 --- a/lisp/textmodes/table.el +++ b/lisp/textmodes/table.el @@ -5215,7 +5215,7 @@ instead of the current buffer and returns the OBJECT." "Update cell face according to the current mode." (if (featurep 'xemacs) (set-face-property 'table-cell 'underline table-fixed-width-mode) - (set-face-inverse-video-p 'table-cell table-fixed-width-mode))) + (set-face-inverse-video 'table-cell table-fixed-width-mode))) (table--update-cell-face) diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index db012e5cf9b..480ab8a581a 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -421,6 +421,17 @@ An alternative value is \" . \", if you use a font with a narrow period." (if (looking-at latex-outline-regexp) (1+ (or (cdr (assoc (match-string 1) latex-section-alist)) -1)) 1000)) + +(defun tex-current-defun-name () + "Return the name of the TeX section/paragraph/chapter at point, or nil." + (save-excursion + (when (re-search-backward + "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" + nil t) + (goto-char (match-beginning 0)) + (buffer-substring-no-properties + (1+ (point)) ; without initial backslash + (line-end-position))))) ;;;; ;;;; Font-Lock support @@ -1062,10 +1073,10 @@ tex-show-queue-command Entering Plain-tex mode runs the hook `text-mode-hook', then the hook `tex-mode-hook', and finally the hook `plain-tex-mode-hook'. When the special subshell is initiated, the hook `tex-shell-hook' is run." - (set (make-local-variable 'tex-command) tex-run-command) - (set (make-local-variable 'tex-start-of-header) "%\\*\\*start of header") - (set (make-local-variable 'tex-end-of-header) "%\\*\\*end of header") - (set (make-local-variable 'tex-trailer) "\\bye\n")) + (setq-local tex-command tex-run-command) + (setq-local tex-start-of-header "%\\*\\*start of header") + (setq-local tex-end-of-header "%\\*\\*end of header") + (setq-local tex-trailer "\\bye\n")) ;;;###autoload (define-derived-mode latex-mode tex-mode "LaTeX" @@ -1108,11 +1119,10 @@ tex-show-queue-command Entering Latex mode runs the hook `text-mode-hook', then `tex-mode-hook', and finally `latex-mode-hook'. When the special subshell is initiated, `tex-shell-hook' is run." - (set (make-local-variable 'tex-command) latex-run-command) - (set (make-local-variable 'tex-start-of-header) - "\\\\document\\(style\\|class\\)") - (set (make-local-variable 'tex-end-of-header) "\\\\begin\\s-*{document}") - (set (make-local-variable 'tex-trailer) "\\end{document}\n") + (setq-local tex-command latex-run-command) + (setq-local tex-start-of-header "\\\\document\\(style\\|class\\)") + (setq-local tex-end-of-header "\\\\begin\\s-*{document}") + (setq-local tex-trailer "\\end{document}\n") ;; A line containing just $$ is treated as a paragraph separator. ;; A line starting with $$ starts a paragraph, ;; but does not separate paragraphs if it has more stuff on it. @@ -1138,18 +1148,17 @@ subshell is initiated, `tex-shell-hook' is run." "marginpar" "parbox" "caption")) "\\|\\$\\$\\|[a-z]*\\(space\\|skip\\|page[a-z]*\\)" "\\>\\)[ \t]*\\($\\|%\\)\\)")) - (set (make-local-variable 'imenu-create-index-function) - 'latex-imenu-create-index) - (set (make-local-variable 'tex-face-alist) tex-latex-face-alist) + (setq-local imenu-create-index-function 'latex-imenu-create-index) + (setq-local tex-face-alist tex-latex-face-alist) (add-hook 'fill-nobreak-predicate 'latex-fill-nobreak-predicate nil t) - (set (make-local-variable 'indent-line-function) 'latex-indent) - (set (make-local-variable 'fill-indent-according-to-mode) t) + (setq-local indent-line-function 'latex-indent) + (setq-local fill-indent-according-to-mode t) (add-hook 'completion-at-point-functions 'latex-complete-data nil 'local) - (set (make-local-variable 'outline-regexp) latex-outline-regexp) - (set (make-local-variable 'outline-level) 'latex-outline-level) - (set (make-local-variable 'forward-sexp-function) 'latex-forward-sexp) - (set (make-local-variable 'skeleton-end-hook) nil)) + (setq-local outline-regexp latex-outline-regexp) + (setq-local outline-level 'latex-outline-level) + (setq-local forward-sexp-function 'latex-forward-sexp) + (setq-local skeleton-end-hook nil)) ;;;###autoload (define-derived-mode slitex-mode latex-mode "SliTeX" @@ -1198,39 +1207,36 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook (defun tex-common-initialization () ;; Regexp isearch should accept newline and formfeed as whitespace. - (set (make-local-variable 'search-whitespace-regexp) "[ \t\r\n\f]+") + (setq-local search-whitespace-regexp "[ \t\r\n\f]+") ;; A line containing just $$ is treated as a paragraph separator. - (set (make-local-variable 'paragraph-start) - "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$") + (setq-local paragraph-start "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$") ;; A line starting with $$ starts a paragraph, ;; but does not separate paragraphs if it has more stuff on it. - (set (make-local-variable 'paragraph-separate) - "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$[ \t]*$") - (set (make-local-variable 'comment-start) "%") - (set (make-local-variable 'comment-add) 1) - (set (make-local-variable 'comment-start-skip) - "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(%+ *\\)") - (set (make-local-variable 'parse-sexp-ignore-comments) t) - (set (make-local-variable 'compare-windows-whitespace) - 'tex-categorize-whitespace) - (set (make-local-variable 'facemenu-add-face-function) - 'tex-facemenu-add-face-function) - (set (make-local-variable 'facemenu-end-add-face) "}") - (set (make-local-variable 'facemenu-remove-face-function) t) - (set (make-local-variable 'font-lock-defaults) - '((tex-font-lock-keywords tex-font-lock-keywords-1 - tex-font-lock-keywords-2 tex-font-lock-keywords-3) - nil nil nil nil - ;; Who ever uses that anyway ??? - (font-lock-mark-block-function . mark-paragraph) - (font-lock-syntactic-face-function - . tex-font-lock-syntactic-face-function) - (font-lock-unfontify-region-function - . tex-font-lock-unfontify-region))) - (set (make-local-variable 'syntax-propertize-function) - (syntax-propertize-rules latex-syntax-propertize-rules)) + (setq-local paragraph-separate "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$[ \t]*$") + (setq-local add-log-current-defun-function #'tex-current-defun-name) + (setq-local comment-start "%") + (setq-local comment-add 1) + (setq-local comment-start-skip + "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(%+ *\\)") + (setq-local parse-sexp-ignore-comments t) + (setq-local compare-windows-whitespace 'tex-categorize-whitespace) + (setq-local facemenu-add-face-function 'tex-facemenu-add-face-function) + (setq-local facemenu-end-add-face "}") + (setq-local facemenu-remove-face-function t) + (setq-local font-lock-defaults + '((tex-font-lock-keywords tex-font-lock-keywords-1 + tex-font-lock-keywords-2 tex-font-lock-keywords-3) + nil nil nil nil + ;; Who ever uses that anyway ??? + (font-lock-mark-block-function . mark-paragraph) + (font-lock-syntactic-face-function + . tex-font-lock-syntactic-face-function) + (font-lock-unfontify-region-function + . tex-font-lock-unfontify-region))) + (setq-local syntax-propertize-function + (syntax-propertize-rules latex-syntax-propertize-rules)) ;; TABs in verbatim environments don't do what you think. - (set (make-local-variable 'indent-tabs-mode) nil) + (setq-local indent-tabs-mode nil) ;; Other vars that should be buffer-local. (make-local-variable 'tex-command) (make-local-variable 'tex-start-of-header) @@ -1523,8 +1529,7 @@ Puts point on a blank line between them." (looking-at bibtex-reference-key)) (push (match-string-no-properties 0) keys))))) ;; Fill the cache. - (set (make-local-variable 'latex-complete-bibtex-cache) - (list files key keys))) + (setq-local latex-complete-bibtex-cache (list files key keys))) (complete-with-action action keys key pred))))) (defun latex-complete-envnames () @@ -1885,8 +1890,7 @@ Mark is left at original location." ;; The utility functions: (define-derived-mode tex-shell shell-mode "TeX-Shell" - (set (make-local-variable 'compilation-error-regexp-alist) - tex-error-regexp-alist) + (setq-local compilation-error-regexp-alist tex-error-regexp-alist) (compilation-shell-minor-mode t)) ;;;###autoload @@ -2099,8 +2103,7 @@ of the current buffer." (with-no-warnings (when (boundp 'TeX-master) (cond ((stringp TeX-master) - (make-local-variable 'tex-main-file) - (setq tex-main-file TeX-master)) + (setq-local tex-main-file TeX-master)) ((and (eq TeX-master t) buffer-file-name) (file-relative-name buffer-file-name))))) ;; Try to guess the main file. @@ -2870,8 +2873,8 @@ There might be text before point." (cons (car x) 'doctex-font-lock-syntactic-face-function)) (_ x))) (cdr font-lock-defaults)))) - (set (make-local-variable 'syntax-propertize-function) - (syntax-propertize-rules doctex-syntax-propertize-rules))) + (setq-local syntax-propertize-function + (syntax-propertize-rules doctex-syntax-propertize-rules))) (run-hooks 'tex-mode-load-hook) diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index abff7f750c5..44e839d2474 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el @@ -33,6 +33,15 @@ ;;; Code: (eval-when-compile (require 'tex-mode)) +(declare-function tex-buffer "tex-mode" ()) +(declare-function tex-region "tex-mode" (beg end)) +(declare-function tex-send-command "tex-mode") +(declare-function tex-recenter-output-buffer "tex-mode" (linenum)) +(declare-function tex-print "tex-mode" (&optional alt)) +(declare-function tex-view "tex-mode" ()) +(declare-function tex-shell-running "tex-mode" ()) +(declare-function tex-kill-job "tex-mode" ()) + (defvar outline-heading-alist) (defgroup texinfo nil @@ -502,6 +511,12 @@ Subexpression 1 is what goes into the corresponding `@end' statement.") (regexp-opt (texinfo-filter 2 texinfo-section-list)) "Regular expression matching just the Texinfo chapter level headings.") +(defun texinfo-current-defun-name () + "Return the name of the Texinfo node at point, or nil." + (save-excursion + (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t) + (match-string-no-properties 1)))) + ;;; Texinfo mode ;;;###autoload @@ -571,66 +586,53 @@ be the first node in the file. Entering Texinfo mode calls the value of `text-mode-hook', and then the value of `texinfo-mode-hook'." - (set (make-local-variable 'page-delimiter) - (concat - "^@node [ \t]*[Tt]op\\|^@\\(" - texinfo-chapter-level-regexp - "\\)\\>")) - (make-local-variable 'require-final-newline) - (setq require-final-newline mode-require-final-newline) - (make-local-variable 'indent-tabs-mode) - (setq indent-tabs-mode nil) - (make-local-variable 'paragraph-separate) - (setq paragraph-separate - (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-separate)) - (make-local-variable 'paragraph-start) - (setq paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-start)) - (set (make-local-variable 'sentence-end-base) - "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*") - (make-local-variable 'fill-column) - (setq fill-column 70) - (make-local-variable 'comment-start) - (setq comment-start "@c ") - (make-local-variable 'comment-start-skip) - (setq comment-start-skip "@c +\\|@comment +") - (make-local-variable 'words-include-escapes) - (setq words-include-escapes t) - (make-local-variable 'imenu-generic-expression) - (setq imenu-generic-expression texinfo-imenu-generic-expression) + (setq-local page-delimiter + (concat "^@node [ \t]*[Tt]op\\|^@\\(" + texinfo-chapter-level-regexp + "\\)\\>")) + (setq-local require-final-newline mode-require-final-newline) + (setq-local indent-tabs-mode nil) + (setq-local paragraph-separate + (concat "\b\\|@[a-zA-Z]*[ \n]\\|" + paragraph-separate)) + (setq-local paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" + paragraph-start)) + (setq-local sentence-end-base "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*") + (setq-local fill-column 70) + (setq-local comment-start "@c ") + (setq-local comment-start-skip "@c +\\|@comment +") + (setq-local words-include-escapes t) + (setq-local imenu-generic-expression texinfo-imenu-generic-expression) (setq imenu-case-fold-search nil) - (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(texinfo-font-lock-keywords nil nil nil backward-paragraph)) - (set (make-local-variable 'syntax-propertize-function) - texinfo-syntax-propertize-function) - (set (make-local-variable 'parse-sexp-lookup-properties) t) + (setq-local syntax-propertize-function texinfo-syntax-propertize-function) + (setq-local parse-sexp-lookup-properties t) + (setq-local add-log-current-defun-function #'texinfo-current-defun-name) ;; Outline settings. - (set (make-local-variable 'outline-heading-alist) - ;; We should merge outline-heading-alist and texinfo-section-list - ;; but in the mean time, let's just generate one from the other. - (mapcar (lambda (x) (cons (concat "@" (car x)) (cadr x))) - texinfo-section-list)) - (set (make-local-variable 'outline-regexp) - (concat (regexp-opt (mapcar 'car outline-heading-alist) t) - "\\>")) - - (make-local-variable 'tex-start-of-header) - (setq tex-start-of-header "%\\*\\*start") - (make-local-variable 'tex-end-of-header) - (setq tex-end-of-header "%\\*\\*end") - (make-local-variable 'tex-first-line-header-regexp) - (setq tex-first-line-header-regexp "^\\\\input") - (make-local-variable 'tex-trailer) - (setq tex-trailer "@bye\n") - - ;; Prevent filling certain lines, in addition to ones specified - ;; by the user. - (let ((prevent-filling "^@\\(def\\|multitable\\)")) - (set (make-local-variable 'auto-fill-inhibit-regexp) - (if (null auto-fill-inhibit-regexp) - prevent-filling - (concat auto-fill-inhibit-regexp "\\|" prevent-filling))))) + (setq-local outline-heading-alist + ;; We should merge `outline-heading-alist' and + ;; `texinfo-section-list'. But in the mean time, let's + ;; just generate one from the other. + (mapcar (lambda (x) (cons (concat "@" (car x)) (cadr x))) + texinfo-section-list)) + (setq-local outline-regexp + (concat (regexp-opt (mapcar 'car outline-heading-alist) t) + "\\>")) + + (setq-local tex-start-of-header "%\\*\\*start") + (setq-local tex-end-of-header "%\\*\\*end") + (setq-local tex-first-line-header-regexp "^\\\\input") + (setq-local tex-trailer "@bye\n") + + ;; Prevent filling certain lines, in addition to ones specified by + ;; the user. + (setq-local auto-fill-inhibit-regexp + (let ((prevent-filling "^@\\(def\\|multitable\\)")) + (if (null auto-fill-inhibit-regexp) + prevent-filling + (concat auto-fill-inhibit-regexp "\\|" prevent-filling))))) |