branch: externals/auctex commit ceb169a21915feb070f1e5e9d9e8d3400514204d Merge: 6c32b97 097ec6c Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge remote-tracking branch 'origin/master' into externals/auctex --- doc/auctex.texi | 38 +++++----- doc/changes.texi | 9 ++- doc/todo.texi | 15 ++-- font-latex.el | 1 + latex.el | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++---- preview.el | 13 ++-- style/dinbrief.el | 3 +- style/letter.el | 3 +- style/ulem.el | 50 +++++++----- tex-buf.el | 20 ++--- tex-fold.el | 16 +++- tex-info.el | 9 ++- tex.el | 65 +++++++++++----- texmathp.el | 5 +- toolbar-x.el | 29 +++---- 15 files changed, 381 insertions(+), 118 deletions(-) diff --git a/doc/auctex.texi b/doc/auctex.texi index 5f01ba1..c5d36ff 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -1203,9 +1203,11 @@ The variable @code{LaTeX-math-list} allows you to add your own mappings. A list containing user-defined keys and commands to be used in @LaTeX{} Math mode. Each entry should be a list of two to four elements. -First, the key to be used after @code{LaTeX-math-abbrev-prefix} for -macro insertion. If it is nil, the symbol has no associated -keystroke (it is available in the menu, though). +First, the key to be used after @code{LaTeX-math-abbrev-prefix} for macro +insertion. The key can be a character (e.g.@: @samp{?o}) for a single +stroke or a string (e.g.@: @samp{"o a"}) for a multi-stroke binding. If it +is nil, the symbol has no associated keystroke (it is available in the +menu, though). Second, a string representing the name of the macro (without a leading backslash.) @@ -4116,7 +4118,7 @@ and if it is relevant for all text modes, append it to Other useful hooks are listed below. -@defvr Variable TeX-after-compilation-finished-hook +@defvr Variable TeX-after-compilation-finished-functions Hook which is run after the @TeX{}/@LaTeX{} processor has successfully finished compiling your document. (@xref{Processing}, for finding out how to compile your document.) Each function in the hook is run with @@ -4127,7 +4129,7 @@ re-compilation especially when using Emacs viewers such as DocView or PDF Tools. The function @code{TeX-revert-document-buffer} can be added to the hook for this purpose. @end defvr -@vindex TeX-after-compilation-finished-hook +@vindex TeX-after-compilation-finished-functions @findex TeX-revert-document-buffer @node Multifile @@ -4161,17 +4163,12 @@ advanced algorithm. (setq-default TeX-master nil) ; @r{Query for master file.} @end lisp -@c FIXME: It doesn't seem that current implementation has this -@c TeX-header-end aware feature. -If @AUCTeX{} finds the line indicating the end of the header in a master -file (@code{TeX-header-end}), it can figure out for itself that this is -a master file. Otherwise, it will ask for the name of the master file +In this case, @AUCTeX{} will ask for the name of the master file associated with the buffer. To avoid asking you again, @AUCTeX{} will automatically insert the name of the master file as a file variable (@pxref{File Variables,,,emacs,The Emacs Editor}). You can also insert the file variable yourself, by putting the following text at the end of your files. -@vindex TeX-header-end @example %%% Local Variables: @@ -5258,8 +5255,9 @@ prompt. @ftable @code @item TeX-arg-conditional -Implements if @var{expr} @var{then} @var{else}. If @var{expr} evaluates to true, parse @var{then} as an -argument list, else parse @var{else} as an argument list. +Implements if @var{expr} @var{then} @var{else}. If @var{expr} evaluates +to true, parse @var{then} as an argument list, else parse @var{else} as an +argument list. @item TeX-arg-literal Insert its arguments into the buffer. Used for specifying extra syntax @@ -5425,12 +5423,18 @@ Insert x and y coordinates as a pair. No arguments. Prompt for document author, using @code{LaTeX-default-author} as initial input. +@item TeX-read-hook +Prompt for a @LaTeX{} hook and return it. + +@item TeX-arg-hook +Prompt for a @LaTeX{} hook and insert it as a @TeX{} macro argument. + @item TeX-read-key-val Prompt for a @samp{key=value} list of options and return them. @item TeX-arg-key-val -Prompt for a @samp{key=value} list of options and insert it as a @TeX{} macro -argument. +Prompt for a @samp{key=value} list of options and insert it as a @TeX{} +macro argument. @end ftable If you add new hooks, you can assume that point is placed directly after @@ -5969,10 +5973,8 @@ The native Texinfo mode provides the binding @kbd{C-c C-t C-i} @kbd{C-c C-t C-p} (@code{texinfo-tex-print}) and @kbd{C-c C-t C-q} (@code{tex-show-print-queue}) for printing and showing the printer queue. These are superseded by the respective commands available -through @kbd{C-c C-c} (@code{TeX-command-master}) in @AUCTeX{}: @samp{Index}, +through @kbd{C-c C-c} (@code{TeX-command-master}) in @AUCTeX{}: @samp{Texindex}, @samp{Print}, and @samp{Queue}. -@c FIXME: "Index" runs makeindex, not texindex. No entry in -@c TeX-command-list runs texindex. @item Kill jobs The command @kbd{C-c C-t C-k} (@code{tex-kill-job}) in the native mode diff --git a/doc/changes.texi b/doc/changes.texi index a24ff5b..c702341 100644 --- a/doc/changes.texi +++ b/doc/changes.texi @@ -105,6 +105,11 @@ now is an obsolete alias. The style @file{latexinfo.el} is removed from @AUCTeX{}. @file{latexinfo.el} was meant to support latexinfo which in return was a @LaTeX{}-2.09 extension of Texinfo, but didn't manage to replace Texinfo. + +@item +@AUCTeX{} has preliminary support for @LaTeX{}-hooks. Hooks provided by +@LaTeX{} kernel are known and available for completion in +@samp{\AddToHook}, @samp{\RemoveFromHook} and @samp{\AddToHookNext}. @end itemize @heading News in 12.3 @@ -177,7 +182,7 @@ More bugs fixed, other minor features implemented. @samp{filecontents} environment now takes an optional argument and can be used anywhere in a document. The macros @samp{\Ref} and @samp{\labelformat} are moved from @file{varioref.sty} to @LaTeX{} -kernel. amsmath has a new macro @samp{\overunderset}. +kernel. @samp{amsmath} has a new macro @samp{\overunderset}. @item A new method is implemented in @previewlatex{} to adjust the foreground @@ -229,7 +234,7 @@ in Texinfo mode. In addition, the option @code{TeX-electric-escape} is now effective in Texinfo mode. When it is enabled, typing @kbd{@@} will invoke @code{TeX-electric-macro} offering completion in similar style with -other TeX modes of @AUCTeX{}. +other @TeX{} modes of @AUCTeX{}. @item Fontification support for @samp{biblatex} package is improved and diff --git a/doc/todo.texi b/doc/todo.texi index 9818a8b..3c0c13f 100644 --- a/doc/todo.texi +++ b/doc/todo.texi @@ -47,17 +47,17 @@ development efforts and avoid redundant work. @item Error help catalogs Currently, the help for errors is more or less hardwired into -@file{tex.el}. For supporting error help in other languages, it would +@file{latex.el}. For supporting error help in other languages, it would be sensible to instead arrange error messages in language-specific files, make a common info file from all such catalogs in a given language and look the error texts up in an appropriate index. The user would then specify a preference list of languages, and the errors would be looked up in the catalogs in sequence until they were identified. -@item Combining @samp{docTeX} with RefTeX +@item Combining @samp{docTeX} with Ref@TeX{} Macro cross references should also be usable for document navigation -using RefTeX. +using Ref@TeX{}. @item Fix remove-style feature @@ -73,6 +73,9 @@ major mode function kills all buffer-local variables. As of @AUCTeX{} 12.3, @code{TeX-remove-style} is no longer used by any other codes. +@item +Document @code{LaTeX-insert-into-commments} and +@code{TeX-translate-location-hook}. @end itemize @node Wishlist @@ -97,7 +100,7 @@ Fringe indicators for errors in the main text would be nice. A separate frame with a table of math character graphics to click on in order to insert the respective sequence into the buffer (cf. the -``grid'' of x-symbol). +``grid'' of @samp{x-symbol}). @item Crossreferencing support @@ -166,7 +169,7 @@ document. @item A nice hierarchical by-topic organization of all officially documented -LaTeX macros, available from the menu bar. +@LaTeX{} macros, available from the menu bar. @item @code{TeX-command-default} should be set from the master file, if not @@ -275,7 +278,7 @@ Do not overwrite emacs warnings about existing auto-save files when loading a new file. @item -Maybe the regexp for matching a TeX symbol during parsing should be +Maybe the regexp for matching a @TeX{} symbol during parsing should be @samp{"\\\\\\([a-zA-Z]+\\|.\\)"} --- @email{thiemann@@informatik.uni-tuebingen.de} Peter Thiemann. diff --git a/font-latex.el b/font-latex.el index da95bc2..18c04d5 100644 --- a/font-latex.el +++ b/font-latex.el @@ -353,6 +353,7 @@ variable `font-latex-fontify-sectioning'." ',num) ("addvspace" "{") ("vspace" "*{") ("hspace" "*{") ("thinspace" "") ("negthinspace" "") ("labelformat" "{{") + ("AddToHook" "{[{") ("RemoveFromHook" "{[") ("AddToHookNext" "{{") ;; XXX: Should macros without arguments rather be listed in a ;; separate category with 'noarg instead of 'command handling? ("enspace" "") ("enskip" "") ("quad" "") ("qquad" "") ("nonumber" "") diff --git a/latex.el b/latex.el index 5204ff4..ded745f 100644 --- a/latex.el +++ b/latex.el @@ -58,6 +58,7 @@ (defvar outline-heading-alist) (defvar TeX-auto-file) (defvar LaTeX-section-list-changed) +(defvar TeX-error-description-list-local) ;;; Syntax @@ -1204,7 +1205,9 @@ If SHORT-CAPTION is non-nil pass it as an optional argument to (unless (zerop (length float)) (concat LaTeX-optop float LaTeX-optcl))) - (when active-mark (goto-char start-marker)) + (when active-mark + (goto-char start-marker) + (set-marker start-marker nil)) (when center (insert TeX-esc "centering") (indent-according-to-mode) @@ -1226,7 +1229,9 @@ If SHORT-CAPTION is non-nil pass it as an optional argument to (LaTeX-newline) (indent-according-to-mode))) ;; bottom caption (default) - (when active-mark (goto-char end-marker)) + (when active-mark + (goto-char end-marker) + (set-marker end-marker nil)) (save-excursion (LaTeX-newline) (indent-according-to-mode) @@ -2337,7 +2342,7 @@ string." ("slides")) "List of document classes offered when inserting a document environment. -If `TeX-arg-input-file-search' is set to `t', you will get +If `TeX-arg-input-file-search' is set to t, you will get completion with all LaTeX classes available in your distribution and this variable will be ignored." :group 'LaTeX-environment @@ -2430,13 +2435,20 @@ To insert a hook here, you must insert it in the appropiate style file.") Initialized once at the first time you prompt for an input file. May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.") +(defvar TeX-global-input-files-with-extension nil + "List of the non-local TeX input files with extension. +Initialized once at the first time you prompt for an input file +inside a file hook command. +May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.") + (defvar LaTeX-global-package-files nil "List of the LaTeX package files. Initialized once at the first time you prompt for a LaTeX package. May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.") -;; Add both variables to `TeX-normal-mode-reset-list': +;; Add the variables to `TeX-normal-mode-reset-list': (add-to-list 'TeX-normal-mode-reset-list 'TeX-global-input-files) +(add-to-list 'TeX-normal-mode-reset-list 'TeX-global-input-files-with-extension) (add-to-list 'TeX-normal-mode-reset-list 'LaTeX-global-package-files) (defun LaTeX-arg-usepackage-read-packages-with-options () @@ -3102,6 +3114,170 @@ as values for the key. Use PROMPT as the prompt string." (let ((options (TeX-read-key-val optional key-val-alist prompt))) (TeX-argument-insert options optional))) +(defun TeX-read-hook () + "Read a LaTeX hook and return it as a string." + (let* ((hook (completing-read + (TeX-argument-prompt nil nil "Hook") + '("cmd" + "env" + ;; From ltfilehook-doc.pdf + "file/before" "file/after" + "include/before" "include/end" "include/after" + "class/before" "class/after" + "package/before" "package/after" + ;; From lthooks-doc.pdf + "begindocument" + "begindocument/before" + "begindocument/end" + "enddocument" + "enddocument/afterlastpage" + "enddocument/afteraux" + "enddocument/info" + "enddocument/end" + "rmfamily" "sffamily" + "ttfamily" "normalfont" + "bfseries" "bfseries/defaults" + "mdseries" "mdseries/defaults" + ;; From ltshipout-doc.pdf + "shipout/before" "shipout/after" + "shipout/foreground" "shipout/background" + "shipout/firstpage" "shipout/lastpage" + ;; From ltpara-doc.pdf + "para/before" "para/begin" + "para/end" "para/after"))) + (place (lambda () + (completing-read + (TeX-argument-prompt nil nil "Where") + (if (string= hook "cmd") + '("after" "before") + '("before" "begin" "end" "after"))))) + (search (lambda () + (if (eq TeX-arg-input-file-search 'ask) + (not (y-or-n-p "Find file yourself? ")) + TeX-arg-input-file-search))) + name where files ); result + (cond ((string= hook "cmd") + ;; cmd/<name>/<where> + (setq name (completing-read + (TeX-argument-prompt nil nil "Command") + (TeX-symbol-list))) + (setq where (funcall place))) + + ;; env/<name>/<where> + ((string= hook "env") + (setq name (completing-read + (TeX-argument-prompt nil nil "Environment") + (LaTeX-environment-list))) + (setq where (funcall place))) + + ;; file/(before|after)/<file-name.xxx> where <file-name> is + ;; optional and must be with extension + ((member hook '("file/before" "file/after")) + (if (funcall search) + (progn + (unless TeX-global-input-files-with-extension + (setq TeX-global-input-files-with-extension + (prog2 + (message "Searching for files...") + (mapcar #'list + (TeX-search-files-by-type 'texinputs + 'global + t nil)) + (message "Searching for files...done")))) + (setq name + (completing-read + (TeX-argument-prompt t nil "File") + TeX-global-input-files-with-extension))) + (setq name + (file-name-nondirectory + (read-file-name + (TeX-argument-prompt t nil "File") + nil ""))))) + + ;; include/(before|after|end)/<file-name> where <file-name> + ;; is optional + ((member hook '("include/before" "include/end" "include/after")) + (if (funcall search) + (progn + (setq files + (prog2 + (message "Searching for files...") + ;; \include looks for files with TeX content, + ;; so limit the search: + (let* ((TeX-file-extensions '("tex" "ltx"))) + (TeX-search-files-by-type 'texinputs 'local t t)) + (message "Searching for files...done"))) + (setq name (completing-read + (TeX-argument-prompt t nil "File") + files))) + (setq name + (file-name-base + (read-file-name + (TeX-argument-prompt t nil "File") + nil ""))))) + + ;; class/(before|after)/<doc-class> where <doc-class> is + ;; optional + ((member hook '("class/before" "class/after")) + (if (funcall search) + (progn + (unless LaTeX-global-class-files + (setq LaTeX-global-class-files + (prog2 + (message "Searching for LaTeX classes...") + (let* ((TeX-file-extensions '("cls"))) + (mapcar #'list + (TeX-search-files-by-type 'texinputs + 'global + t t))) + (message "Searching for LaTeX classes...done")))) + (setq name (completing-read + (TeX-argument-prompt t nil "Document class") + LaTeX-global-class-files))) + (setq name + (file-name-base + (read-file-name + (TeX-argument-prompt t nil "File") + nil ""))))) + + ;; package/(before|after)/<pack-name> where + ;; <pack-name> is optional + ((member hook '("package/before" "package/after")) + (if (funcall search) + (progn + (unless LaTeX-global-package-files + (setq LaTeX-global-package-files + (prog2 + (message "Searching for LaTeX packages...") + (let* ((TeX-file-extensions '("sty"))) + (mapcar #'list + (TeX-search-files-by-type 'texinputs + 'global + t t))) + (message "Searching for LaTeX packages...done")))) + (setq name (completing-read + (TeX-argument-prompt t nil "Package") + LaTeX-global-package-files))) + (setq name (file-name-base + (read-file-name + (TeX-argument-prompt t nil "File") + nil ""))))) + + ;; User specific input for the hook, do nothing: + (t nil)) + ;; Process the input: For cmd or env, concat the elements with a + ;; slash. For other hooks, check if the optional name is given + ;; and append it with a backslash to the hook: + (if (member hook '("cmd" "env")) + (concat hook "/" name "/" where) + (concat hook (when (and name (not (string= name ""))) + (concat "/" name)))))) + +(defun TeX-arg-hook (optional) + "Prompt for a LaTeX hook. +Insert the given hook as a TeX macro argument. If OPTIONAL is +non-nil, insert it as an optional argument." + (TeX-argument-insert (TeX-read-hook) optional)) ;;; Verbatim constructs @@ -3814,7 +3990,7 @@ performed in that case." (if (re-search-forward (concat "\\(" ;; Code comments. - "[^ \r\n%\\]\\([ \t]\\|\\\\\\\\\\)*" + "\\([^ \r\n%\\]\\|\\\\%\\)\\([ \t]\\|\\\\\\\\\\)*" TeX-comment-start-regexp "\\|" ;; Lines ending with `\par'. @@ -3854,7 +4030,8 @@ performed in that case." ;; ELSE part follows - loop termination relies on a fact ;; that (LaTeX-fill-region-as-para-do) moves point past ;; the filled region - (LaTeX-fill-region-as-para-do from end-marker justify-flag))))))) + (LaTeX-fill-region-as-para-do from end-marker justify-flag))))) + (set-marker end-marker nil))) ;; The content of `LaTeX-fill-region-as-para-do' was copied from the ;; function `fill-region-as-paragraph' in `fill.el' (CVS Emacs, @@ -3914,7 +4091,10 @@ space does not end a sentence, so don't break a line there." (goto-char from-plus-indent)) (if (not (> to (point))) - nil ;; There is no paragraph, only whitespace: exit now. + ;; There is no paragraph, only whitespace: exit now. + (progn + (set-marker to nil) + nil) (or justify (setq justify (current-justification))) @@ -4039,10 +4219,12 @@ space does not end a sentence, so don't break a line there." (concat "^\\([ \t]*" TeX-comment-start-regexp "+\\)*" "[ \t]*") (line-beginning-position))) - (LaTeX-fill-newline))))) + (LaTeX-fill-newline))) + (set-marker end-marker nil))) ;; Leave point after final newline. (goto-char to) (unless (eobp) (forward-char 1)) + (set-marker to nil) ;; Return the fill-prefix we used fill-prefix))) @@ -4320,7 +4502,8 @@ depends on the value of `LaTeX-syntactic-comments'." (line-beginning-position 2) justify) (goto-char end-marker) - (beginning-of-line))) + (beginning-of-line) + (set-marker end-marker nil))) (LaTeX-fill-code-comment justify))) ;; Syntax-aware filling: ;; * `LaTeX-syntactic-comments' enabled: Everything. @@ -4462,6 +4645,7 @@ formatting." (concat "^\\($\\|[ \t]+$\\|[ \t]*" TeX-comment-start-regexp "+[ \t]*$\\)"))) (forward-line 1)))) + (set-marker next-par nil) (set-marker to nil))) (message "Formatting%s...done" (or what ""))) @@ -5469,8 +5653,14 @@ Each entry should be a list with up to four elements, KEY, VALUE, MENU and CHARACTER. KEY is the key (after `LaTeX-math-abbrev-prefix') to be redefined -in math minor mode. If KEY is nil, the symbol has no associated -keystroke \(it is available in the menu, though\). +in math minor mode. KEY can be a character (e.g. ?o) for a +single stroke or a string (e.g. \"o a\") for a multi-stroke +binding. If KEY is nil, the symbol has no associated +keystroke (it is available in the menu, though). Note that +predefined keys in `LaTeX-math-default' cannot be overridden in +this variable. Currently, only the lowercase letter 'o' is free +for user customization, more options are available in uppercase +area. VALUE can be a string with the name of the macro to be inserted, or a function to be called. The macro must be given without the @@ -5478,8 +5668,8 @@ leading backslash. The third element MENU is the name of the submenu where the command should be added. MENU can be either a string -\(e.g. \"greek\"\), a list (e.g. \(\"AMS\" \"Delimiters\"\)\) or -nil. If MENU is nil, no menu item will be created. +\(e.g. \"greek\"), a list (e.g. (\"AMS\" \"Delimiters\")) or nil. +If MENU is nil, no menu item will be created. The fourth element CHARACTER is a Unicode character position for menu display. When nil, no character is shown. @@ -7166,7 +7356,12 @@ function would return non-nil and `(match-string 1)' would return ;; `LaTeX-font-list' once it is needed more frequently. '("textssc" t) ;; User level reset macros: - '("normalfont" -1) '("normalshape" -1))) + '("normalfont" -1) '("normalshape" -1) + + ;; LaTeX hook macros: + '("AddToHook" TeX-arg-hook [ "Label" ] t) + '("RemoveFromHook" TeX-arg-hook [ "Label" ]) + '("AddToHookNext" TeX-arg-hook t))) (TeX-run-style-hooks "LATEX") diff --git a/preview.el b/preview.el index 3f708f2..0d5ec37 100644 --- a/preview.el +++ b/preview.el @@ -1509,6 +1509,8 @@ This is for matching screen font size and previews." :group 'preview-appearance :type '(repeat (choice + ;; FIXME: It seems that the bug mentioned below doesn't exist + ;; at least for emacs 27.2. ;; This is a bug: type function seems to match variables, too. (restricted-sexp :match-alternatives (functionp) :tag "Function" :value preview-auctex-font-size) @@ -1554,9 +1556,9 @@ display in use.") (defun preview-make-image (symbol) "Make an image from a preview spec list. The first spec that is workable (given the current setting of -`preview-min-spec') from the given symbol is used here. The -icon is cached in the property list of the symbol." - (let ((alist (get 'preview-min-alist symbol))) +`preview-min-spec') from the given SYMBOL is used here. The +icon is cached in the property list of the SYMBOL." + (let ((alist (get symbol 'preview-min-alist))) (cdr (or (assq preview-min-spec alist) (car (put symbol 'preview-min-alist @@ -2979,7 +2981,7 @@ With prefix argument REMOVE, remove it again." (setq pattern (regexp-quote preview-TeX-style-dir)) (dolist (env (cons "TEXINPUTS=" (copy-sequence process-environment))) (if (string-match "\\`\\(TEXINPUTS[^=]*\\)=" env) - (unless (string-match pattern env) + (unless (save-match-data (string-match pattern env)) (setenv (match-string 1 env) (concat preview-TeX-style-dir (substring env (match-end 0)))))))))) @@ -3066,7 +3068,8 @@ pp") (define-key LaTeX-mode-map [tool-bar preview] `(menu-item "Preview at point" preview-at-point :image ,preview-tb-icon - :help "Preview on/off at point"))) + :help "Preview on/off at point" + :vert-only t))) (when buffer-file-name (let* ((filename (expand-file-name buffer-file-name)) format-cons) diff --git a/style/dinbrief.el b/style/dinbrief.el index 57bf773..fe8a5e9 100644 --- a/style/dinbrief.el +++ b/style/dinbrief.el @@ -169,7 +169,8 @@ (marker-position addr-end) 'move) (progn (newline) - (indent-to addr-column)))))))) + (indent-to addr-column))))) + (set-marker addr-end nil)))) (LaTeX-dinbrief-insert "\n") (indent-to indentation)) (if (not (zerop (length postremark))) diff --git a/style/letter.el b/style/letter.el index a07aba5..5c64c28 100644 --- a/style/letter.el +++ b/style/letter.el @@ -146,7 +146,8 @@ (marker-position addr-end) 'move) (progn (newline) - (indent-to addr-column)))))))) + (indent-to addr-column))))) + (set-marker addr-end nil)))) (insert "\n") (indent-to indentation)) (insert TeX-esc "opening" diff --git a/style/ulem.el b/style/ulem.el index 70ea7a8..f84fcc6 100644 --- a/style/ulem.el +++ b/style/ulem.el @@ -24,7 +24,7 @@ ;;; Commentary: -;; This file adds support for `ulem.sty'. +;; This file adds support for `ulem.sty' dated 2019-11-18. ;;; Code: @@ -44,38 +44,48 @@ '("uwave" 1) '("sout" 1) '("xout" 1) - ;; can be used with \renewcommand or \setlength + '("dashuline" 1) + '("dotuline" 1) + ;; can be used with \renewcommand "ULthickness" - "ULdepth" ;; custom commands can be defined with these commands; see the ;; documentation for an example "ULon" - "markoverwith" + ;; \markoverwith takes on argument + '("markoverwith" 1) ;; \useunder {underline_command}{font_declaration}{font_command} ;; replaces occurences of font_declaration and font_command with the ;; underline_command '("useunder" TeX-arg-ulem-useunder TeX-arg-ulem-fontdecl TeX-arg-ulem-fontcmd)) + ;; \ULdepth can be changed with \setlength + (LaTeX-add-lengths "ULdepth") + ;; Fontification (when (and (featurep 'font-latex) (eq TeX-install-font-lock 'font-latex-setup)) ;; Tell font-lock about the update. - (font-latex-add-keywords '(("useunder" "{{{")) 'function) + (font-latex-add-keywords '(("useunder" "{{{")) + 'function) (font-latex-add-keywords '(("uline" "{") + ("uuline" "{") ("uwave" "{") ("sout" "{") - ("xout" "{")) 'textual))) + ("xout" "{") + ("dashuline" "{") + ("dotuline" "{")) + 'textual))) TeX-dialect) -(defvar LaTeX-arg-fontdecl +(defvar LaTeX-ulem-fontdecl (mapcar (lambda (str) (concat "\\" str)) '("itshape" "bfseries" "scshape" "ttfamily" "upshape" "mdseries" "rmfamily" "sffamily" "slshape")) - "List of font declaration commands in LaTeX") + "List of font declaration commands in LaTeX.") -(defvar LaTeX-arg-fontcmd +(defvar LaTeX-ulem-fontcmd (mapcar (lambda (str) (concat "\\" str)) '("textit" "textbf" "textsc" "texttt" "textup" "textmd" @@ -83,28 +93,30 @@ "List of font commands in LaTeX") (defun TeX-arg-ulem-fontdecl (optional &optional prompt) - "Prompt for the font-declaration un \\useunder" + "Prompt for the font-declaration un \\useunder." (TeX-argument-insert (completing-read (TeX-argument-prompt optional prompt "Font declaration") - LaTeX-arg-fontdecl nil t) optional)) + LaTeX-ulem-fontdecl nil t) + optional)) (defun TeX-arg-ulem-fontcmd (optional &optional prompt) - "Prompt for the font-declaration un \\useunder" + "Prompt for the font-declaration un \\useunder." (TeX-argument-insert (completing-read (TeX-argument-prompt optional prompt "Font command") - LaTeX-arg-fontcmd nil t) optional)) + LaTeX-ulem-fontcmd nil t) + optional)) -;; adapted from url.el:TeX-arg-urlstyle +;; adapted from url.el: TeX-arg-urlstyle (defun TeX-arg-ulem-useunder (optional &optional prompt) - "Prompt for underline command used in \\useunder" + "Prompt for underline command used in \\useunder." (TeX-argument-insert (completing-read (TeX-argument-prompt optional prompt "Underline command") - (mapcar #'list - (mapcar (lambda (str) (concat "\\" str)) - '("uline" "uuline" - "uwave" "sout" "xout"))) + (mapcar (lambda (str) (concat "\\" str)) + '("uline" "uuline" + "uwave" "sout" "xout" + "dashuline" "dotuline")) nil t) optional)) diff --git a/tex-buf.el b/tex-buf.el index 0f3bf18..ce54251 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -84,7 +84,7 @@ Return non-nil if document needs to be re-TeX'ed." If NAME-OR-FILE-FN is a string, interpret it as the filename. Otherwise, assume it is a callable function and call it with EXTENSION as an argument and return the result without -modification. EXTENSION is a string which should not start with +modification. EXTENSION is a string which should not start with '.'." (if (stringp name-or-file-fn) (if extension @@ -291,7 +291,6 @@ at bottom if LINE is nil." (defvar TeX-current-page) (defvar TeX-error-overview-open-after-TeX-run) (defvar TeX-error-list) -(defvar TeX-parse-all-errors) (defvar TeX-command-buffer) (defvar TeX-region) @@ -490,7 +489,7 @@ Do you want to select one of these engines? " FILE-FN is the symbol of a function returning a file name. The function has one optional argument, the extension to use on the -file. Valid choices are `TeX-master-file' and `TeX-region-file' +file. Valid choices are `TeX-master-file' and `TeX-region-file'. Use the information in `TeX-command-list' to determine how to run the command. @@ -603,9 +602,10 @@ the following three conditions are met: 2. \" \\input\" is supplemented 3. EXTRA is non-nil (default when expanding \"%T\") Adjust dynamically bound variable `TeX-expand-pos' to avoid possible -infinite loop in `TeX-command-expand'. If PREPROCESS-FN is non-nil then -it is called with the filename as an argument and the results is -enclosed instead of the filename. +infinite loop in `TeX-command-expand'. +If PREPROCESS-FN is non-nil then it is called with the filename +as an argument and the result is enclosed instead of the +filename. Helper function of `TeX-command-expand'. Use only within entries in `TeX-expand-list-builtin' and `TeX-expand-list'." @@ -2530,14 +2530,6 @@ This variable is intended to be set only in output buffer so it will be shared among all files of the same document.") (make-variable-buffer-local 'TeX-error-list) -(defcustom TeX-parse-all-errors t - "Whether to automatically collect all warning and errors after running TeX. - -If t, it makes it possible to use `TeX-previous-error' with TeX -commands." - :group 'TeX-command - :type 'boolean) - (defun TeX-parse-all-errors () "Parse TeX output buffer to collect all warnings and errors." ;; Reset error list. diff --git a/tex-fold.el b/tex-fold.el index 9eab077..d5b98d1 100644 --- a/tex-fold.el +++ b/tex-fold.el @@ -73,7 +73,7 @@ macros, 'math for math macros and 'comment for comments." '(("[f]" ("footnote" "marginpar")) ("[c]" ("cite")) ("[l]" ("label")) - ("[r]" ("ref" "pageref" "eqref")) + ("[r]" ("ref" "pageref" "eqref" "footref")) ("[i]" ("index" "glossary")) ("[1]:||*" ("item")) ("..." ("dots")) @@ -807,6 +807,12 @@ That means, put respective properties onto overlay OV." (skip-chars-forward " \t") (point)))) (overlay-put ov 'mouse-face 'highlight) + (when font-lock-mode + ;; Add raise adjustment for superscript and subscript. + ;; (bug#42209) + (setq display-string + (propertize display-string + 'display (get-text-property ov-start 'display)))) (overlay-put ov 'display display-string) (when font-lock-mode (overlay-put ov 'face TeX-fold-folded-face)) @@ -902,7 +908,11 @@ With zero or negative ARG turn mode off." :keymap (list (cons TeX-fold-command-prefix TeX-fold-keymap)) (if TeX-fold-mode (progn - (set (make-local-variable 'search-invisible) t) + ;; The value t causes problem when body text is hidden in + ;; outline-minor-mode. (bug#36651) + ;; In addition, it's better not to override user preference + ;; without good reason. + ;; (set (make-local-variable 'search-invisible) t) (add-hook 'post-command-hook #'TeX-fold-post-command nil t) (add-hook 'LaTeX-fill-newline-hook #'TeX-fold-update-at-point nil t) (add-hook 'TeX-after-insert-macro-hook @@ -924,7 +934,7 @@ With zero or negative ARG turn mode off." (TeX-mode-prefix) elt)))) (when (boundp symbol) (symbol-value symbol))))))) - (kill-local-variable 'search-invisible) + ;; (kill-local-variable 'search-invisible) (remove-hook 'post-command-hook #'TeX-fold-post-command t) (remove-hook 'LaTeX-fill-newline-hook #'TeX-fold-update-at-point t) (TeX-fold-clearout-buffer)) diff --git a/tex-info.el b/tex-info.el index ea6cab0..ef1e439 100644 --- a/tex-info.el +++ b/tex-info.el @@ -478,8 +478,10 @@ is assumed by default." (if (nth 1 reftex-label-menu-flags) ; section number flag (concat section-number " ")) text)) - (list 'toc "toc" text file marker level section-number - literal (marker-position marker)))) + (prog1 + (list 'toc "toc" text file marker level section-number + literal (marker-position marker)) + (set-marker marker nil)))) (defun Texinfo-reftex-hook () "Hook function to plug Texinfo into RefTeX." @@ -865,7 +867,8 @@ value of `Texinfo-mode-hook'." (run-mode-hooks 'text-mode-hook 'Texinfo-mode-hook) (TeX-set-mode-name)) -(defcustom Texinfo-clean-intermediate-suffixes nil +(defcustom Texinfo-clean-intermediate-suffixes + '("\\.cps?" "\\.vrs?" "\\.fns?" "\\.tps?" "\\.pgs?" "\\.kys?") "List of regexps matching suffixes of files to be deleted. The regexps will be anchored at the end of the file name to be matched, i.e. you do _not_ have to cater for this yourself by adding \\\\' or $." diff --git a/tex.el b/tex.el index d964940..46d6bbc 100644 --- a/tex.el +++ b/tex.el @@ -199,9 +199,20 @@ If nil, none is specified." (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode context-mode) :help "Run BibTeX") - ("Biber" "biber %s %(output-dir)" TeX-run-Biber nil + ("Biber" "biber %(output-dir) %s" TeX-run-Biber nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run Biber") + ;; Not part of standard TeX. + ;; It seems that texindex doesn't support "--output-dir" option. + ("Texindex" "texindex %s.??" TeX-run-command nil + (texinfo-mode) :help "Run Texindex") + ;; TODO: + ;; 1. Supply "--dvipdf" option if `TeX-PDF-mode' and + ;; `TeX-PDF-from-DVI' are non-nil. + ;; 2. Supply "--build-dir=DIR" option when `TeX-output-dir' is + ;; non-nil. + ("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil + (texinfo-mode) :help "Run Texi2dvi or Texi2pdf") ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer") ("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" @@ -212,13 +223,13 @@ If nil, none is specified." ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert DVI file to PostScript") - ("Dvipdfmx" "dvipdfmx %d -o %(O?pdf)" TeX-run-dvipdfmx nil + ("Dvipdfmx" "dvipdfmx -o %(O?pdf) %d" TeX-run-dvipdfmx nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert DVI file to PDF with dvipdfmx") ("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert PostScript file to PDF") - ("Glossaries" "makeglossaries %(O?aux)" TeX-run-command nil + ("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run makeglossaries to create glossary file") ("Index" "makeindex %(O?idx)" TeX-run-index nil @@ -557,6 +568,7 @@ string." ("%(extraopts)" (lambda () TeX-command-extra-options)) ("%(output-dir)" TeX--output-dir-arg "--output-directory=") ("%(o-dir)" TeX--output-dir-arg "-o ") + ("%(d-dir)" TeX--output-dir-arg "-d ") ("%S" TeX-source-correlate-expand-options) ("%dS" TeX-source-specials-view-expand-options) ("%cS" TeX-source-specials-view-expand-client) @@ -713,6 +725,19 @@ sure \"%p\" is the first entry." (autoload 'TeX-save-document "tex-buf" nil t) (autoload 'TeX-view "tex-buf" nil t) +;; This variable used to be defined in tex-buf.el. It is used in +;; `TeX-mode-specific-command-menu-entries' in this file. It is now +;; (June 2021) moved into this file to avoid `void-variable' errors +;; with the "Command" menu if tex-buf.el is not loaded yet for reasons +;; mentioned above. +(defcustom TeX-parse-all-errors t + "Whether to automatically collect all warning and errors after running TeX. + +If t, it makes it possible to use `TeX-previous-error' with TeX +commands." + :group 'TeX-command + :type 'boolean) + ;;; Portability. (defmacro TeX--if-macro-fboundp (name then &rest else) @@ -2268,8 +2293,8 @@ change the file. If the variable is 'dwim, AUCTeX will try to avoid querying by attempting to `do what I mean'; and then change the file. -It is suggested that you use the File Variables (see the info node in -the Emacs manual) to set this variable permanently for each file." +It is suggested that you use the File Variables (see the info node +`File Variables') to set this variable permanently for each file." :group 'TeX-command :group 'TeX-parse :type '(choice (const :tag "Query" nil) @@ -2511,22 +2536,23 @@ be relative to that." "The path of the directory where output files should be placed. A relative path is interpreted as being relative to the master -file in `TeX-master'. The path cannot contain a directory that -starts with '.'. If this variable is nil, the output directory is -assumed to be the same as the directory of `TeX-master'." +file in `TeX-master'. The path cannot contain a directory that +starts with '.'. If this variable is nil, the output directory +is assumed to be the same as the directory of `TeX-master'." :group 'TeX-file :safe #'string-or-null-p :type '(choice (const :tag "Directory of master file" nil) (string :tag "Custom" "build"))) (make-variable-buffer-local 'TeX-output-dir) -(defun TeX--master-output-dir (master-dir relative-to-master) +(defun TeX--master-output-dir (master-dir relative-to-master &optional ensure) "Return the directory path where output files should be placed. If `TeX-output-dir' is nil, then return nil. MASTER-DIR is the directory path where the master file is -located. If RELATIVE-TO-MASTER is non-nil, make the returned path -relative to the directory in MASTER-DIR." +located. If RELATIVE-TO-MASTER is non-nil, make the returned +path relative to the directory in MASTER-DIR. If ENSURE is +non-nil, the output directory is created if it does not exist." (when TeX-output-dir (let* ((master-dir (expand-file-name (or master-dir ""))) (out-dir (file-name-as-directory @@ -2536,7 +2562,7 @@ relative to the directory in MASTER-DIR." TeX-output-dir master-dir)))))) ;; Make sure the directory exists - (unless (file-exists-p out-dir) + (unless (or (not ensure) (file-exists-p out-dir)) (make-directory (file-name-as-directory out-dir) t)) (if relative-to-master (file-relative-name out-dir master-dir) @@ -2544,9 +2570,9 @@ relative to the directory in MASTER-DIR." (defun TeX--output-dir-arg (argname) "Format the output directory as a command argument. -ARGNAME is prepended to the quoted output directory. If +ARGNAME is prepended to the quoted output directory. If `TeX-output-dir' is nil then return an empty string." - (let ((out-dir (TeX--master-output-dir (TeX-master-directory) t))) + (let ((out-dir (TeX--master-output-dir (TeX-master-directory) t t))) (if out-dir (concat argname "\"" out-dir "\"") ""))) @@ -3488,7 +3514,8 @@ See `TeX-parse-macro' for details." (insert TeX-arg-opening-brace) (goto-char (marker-position end)) (insert TeX-arg-closing-brace) - (setq insert-flag t)))) + (setq insert-flag t) + (set-marker end nil)))) ((= arg 0)) ; nop for clarity ((> arg 0) (TeX-parse-argument optional t) @@ -4143,14 +4170,15 @@ If SKIP is not-nil, don't insert code for SKIP." "List of symbols to ignore when scanning a TeX style file.") (defcustom TeX-auto-regexp-list 'TeX-auto-full-regexp-list - "List of regular expressions used for parsing the current file." + "List of regular expressions used for parsing the current file. +It can also be a name of a variable having such value." :type '(radio (variable-item TeX-auto-empty-regexp-list) (variable-item TeX-auto-full-regexp-list) (variable-item plain-TeX-auto-regexp-list) (variable-item LaTeX-auto-minimal-regexp-list) (variable-item LaTeX-auto-label-regexp-list) (variable-item LaTeX-auto-regexp-list) - (symbol :tag "Other") + (variable :tag "Other") (repeat :tag "Specify" (group (regexp :tag "Match") (sexp :tag "Groups") @@ -4221,6 +4249,7 @@ Use `TeX-auto-x-regexp-list' for parsing the region between (defcustom TeX-auto-x-regexp-list 'LaTeX-auto-label-regexp-list "List of regular expressions used for additional parsing. +It can also be a name of a variable having such value. See `TeX-auto-x-parse-length'." :type '(radio (variable-item TeX-auto-empty-regexp-list) (variable-item TeX-auto-full-regexp-list) @@ -4228,7 +4257,7 @@ See `TeX-auto-x-parse-length'." (variable-item LaTeX-auto-minimal-regexp-list) (variable-item LaTeX-auto-label-regexp-list) (variable-item LaTeX-auto-regexp-list) - (symbol :tag "Other") + (variable :tag "Other") (repeat :tag "Specify" (group (regexp :tag "Match") (sexp :tag "Groups") diff --git a/texmathp.el b/texmathp.el index ac2b75c..b0fd02d 100644 --- a/texmathp.el +++ b/texmathp.el @@ -274,7 +274,10 @@ See the variable `texmathp-tex-commands' about which commands are checked." (interactive) (let* ((pos (point)) math-on sw-match (bound (save-excursion - (if (re-search-backward "[\n\r][ \t]*[\n\r]" + (if (re-search-backward + (if (eq major-mode 'doctex-mode) + "[\n\r]%*[ \t]*[\n\r]" + "[\n\r][ \t]*[\n\r]") nil 1 texmathp-search-n-paragraphs) (match-beginning 0) (point-min)))) diff --git a/toolbar-x.el b/toolbar-x.el index d95ca59..8f07bea 100644 --- a/toolbar-x.el +++ b/toolbar-x.el @@ -1116,19 +1116,22 @@ function `toolbar-install-toolbar'." (cadr (memq :visible filtered-props)))) (button (cons (memq :button filtered-props) (cadr (memq :button filtered-props)))) - (menuitem (append - (list 'menu-item - (toolbarx-make-string-from-symbol symbol) - command - :image image-descriptor) - (when (car help) - (list :help (cdr help))) - (when (car enable) - (list :enable (cdr enable))) - (when (car visible) - (list :visible (cdr visible))) - (when (car button) - (list :button (cdr button))))) + (menuitem (if (eq symbol 'separator) + '(menu-item "--") + (append + (list 'menu-item + (toolbarx-make-string-from-symbol symbol) + command + :image image-descriptor) + (when (car help) + (list :help (cdr help))) + (when (car enable) + (list :enable (cdr enable))) + (when (car visible) + (list :visible (cdr visible))) + (when (car button) + (list :button (cdr button))) + '(:vert-only t)))) (key-not-used (let* ((count 0) (symb symbol))