branch: main commit d1047f36c403e66af4a50159505ba7828f6e94b5 Merge: 74232674 3750d1a6 Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge remote-tracking branch 'origin/master' into externals/auctex --- bib-cite.el | 125 +++++----------------------- doc/changes.texi | 12 ++- doc/preview-faq.texi | 2 +- doc/tex-ref.tex | 36 ++++---- font-latex.el | 9 +- latex.el | 20 ++--- multi-prompt.el | 4 +- preview.el | 48 +++++++---- style/babel.el | 4 +- style/biblatex.el | 4 +- style/bigdelim.el | 6 +- style/hologo.el | 6 +- style/newfloat.el | 4 +- style/ntheorem.el | 2 +- style/wrapfig.el | 2 +- tests/japanese/preview-latex.el | 144 +++++++++++++++++--------------- tests/latex/font-latex-test.el | 180 ++++++++++++++++++++++++++++++++++++++++ tests/make-test-deps.emacs-lisp | 4 +- tests/tex/path-expansion.el | 7 +- tex-bar.el | 8 +- tex-buf.el | 4 +- tex-fold.el | 4 +- tex.el | 94 ++++++--------------- toolbar-x.el | 30 +++---- 24 files changed, 425 insertions(+), 334 deletions(-) diff --git a/bib-cite.el b/bib-cite.el index b21bdcbb..99b92784 100644 --- a/bib-cite.el +++ b/bib-cite.el @@ -1,5 +1,4 @@ -;;; bib-cite.el --- test -*- lexical-binding: t; -*- -;; bib-cite.el - Display \cite, \ref or \label / Extract refs from BiBTeX file. +;; bib-cite.el - Display \cite, \ref or \label / Extract refs from BiBTeX file. -*- lexical-binding: t; -*- ;; Copyright (C) 1994-1999, 2001, 2003-2005, 2014-2021 Free Software Foundation, Inc. @@ -594,10 +593,6 @@ (require 'cl-lib)) ;; Silence the compiler: -(declare-function dired-replace-in-string "ext:dired" - (regexp newtext string)) -(declare-function dired-split "ext:dired-aux" - (pat str &optional limit)) (declare-function reftex-view-crossref "ext:reftex-dcr" (&optional arg auto-how fail-quietly)) @@ -628,12 +623,6 @@ You may use `switch-to-buffer' `switch-to-buffer-other-window' or "Call bib-highlight-mouse from `LaTeX-mode-hook' to add green highlight." :type 'boolean) -(defcustom bib-label-help-echo-format "button2 finds %s, button3 displays %s" - "Format string for info if the mouse is over LaTeX commands. -If nil, do not display info." - :type '(radio (const :tag "Don't display info" nil) - string)) - (defcustom bib-bibtex-env-variable "BIBINPUTS" "Environment variable setting the path where BiBTeX input files are found. BiBTeX 0.99b manual says this should be TEXBIB. @@ -673,7 +662,7 @@ setting the elisp variable bib-bibtex-env-variable)" (defcustom bib-etags-command "etags -r '/.*\\\\\\(eq\\|page\\|[fvF]\\)ref.*/' -o " "Variable for the etags command and its output option. -In unix, this is usually \"etags -r '/.*\\\(eq\|page\|[fvF]\)ref.*/' -o \" +In unix, this is usually \"etags -r '/.*\\\\\\(eq\\|page\\|[fvF]\\)ref.*/' -o \" \(we use the -r option to tell etags to list AMS-LaTeX's \\eqref command.) In DOS and OS/2, this *may* be different, e.g. using slashes like \"etags /o=\" If so, set it this variable." @@ -681,7 +670,7 @@ If so, set it this variable." (defcustom bib-etags-append-command "etags -r '/.*\\\\\\(eq\\|page\\|[fvF]\\)ref.*/' -a -o " "Variable for the etags command and its append and output option. -In unix, this is usually \"etags -r '/.*\\\(eq\|page\|[fvF]\)ref.*/' -a -o \" +In unix, this is usually \"etags -r '/.*\\\\\\(eq\\|page\\|[fvF]\\)ref.*/' -a -o \" In DOS and OS/2, this *may* be \"etags /a /o=\" If so, set it this variable." :type 'string) @@ -725,11 +714,6 @@ A opening curly bracket is appended to the regexp.") (defvar bib-highlight-mouse-keymap (make-sparse-keymap) "Keymap for mouse bindings in highlighted texts in bicite.") -(defvar bib-ext-list nil - "Xemacs buffer-local list of bib-cite extents.") -(make-variable-buffer-local 'bib-ext-list) -(put 'bib-ext-list 'permanent-local t) - (defvar bib-cite-minor-mode-menu nil) ;;;###autoload @@ -884,7 +868,7 @@ runs `bib-find', and [mouse-3] runs `bib-display'." If text under cursor is a \\cite command, then display its BibTeX info from \\bibliography input file. Example with cursor located over cite command or arguments: - \cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94} + \\cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94} ^Display-all-citations ^Display-this-citation If text under cursor is a \\ref command, then display environment associated @@ -917,7 +901,7 @@ A TAGS file is created and used for multi-file documents under auctex." For multi-entry cite commands, the cursor should be on the actual cite key desired (otherwise a random entry will be selected). -e.g.: \cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94} +e.g.: \\cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94} ^Display-this-citation If text under cursor is a \\ref command, then point is moved to its matching @@ -948,7 +932,7 @@ A TAGS file is created and used for multi-file documents under auctex." "Bib-cite intenal variable to hold last \\ref or \\eqref find.") (defun bib-find-next (&optional prev-p) - "Find next occurrence of a \ref or \eqref. + "Find next occurrence of a \\ref or \\eqref. This is made necessary because we now use a regexp to find tags in multi-file documents, and the Emacs command `find-tag' doesn't allow to interactively find the next occurrence of a regexp." @@ -1033,7 +1017,7 @@ by using bib-apropos sequentially." "Bib-cite internal variable.") (defun bib-make-bibliography () - "Extract citations used in the current document from \bibliography{} file(s). + "Extract citations used in the current document from \\bibliography{} file(s). Put them into a buffer named after the current buffer, with extension .bib. In an AUCTeX multi-file document, parsing must be on and the citation keys @@ -1220,12 +1204,11 @@ See variables bib-etags-command and bib-etags-filename" ;; *all of code was here* ;; ) (save-excursion - (let ((s)(e);; (extent) (local-extent-list bib-ext-list) + (let ((s)(e) (inhibit-read-only t) (modified (buffer-modified-p))) ;put-text-property changing this? ;; * peta Wed Nov 8 16:27:29 1995 -- better remove the mouse face ;; properties first. - (setq bib-ext-list nil) ;Reconstructed below... ;; Remove properties for regular emacs ;; FIXME This detroys all mouse-faces and local-maps! ;; FIXME Hope no other package is using them in this buffer! @@ -1269,32 +1252,13 @@ See variables bib-etags-command and bib-etags-filename" '(mouse-face local-map))) (set-buffer-modified-p modified)))) -(defun bib-label-help-echo (object) - (if bib-label-help-echo-format - (bib-label-help object bib-label-help-echo-format))) - -;; Balloon-help callback. Anders Stenman <sten...@isy.liu.se> -;; Patched by Bruce Ravel <bruce.ra...@nist.gov> -(defun bib-label-help (object &optional format) - (or format (setq format "Use mouse button 2 to find the %s. -Use mouse button 3 to display the %s.")) - (save-match-data - (let* ((string (extent-string object)) - (type (cond ((string-match "^\\\\[A-Za-z]*cite[A-Za-z]*" string) "citation") - ((string-match - (concat "^" bib-ref-regexp) string) - "\\label{}") - ((string-match "^\\\\label" string) "\\ref{}") - (t "this (unknown) reference")))) - (format format type type)))) - ;;---------------------------------------------------------------------------- ;; Routines to display or edit a citation's bibliography (defun bib-display-citation () "Do the displaying of cite info. Return t if found cite key, nil otherwise. Example with cursor located over cite command or arguments: -\cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94} +\\cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94} ^Display-all-citations ^Display-this-citation" (save-excursion (let* ((the-keys-obarray (bib-get-citekeys-obarray)) ;1st in case of error @@ -1325,10 +1289,10 @@ Example with cursor located over cite command or arguments: (defun bib-edit-citation () "Do the edit of cite info. Return t if found cite key, nil otherwise. Find and and put edit point in bib file associated with a BibTeX citation -under cursor from \bibliography input file. +under cursor from \\bibliography input file. In a multi-entry cite command, the cursor should be on the actual cite key desired (otherwise a random entry will be selected). -e.g.: \cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94} +e.g.: \\cite{Wadhams81,Bourke.et.al87,SchneiderBudeus94} ^Display-this-citation" (let ((the-keys-obarray (bib-get-citekeys-obarray)) ;1st in case of error (bib-buffer (bib-get-bibliography t)) @@ -1465,7 +1429,11 @@ If within a multi-file document (in auctex only) (if (bib-Is-hidden) (save-excursion (beginning-of-line) - (show-entry))))) + ;; COMPATIBILITY for emacs<25. + (if (fboundp 'outline-show-entry) + (outline-show-entry) + (with-no-warnings + (show-entry))))))) (defvar bib-label-prompt-map (let ((map (make-sparse-keymap))) @@ -1792,8 +1760,8 @@ Return the-warnings as text." (let* ((the-key (car (car string-alist))) (the-string (cdr (car string-alist))) (slashed-string ; "J. of Geo.\" -> "J. of Geo.\\\\" - (dired-replace-in-string - "\\\\" "\\\\" the-string))) + (replace-regexp-in-string + "\\\\" "\\\\" the-string t t))) (while (re-search-forward (concat "\\(^[, \t]*[a-zA-Z]+[ \t]*=[ \t]*\\)" @@ -2127,9 +2095,9 @@ Makes sure TAGS file exists, etc." If using AUCTeX, and either TeX-parse-self is set or C-c C-n is used to parse the document, then the entire multifile document will be searched -for \bibliography commands. +for \\bibliography commands. -If this fails, the current buffer is searched for the first \bibliography +If this fails, the current buffer is searched for the first \\bibliography command. If include-filenames-f is true, include as a special header the filename @@ -2341,50 +2309,6 @@ If FIRST-FILE is t, stop after first file is found." ;; (setq the-list (cdr the-list)))) ;; filespec)) -(or (fboundp 'dired-replace-in-string) - ;; This code is part of GNU emacs - (defun dired-replace-in-string (regexp newtext string) - ;; Replace REGEXP with NEWTEXT everywhere in STRING and return result. - ;; NEWTEXT is taken literally---no \\DIGIT escapes will be recognized. - (let ((result "") (start 0) mb me) - (while (string-match regexp string start) - (setq mb (match-beginning 0) - me (match-end 0) - result (concat result (substring string start mb) newtext) - start me)) - (concat result (substring string start))))) - - -;; Could use fset here to equal TeX-split-string to dired-split if only -;; dired-split is defined. That would eliminate a check in psg-list-env. -(and (not (fboundp 'TeX-split-string)) - (not (fboundp 'dired-split)) - ;; This code is part of AUCTeX - (defun TeX-split-string (char string) - "Returns a list of strings. given REGEXP the STRING is split into -sections which in string was seperated by REGEXP. - -Examples: - - (TeX-split-string \"\:\" \"abc:def:ghi\") - -> (\"abc\" \"def\" \"ghi\") - - (TeX-split-string \" *\" \"dvips -Plw -p3 -c4 testfile.dvi\") - - -> (\"dvips\" \"-Plw\" \"-p3\" \"-c4\" \"testfile.dvi\") - -If CHAR is nil, or \"\", an error will occur." - - (let ((regexp char) - (start 0) - (result '())) - (while (string-match regexp string start) - (let ((match (string-match regexp string start))) - (setq result (cons (substring string start match) result)) - (setq start (match-end 0)))) - (setq result (cons (substring string start nil) result)) - (nreverse result)))) - (defun bib-cite-file-directory-p (file) "Like default `file-directory-p' but allow FILE to end in // for ms-windows." (save-match-data @@ -2401,15 +2325,12 @@ bib-dos-or-os2-variable affects: path separator used (: or ;) whether backslashes are converted to slashes" (if (not (getenv env)) - nil ;Because dired-replace-in-string fails + nil ;Because replace-regexp-in-string fails (let* ((value (if bib-dos-or-os2-variable - (dired-replace-in-string "\\\\" "/" (getenv env)) + (replace-regexp-in-string "\\\\" "/" (getenv env) t t) (getenv env))) (sep-char (or (and bib-dos-or-os2-variable ";") ":")) - (entries (and value - (or (and (fboundp 'TeX-split-string) - (TeX-split-string sep-char value)) - (dired-split sep-char value))))) + (entries (split-string value sep-char))) (cl-loop for x in entries if (bib-cite-file-directory-p x) collect x)))) (provide 'bib-cite) diff --git a/doc/changes.texi b/doc/changes.texi index 39cd7133..109c4da1 100644 --- a/doc/changes.texi +++ b/doc/changes.texi @@ -11,6 +11,12 @@ @heading News in 13.0 @itemize @bullet +@item +Two functions @code{TeX-split-string} and @code{TeX-assoc} are now +obsolete and will be removed in future release. If your personal code +uses these functions, use @code{split-string} and @code{assoc-string} +instead. + @item Since @AUCTeX{} 12.2, @kbd{C-x C-w} accidentally disabled the parse on save in that buffer, even when you enabled @code{TeX-auto-save} option. @@ -20,9 +26,9 @@ This bug was fixed. @AUCTeX{} now requires GNU Emacs 24.3 or higher. @item -Old implementations for viewers were discarded, as stated long before. -The variables @code{TeX-output-view-style} and @code{TeX-view-style} -have no effect now. The former placeholders @samp{%v} and @samp{%vv} in +Old implementations for viewers were discarded, as announced long before. +The variables @code{TeX-output-view-style} and @code{TeX-view-style} have +no effect now. The former placeholders @samp{%v} and @samp{%vv} in @code{TeX-command-list} are ignored. @item diff --git a/doc/preview-faq.texi b/doc/preview-faq.texi index 8c77e282..feb19792 100644 --- a/doc/preview-faq.texi +++ b/doc/preview-faq.texi @@ -84,7 +84,7 @@ Carbon, and @previewlatex{} is working with them, too. With Windows, both native Emacs and Cygwin Emacs should work. However, it is known that @url{https://miktex.org/,MiK@TeX{}} sometimes doesn't work with @previewlatex{}. In that case, use -@url{https://tug.org/texlive/,@TeX{}live} instead. +@url{https://tug.org/texlive/,@TeX{} Live} instead. @node Installation Trouble, Customization, Requirements, Frequently Asked Questions @section Installation Trouble diff --git a/doc/tex-ref.tex b/doc/tex-ref.tex index c16f3121..026f64d9 100644 --- a/doc/tex-ref.tex +++ b/doc/tex-ref.tex @@ -194,6 +194,8 @@ are preserved on all copies. \def\<#1>{$\langle${\rm #1}$\rangle$} \def\kbd#1{{\tt#1}\null} %\null so not an abbrev even if period follows +\def\var#1{{\tt #1}} +\def\file#1{{\tt #1}} \def\beginexample{\par\leavevmode\begingroup \obeylines\obeyspaces\parskip0pt\tt} @@ -341,10 +343,10 @@ indicated in the mode line. \section{Variables} All math mode commands are under the prefix key specified by -LaTeX-math-abbrev-prefix, default is "`". +\var{LaTeX-math-abbrev-prefix}, default is ``\kbd{`}''. You can define your own math mode commands by setting the variable -LaTeX-math-list before loading LaTeX-math-mode. +\var{LaTeX-math-list} before enabling \var{LaTeX-math-mode}. \section{Greek Letters} @@ -450,7 +452,7 @@ LaTeX-math-list before loading LaTeX-math-mode. \previewlatex\ is part of AUC\TeX. If it is active, you should see an entry ``Preview'' in the menu bar when editing \LaTeX{} files. If you have a ``LaTeX'', but no ``Preview'' menu, add the following to your -{\tt .emacs} file: +init file (usually \file{\string~/.emacs.d/init.el}): \beginexample (load "preview-latex.el" nil t t) \endexample @@ -479,29 +481,29 @@ area up to the next preview. \key{Copy region as MML}{C-c C-p C-w} The last keysequence will copy a region with previews into the kill -buffer in a form fit for sending in Emacs' message-mode. +ring in a form fit for sending in Emacs' {\tt message-mode}. \section{Customization within Emacs} You can use \kbd{M-x customize-variable RET} or the ``Preview\slash Customize'' menu for customization. Worthwhile settings: -\halign to \hsize{\tabskip=1ptplus1fil\relax#\hfil&\hfil\kbd{#}\tabskip0pt\cr +\halign to \hsize{\tabskip=1ptplus1fil\relax#\hfil&\hfil\var{#}\tabskip0pt\cr \noalign{\medskip If you have dvipng available:} Set to \kbd{dvipng}&preview-image-type\cr \noalign{\medskip \vbox{Keep counter values when regenerating single previews:}} Set to \kbd{t}&preview-preserve-counters\cr \noalign{\medskip \vbox{Cache/Don't cache preamble without query -(preamble caching is done using {\tt mylatex.ltx} and might not always +(preamble caching is done using \file{mylatex.ltx} and might not always work. Use the appropriate key sequences for overriding the following setting):}} Set to \kbd{t}/\kbd{nil}&preview-auto-cache-preamble\cr} \section{Customization from \LaTeX{}} -Customization is done in the document preamble (you need to load {\tt -preview.sty} explicitly) or in {\tt prauctex.cfg} (which should load -the system {prauctex.cfg} first). Commands: +Customization is done in the document preamble (you need to load +\file{preview.sty} explicitly) or in \file{prauctex.cfg} (which should +load the system \file{prauctex.cfg} first). Commands: \halign to \hsize{\tabskip=1ptplus1fil\relax#\hfil&\hfil\kbd{#}\tabskip0pt\cr Preview macro&\string\PreviewMacro[\{\<args>\}]\{\<macro>\}\cr @@ -523,7 +525,7 @@ Skip next token&-\cr Transformation&\#\{\<macro args>\}\{\<replacement>\}\cr } -More options and explanations can be found in {\tt preview.dvi} or the +More options and explanations can be found in \file{preview.pdf} or the Texinfo manual. \vskip 5ex plus 6ex minus 1ex @@ -549,8 +551,8 @@ Texinfo manual. AUC\TeX\ supports outline mode by defining section, subsection, etc. as heading levels. You can use \kbd{M-x outline-minor-mode RET} to toggle outline minor mode. All outline minor mode commands are -under the prefix key specified by outline-minor-mode-prefix, default -is ``C-c @''. +under the prefix key specified by \var{outline-minor-mode-prefix}, default +is \kbd{C-c @}. \key{Hide all of buffer except headings}{C-c @ C-t} \key{Show all text in buffer}{C-c @ C-a} @@ -574,8 +576,8 @@ is ``C-c @''. \section{Activation} -RefTeX is part of [X]Emacs. To activate and make it interact with -AUCTeX, insert the following lines in .emacs. +RefTeX is part of Emacs. To activate and make it interact with +AUCTeX, insert the following lines in \file{init.el}. \vskip-3mm \beginexample (add-hook 'LaTeX-mode-hook 'turn-on-reftex) @@ -616,7 +618,7 @@ RefTeX's special buffers have many active keys. The common ones are: \section{Multifile actions} Since RefTeX scans the entire (multifile) document, it can provide -commands that act on all files of a document. Check the {\tt +commands that act on all files of a document. Check the \kbd{ Ref->Global Actions} menu for these commands. \section{Variables} @@ -640,12 +642,12 @@ consistent. \csname title\endcsname{RefTeX} -\section{Activation in .emacs} +\section{Activation in init.el} \vskip-4mm \beginexample (add-hook 'LaTeX-mode-hook 'turn-on-reftex) -(setq reftex-plug-into-auctex t) +(setq reftex-plug-into-AUCTeX t) \endexample \section{Table of Contents} diff --git a/font-latex.el b/font-latex.el index 6755f8d8..ae19c387 100644 --- a/font-latex.el +++ b/font-latex.el @@ -772,13 +772,13 @@ specified. Setting this variable directly does not take effect; restart Emacs." :group 'font-latex-keywords - :type `(repeat (list (string :tag "Name") + :type '(repeat (list (string :tag "Name") (choice (repeat :tag "Keywords" (string :tag "Keyword")) (repeat :tag "Keywords with specs" (group (string :tag "Keyword") (string :tag "Format specifier")))) - ,'(choice (face :tag "Face name") + (choice (face :tag "Face name") (custom-face-edit :tag "Face attributes")) (choice :tag "Type" ;; Maps to @@ -1225,9 +1225,8 @@ have changed." :group 'font-latex-highlighting-faces) (defface font-latex-slide-title-face - (let* ((scale 1.2)) - `((t (:inherit (variable-pitch font-lock-type-face) - :weight bold :height ,scale)))) + '((t (:inherit (variable-pitch font-lock-type-face) + :weight bold :height 1.2))) "Face for slide titles." :group 'font-latex-highlighting-faces) diff --git a/latex.el b/latex.el index 6b468487..68ed0f33 100644 --- a/latex.el +++ b/latex.el @@ -1733,7 +1733,7 @@ This is necessary since index entries may contain commands and stuff.") (defun LaTeX-split-bibs (match) "Extract bibliography resources from MATCH. Split the string at commas and remove Biber file extensions." - (let ((bibs (TeX-split-string " *, *" (TeX-match-buffer match)))) + (let ((bibs (split-string (TeX-match-buffer match) " *, *"))) (dolist (bib bibs) (LaTeX-add-bibliographies (replace-regexp-in-string (concat "\\(?:\\." @@ -1841,7 +1841,7 @@ The value is actually the tail of the list of options given to PACKAGE." ;; Cleanup BibTeX/Biber files (setq LaTeX-auto-bibliography (apply #'append (mapcar (lambda (arg) - (TeX-split-string "," arg)) + (split-string arg ",")) LaTeX-auto-bibliography))) ;; Reset class and packages options for the current buffer @@ -1865,8 +1865,8 @@ The value is actually the tail of the list of options given to PACKAGE." ;; Treat documentclass/documentstyle specially. (if (or (string-equal "package" class) (string-equal "Package" class)) - (dolist (elt (TeX-split-string - "\\([ \t\r\n]\\|%[^\n\r]*[\n\r]\\|,\\)+" style)) + (dolist (elt (split-string + style "\\([ \t\r\n]\\|%[^\n\r]*[\n\r]\\|,\\)+")) ;; Append style to the style list. (add-to-list 'TeX-auto-file elt t) ;; Append to `LaTeX-provided-package-options' the name of the @@ -5968,7 +5968,7 @@ If prefix argument FORCE is non-nil, always insert a regular hyphen." font-lock-comment-face))) (texmathp) (TeX-in-comment)) - (call-interactively 'self-insert-command) + (call-interactively #'self-insert-command) (let* ((lang (assoc LaTeX-babel-hyphen-language LaTeX-babel-hyphen-language-alist)) (hyphen (if lang (nth 1 lang) LaTeX-babel-hyphen)) @@ -5983,20 +5983,20 @@ If prefix argument FORCE is non-nil, always insert a regular hyphen." (progn (delete-char (- hyphen-length)) (insert "--")) (delete-char (- hyphen-length)) - (call-interactively 'self-insert-command))) + (call-interactively #'self-insert-command))) ;; -- --> [+]- ((string= (buffer-substring (max (- (point) 2) (point-min)) (point)) "--") - (call-interactively 'self-insert-command)) + (call-interactively #'self-insert-command)) ;; - --> "= / [+]- ((eq (char-before) ?-) (if h-after-h (progn (delete-char -1) (insert hyphen)) - (call-interactively 'self-insert-command))) + (call-interactively #'self-insert-command))) (h-after-h - (call-interactively 'self-insert-command)) + (call-interactively #'self-insert-command)) (t (insert hyphen)))))) ;; Cater for Delete Selection mode (put 'LaTeX-babel-insert-hyphen 'delete-selection t) @@ -6856,7 +6856,7 @@ function would return non-nil and `(match-string 1)' would return (point-max) t) (setq optstr (TeX-match-buffer 1) docstyle (TeX-match-buffer 2) - optlist (TeX-split-string "," optstr)) + optlist (split-string optstr ",")) (if (search-forward-regexp "\\\\documentstyle{\\([^}]*\\)}" (point-max) t) diff --git a/multi-prompt.el b/multi-prompt.el index 5ca34229..409e1d07 100644 --- a/multi-prompt.el +++ b/multi-prompt.el @@ -99,7 +99,7 @@ are the arguments to `completing-read'. See that." (interactive) (if (bobp) (throw 'multi-prompt-next 'back) - (call-interactively 'backward-delete-char))) + (call-interactively #'backward-delete-char))) (defun multi-prompt-next () (interactive) @@ -114,7 +114,7 @@ are the arguments to `completing-read'. See that." (defun multi-prompt-next-must-match () (interactive) - (when (call-interactively 'minibuffer-complete) + (when (call-interactively #'minibuffer-complete) (let ((content (buffer-substring-no-properties (point-min) (point-max)))) (when (or ;; (not require-match) (assoc content minibuffer-completion-table)) diff --git a/preview.el b/preview.el index 9d8a2303..e1030ebe 100644 --- a/preview.el +++ b/preview.el @@ -116,7 +116,9 @@ spec to avoid unnecessary evaluation time." :type preview-specs-type :set #'preview-specs-setter) -(defvar preview-nonready-icon) +(defvar preview-nonready-icon nil + "The icon used for previews to be generated. +Suitable spec is chosen from `preview-nonready-icon-specs'.") (defcustom preview-error-icon-specs '((:type xpm :min 22 :file "prverr24.xpm" :ascent 90) @@ -135,7 +137,9 @@ spec to avoid unnecessary evaluation time." :set #'preview-specs-setter ) -(defvar preview-error-icon) +(defvar preview-error-icon nil + "The icon used for PostScript errors. +Suitable spec is chosen from `preview-error-icon-specs'.") (defcustom preview-icon-specs '((:type xpm :min 24 :file "prvtex24.xpm" :ascent 75) @@ -156,7 +160,9 @@ spec to avoid unnecessary evaluation time." :type preview-specs-type :set #'preview-specs-setter) -(defvar preview-icon) +(defvar preview-icon nil + "The icon used for an open preview. +Suitable spec is chosen from `preview-icon-specs'.") (defgroup preview-latex nil "LaTeX options for preview." :group 'preview @@ -1318,7 +1324,7 @@ Try \\[ps-run-start] \\[ps-run-buffer] and \ (file-relative-name (car (nth 1 filenames))))) (ps-open - (let ((str + (let ((string (concat (mapconcat #'shell-quote-argument (append (list @@ -1330,7 +1336,7 @@ Try \\[ps-run-start] \\[ps-run-buffer] and \ preview-gs-init-string (aref (overlay-get ov 'queued) 1) err))) - (lambda () (interactive "@") (preview-mouse-open-error str)))) + (lambda () (interactive "@") (preview-mouse-open-error string)))) (str (preview-make-clickable nil @@ -1538,7 +1544,11 @@ so that they match the reference face in height." 10.0))) (lambda () (/ d (preview-document-pt))))) -(defvar preview-min-spec) +(defvar preview-min-spec nil + "Value to filter out too large icons. +Icon specs with :size larger than this value is not used. +Appropriate value is determined at run time according to the +display in use.") (defun preview-make-image (symbol) "Make an image from a preview spec list. @@ -2058,7 +2068,7 @@ overlays not in the active window." (push ovr preview-temporary-opened)))) (if (fboundp 'advice-add) ;Emacsā„24.4 (or ELPA package nadvice) - (advice-add 'replace-highlight :before #'preview--open-for-replace) + nil ; See the defcustom below. (defadvice replace-highlight (before preview) (preview--open-for-replace (ad-get-arg 0) (ad-get-arg 1)))) @@ -2073,10 +2083,16 @@ overlays not in the active window." :require 'preview :set (lambda (symbol value) (set-default symbol value) - (if value - (ad-enable-advice 'replace-highlight 'before 'preview) - (ad-disable-advice 'replace-highlight 'before 'preview)) - (ad-activate 'replace-highlight)) + (if (fboundp 'advice-add) ; COMPATIBILITY for Emacs<24.4 + (if value + (advice-add 'replace-highlight :before + #'preview--open-for-replace) + (advice-remove 'replace-highlight + #'preview--open-for-replace)) + (if value + (ad-enable-advice 'replace-highlight 'before 'preview) + (ad-disable-advice 'replace-highlight 'before 'preview)) + (ad-activate 'replace-highlight))) :initialize #'custom-initialize-reset) (defun preview-relaxed-string= (&rest args) @@ -2293,7 +2309,8 @@ kept." (add-hook 'kill-buffer-hook #'preview-kill-buffer-cleanup) (add-hook 'before-revert-hook #'preview-kill-buffer-cleanup) -(defvar preview-last-counter) +(defvar preview-last-counter nil + "Last counter information.") (defun preview-extract-counters (ctr) (setq preview-last-counter @@ -3909,7 +3926,8 @@ This is passed through `preview-do-replacements'." (choice (symbol :tag "Variable with literal string") (string :tag "non-literal regexp replacement"))))))) -(defvar preview-format-name) +(defvar preview-format-name nil + "Format name when enabling preamble cache.") (defcustom preview-dump-replacements '(preview-LaTeX-command-replacements @@ -3997,7 +4015,7 @@ If FORMAT-CONS is non-nil, a previous format may get reused." command format-cons) (preview-format-kill format-cons)) - (delete-file ',dump-file)) + (delete-file dump-file)) (error (preview-log-error err "Dumping" process))) (preview-reraise-error process))))))) @@ -4171,7 +4189,7 @@ internal parameters, STR may be a log to insert into the current log." ;; get the correct path but then ;; strip the extension (file-name-sans-extension - (TeX-master-file "prv" t)))))) + (TeX-master-file "prv" t)))))) (process-environment (copy-sequence process-environment)) (process (progn diff --git a/style/babel.el b/style/babel.el index 548f2c85..9206dac0 100644 --- a/style/babel.el +++ b/style/babel.el @@ -115,7 +115,7 @@ ;; take the car of `LaTeX-provided-class-options'. (cdr (car LaTeX-provided-class-options)) (cdr (assoc "babel" LaTeX-provided-package-options)))) - (setq elt (TeX-split-string "=" elt)) + (setq elt (split-string elt "=")) (if (equal (car elt) "main") ;; Starting from version 3.9 of `babel' package, languages can be set ;; with the following syntax: @@ -126,7 +126,7 @@ (setq main-language (car (cdr elt))) ;; Get rid of the modifiers (`medieval' and `notilde' in the above ;; example). - (setq elt (car (TeX-split-string "\\." (car elt)))) + (setq elt (car (split-string (car elt) "\\."))) (if (member elt LaTeX-babel-language-list) ;; Append element to `active-languages' to respect loading order. ;; `babel' package uses as default language the last loaded one, diff --git a/style/biblatex.el b/style/biblatex.el index e92f186a..c925c93c 100644 --- a/style/biblatex.el +++ b/style/biblatex.el @@ -276,7 +276,7 @@ for citation keys." ;;; Global Customization ;; Setting Package Options '("ExecuteBibliographyOptions" - [TeX-arg-eval mapconcat 'identity + [TeX-arg-eval mapconcat #'identity (TeX-completing-read-multiple "Entry type: " LaTeX-biblatex-entrytype) ","] (TeX-arg-key-val LaTeX-biblatex-executebibliographyoptions-options)) @@ -329,7 +329,7 @@ for citation keys." '("defbibcheck" "Name" t) ;; Dynamic Entry Sets '("defbibentryset" "Set" - (TeX-arg-eval mapconcat 'identity (TeX-completing-read-multiple + (TeX-arg-eval mapconcat #'identity (TeX-completing-read-multiple "Keys: " (LaTeX-bibitem-list)) ",")) ;;; Citation Commands '("cite" (TeX-arg-conditional TeX-arg-cite-note-p diff --git a/style/bigdelim.el b/style/bigdelim.el index 7f0dee5e..cb54da72 100644 --- a/style/bigdelim.el +++ b/style/bigdelim.el @@ -34,8 +34,8 @@ ;; Silence the compiler: (declare-function font-latex-add-keywords - "font-latex" - (keywords class)) + "font-latex" + (keywords class)) (defun TeX-arg-bigdelim-brace (optional side &optional prompt) "Prompt for a single brace, and do not insert the matching one. @@ -53,7 +53,7 @@ standard one." TeX-grop)) (TeX-arg-closing-brace (if (string= TeX-arg-opening-brace TeX-grop) TeX-grcl - ""))) + ""))) (TeX-argument-insert brace optional (when (member brace '("{" "}")) TeX-esc)))) diff --git a/style/hologo.el b/style/hologo.el index f714d6cf..863b3d46 100644 --- a/style/hologo.el +++ b/style/hologo.el @@ -111,9 +111,9 @@ (member (buffer-substring (region-beginning) (region-end)) LaTeX-hologo-logo-names)) (progn - (insert TeX-grop) - (goto-char (region-end)) - (insert TeX-grcl)) + (insert TeX-grop) + (goto-char (region-end)) + (insert TeX-grcl)) (TeX-argument-insert (completing-read "Logo name: " LaTeX-hologo-logo-names) optional))) diff --git a/style/newfloat.el b/style/newfloat.el index 82adbdbd..3eb865cc 100644 --- a/style/newfloat.el +++ b/style/newfloat.el @@ -176,7 +176,7 @@ If `caption.el' is loaded, add the new floating environment to '("SetupFloatingEnvironment" (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Floating environment") - (mapcar 'car (LaTeX-newfloat-DeclareFloatingEnvironment-list))) + (mapcar #'car (LaTeX-newfloat-DeclareFloatingEnvironment-list))) (TeX-arg-key-val LaTeX-newfloat-key-val-options-local)) '("ForEachFloatingEnvironment" t) @@ -185,7 +185,7 @@ If `caption.el' is loaded, add the new floating environment to '("PrepareListOf" (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Floating environment") - (mapcar 'car (LaTeX-newfloat-DeclareFloatingEnvironment-list))) + (mapcar #'car (LaTeX-newfloat-DeclareFloatingEnvironment-list))) t) '("newfloatsetup" diff --git a/style/ntheorem.el b/style/ntheorem.el index 4c57623c..e3ab7ad5 100644 --- a/style/ntheorem.el +++ b/style/ntheorem.el @@ -325,7 +325,7 @@ make them available as new environments. Update ;; 2.4 Generating Theoremlists '("listtheorems" - (TeX-arg-eval mapconcat 'identity + (TeX-arg-eval mapconcat #'identity (TeX-completing-read-multiple "Lists: " (LaTeX-ntheorem-newtheorem-list)) ",")) diff --git a/style/wrapfig.el b/style/wrapfig.el index 2de699b5..35d8a057 100644 --- a/style/wrapfig.el +++ b/style/wrapfig.el @@ -95,7 +95,7 @@ (LaTeX-newfloat-DeclareFloatingEnvironment-list)) (completing-read "Float type: " - (mapcar 'car (LaTeX-newfloat-DeclareFloatingEnvironment-list))) + (mapcar #'car (LaTeX-newfloat-DeclareFloatingEnvironment-list))) (TeX-read-string "Float type: "))) (narrow (TeX-read-string "(Optional) Number of narrow lines: ")) (placement (completing-read diff --git a/tests/japanese/preview-latex.el b/tests/japanese/preview-latex.el index 9b5f3955..d69b1105 100644 --- a/tests/japanese/preview-latex.el +++ b/tests/japanese/preview-latex.el @@ -22,8 +22,10 @@ ;;; Code: (require 'ert) -(let ((japanese-TeX-error-messages nil)) - (require 'tex-jp)) +(let (_) + (defvar japanese-TeX-error-messages) + (let ((japanese-TeX-error-messages nil)) + (require 'tex-jp))) (require 'preview) (AUCTeX-set-ert-path @@ -54,7 +56,8 @@ character used to cause trouble. Such patterns are tested." (process-environment (copy-sequence process-environment)) (locale-coding-system 'shift_jis) (TeX-japanese-process-output-coding-system nil) - (TeX-japanese-process-input-coding-system nil)) + (TeX-japanese-process-input-coding-system nil) + buffer1 buffer2) ;; Make platex binary to output in `shift_jis' encoding. (setenv "LC_ALL" "ja_JP.SJIS") ;; If your startup script for `TeX-shell' (normally "/bin/sh") @@ -63,9 +66,10 @@ character used to cause trouble. Such patterns are tested." ;; negative can be as positive. (unwind-protect (save-window-excursion - (find-file platex-shift-jis) + (setq buffer1 (find-file platex-shift-jis)) (delete-other-windows) (preview-document) + (setq buffer2 (TeX-active-buffer)) (message "Please wait for asynchronous process to finish...") (sleep-for 5) ;; Actually, this type of trouble seems to be captured early by @@ -79,17 +83,16 @@ character used to cause trouble. Such patterns are tested." (should (yes-or-no-p "\ Did all images come out at the correct position? "))) ;; Cleanup. - (set-buffer (get-file-buffer platex-shift-jis)) - (let* ((buffer (TeX-process-buffer-name (TeX-master-file nil t))) - (process (get-buffer-process buffer))) - (if process (delete-process process)) - (kill-buffer buffer)) - (preview-clearout-document) - (TeX-clean t) - (dolist (dir preview-temp-dirs) - (if (file-exists-p (directory-file-name dir)) - (delete-directory dir t))) - (kill-buffer)))) + (if (buffer-live-p buffer2) + (kill-buffer buffer2)) + (when (buffer-live-p buffer1) + (set-buffer buffer1) + (preview-clearout-document) + (TeX-clean t) + (dolist (dir preview-temp-dirs) + (if (file-exists-p (directory-file-name dir)) + (delete-directory dir t))) + (kill-buffer buffer1))))) (ert-deftest japanese-preview-different-coding-system () "Different coding systems between file and process are OK or not. @@ -104,7 +107,8 @@ the process differ." (process-environment (copy-sequence process-environment)) (locale-coding-system 'shift_jis) (TeX-japanese-process-output-coding-system nil) - (TeX-japanese-process-input-coding-system nil)) + (TeX-japanese-process-input-coding-system nil) + buffer1 buffer2) ;; Make platex binary to output in `shift_jis' encoding. (setenv "LC_ALL" "ja_JP.SJIS") ;; If your startup script for `TeX-shell' (normally "/bin/sh") @@ -113,9 +117,10 @@ the process differ." ;; negative can be as positive. (unwind-protect (save-window-excursion - (find-file different-coding-system) + (setq buffer1 (find-file different-coding-system)) (delete-other-windows) (preview-document) + (setq buffer2 (TeX-active-buffer)) (message "Please wait for asynchronous process to finish...") (sleep-for 5) ;; Actually, this type of trouble seems to be captured early by @@ -129,17 +134,16 @@ the process differ." (should (yes-or-no-p "\ Did all images come out at the correct position? "))) ;; Cleanup. - (set-buffer (get-file-buffer different-coding-system)) - (let* ((buffer (TeX-process-buffer-name (TeX-master-file nil t))) - (process (get-buffer-process buffer))) - (if process (delete-process process)) - (kill-buffer buffer)) - (preview-clearout-document) - (TeX-clean t) - (dolist (dir preview-temp-dirs) - (if (file-exists-p (directory-file-name dir)) - (delete-directory dir t))) - (kill-buffer)))) + (if (buffer-live-p buffer2) + (kill-buffer buffer2)) + (when (buffer-live-p buffer1) + (set-buffer buffer1) + (preview-clearout-document) + (TeX-clean t) + (dolist (dir preview-temp-dirs) + (if (file-exists-p (directory-file-name dir)) + (delete-directory dir t))) + (kill-buffer buffer1))))) (ert-deftest japanese-preview-preserve-kanji-option () "`TeX-inline-preview-internal' preserves kanji option or not. @@ -154,12 +158,14 @@ is enabled." (let ((TeX-clean-confirm nil) (preview-auto-cache-preamble t) (TeX-japanese-process-output-coding-system nil) - (TeX-japanese-process-input-coding-system nil)) + (TeX-japanese-process-input-coding-system nil) + buffer1 buffer2) (unwind-protect (save-window-excursion - (find-file preserve-kanji-option) + (setq buffer1 (find-file preserve-kanji-option)) (delete-other-windows) (preview-document) + (setq buffer2 (TeX-active-buffer)) (message "Please wait for asynchronous process to finish...") (sleep-for 3) (message "Please wait for asynchronous process to finish...done") @@ -169,17 +175,16 @@ is enabled." (should (yes-or-no-p "\ Did the image come out at the correct position? "))) ;; Cleanup. - (set-buffer (get-file-buffer preserve-kanji-option)) - (let* ((buffer (TeX-process-buffer-name (TeX-master-file nil t))) - (process (get-buffer-process buffer))) - (if process (delete-process process)) - (kill-buffer buffer)) - (preview-clearout-document) - (TeX-clean t) - (dolist (dir preview-temp-dirs) - (if (file-exists-p (directory-file-name dir)) - (delete-directory dir t))) - (kill-buffer)))) + (if (buffer-live-p buffer2) + (kill-buffer buffer2)) + (when (buffer-live-p buffer1) + (set-buffer buffer1) + (preview-clearout-document) + (TeX-clean t) + (dolist (dir preview-temp-dirs) + (if (file-exists-p (directory-file-name dir)) + (delete-directory dir t))) + (kill-buffer buffer1))))) ;; The following tests the individual parts fixed in May 2017 and can be ;; automated with batch mode. Note that these tests just check specific @@ -219,10 +224,10 @@ String encoded in `shift_jis' can have regexp meta characters in it." (let ((TeX-clean-confirm nil) ;; Make `preview-call-hook' inactive. (preview-image-creators nil) - dummyfile process) + dummyfile process buffer1 buffer2) (unwind-protect (save-window-excursion - (find-file preserve-kanji-option) + (setq buffer1 (find-file preserve-kanji-option)) (setq dummyfile (TeX-master-file)) (delete-other-windows) (setq process (TeX-inline-preview-internal @@ -235,17 +240,19 @@ String encoded in `shift_jis' can have regexp meta characters in it." (let ((cmd (process-command process))) (should (string-match "-kanji" (nth (1- (length cmd)) cmd))))) ;; Cleanup. - (accept-process-output process) - (set-buffer (get-file-buffer preserve-kanji-option)) - (let* ((buffer (TeX-process-buffer-name (TeX-master-file nil t))) - (process (get-buffer-process buffer))) - (if process (delete-process process)) - (kill-buffer buffer)) - (TeX-clean t) - (dolist (dir preview-temp-dirs) - (if (file-exists-p (directory-file-name dir)) - (delete-directory dir t))) - (kill-buffer)))) + (when (processp process) + (setq buffer2 (process-buffer process)) + (accept-process-output process) + (delete-process process)) + (if (buffer-live-p buffer2) + (kill-buffer buffer2)) + (when (buffer-live-p buffer1) + (set-buffer buffer1) + (TeX-clean t) + (dolist (dir preview-temp-dirs) + (if (file-exists-p (directory-file-name dir)) + (delete-directory dir t))) + (kill-buffer buffer1))))) (ert-deftest japanese-preview-preserve-kanji-option3 () "Test command to dump format file preserves kanji option or not." @@ -253,10 +260,10 @@ String encoded in `shift_jis' can have regexp meta characters in it." ;; Make `preview-call-hook' inactive. (preview-image-creators nil) (preview-format-name "dummy") - dummyfile process) + dummyfile process buffer1 buffer2) (unwind-protect (save-window-excursion - (find-file preserve-kanji-option) + (setq buffer1 (find-file preserve-kanji-option)) (setq dummyfile (TeX-master-file)) (delete-other-windows) (setq process (TeX-inline-preview-internal @@ -269,16 +276,19 @@ String encoded in `shift_jis' can have regexp meta characters in it." (let ((cmd (process-command process))) (should (string-match "-kanji" (nth (1- (length cmd)) cmd))))) ;; Cleanup. - (accept-process-output process) - (set-buffer (get-file-buffer preserve-kanji-option)) - (let* ((buffer (TeX-process-buffer-name (TeX-master-file nil t))) - (process (get-buffer-process buffer))) - (if process (delete-process process)) - (kill-buffer buffer)) - (TeX-clean t) - (dolist (dir preview-temp-dirs) - (if (file-exists-p (directory-file-name dir)) - (delete-directory dir t))) - (kill-buffer)))) + (when (processp process) + (setq buffer2 (process-buffer process)) + (accept-process-output process) + (delete-process process)) + (if (buffer-live-p buffer2) + (kill-buffer buffer2)) + (when (buffer-live-p buffer1) + (set-buffer buffer1) + (TeX-clean t) + (mapc #'preview-format-kill preview-dumped-alist) + (dolist (dir preview-temp-dirs) + (if (file-exists-p (directory-file-name dir)) + (delete-directory dir t))) + (kill-buffer buffer1))))) ;;; preview-latex.el ends here diff --git a/tests/latex/font-latex-test.el b/tests/latex/font-latex-test.el index 7484d039..577ec777 100644 --- a/tests/latex/font-latex-test.el +++ b/tests/latex/font-latex-test.el @@ -24,6 +24,8 @@ (require 'ert) (require 'latex) (require 'font-latex) +(defvar font-lock-beg) +(defvar font-lock-end) (ert-deftest font-latex-three-dollars () "Test three consecutive dollar is ignored." @@ -81,4 +83,182 @@ $a$") (should (font-latex-extend-region-backwards-quotation)) (should (= font-lock-beg 5))))) +(ert-deftest font-latex-general-fontification () + "Test general fontification in a LaTeX file." + (with-temp-buffer + (let ((TeX-install-font-lock 'font-latex-setup) + (font-latex-fontify-sectioning 'color)) + (insert "\ +\\documentclass[10pt]{article} +\\begin{document} +\\section{Macros} +Inline verbatim test: \\verb|x| +Inline math test: $x$, \\(x\\) +Marginpar test: \\marginpar{x} +Sedate macro test: \\sedate +\\section{Font Specifiers} +Roman face test: \\textrm{x} +Bold face test: \\textbf{x} +Italic face test: \\textit{x} +Bold italic face test: \\textit{\\textbf{x}} +Emphasize face test: \\emph{x} +Declarations test: \\ttfamily x {\\ttfamily x} + \\itshape x {\\itshape x} + \\bfseries x {\\bfseries x} +\\section{Environments} +\\subsection{Math} +\\begin{math} + x +\\end{math} +\\[ + x +\\] +\\[x\\] +\\begin{displaymath} + x +\\end{displaymath} +\\begin{equation} + x +\\end{equation} +\\subsection{Misc.} +\\begin{verbatim} +x +\\end{verbatim} +\\begin{description} +\\item[x] x +\\end{description} +\\end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End:\n") + (LaTeX-mode) + (font-lock-ensure) + (goto-char (point-min)) + + ;; Test for \documentclass: + (search-forward-regexp "\\\\document\\(?1:c\\)lass\\[") + (should (font-latex-faces-present-p 'font-lock-keyword-face + (match-beginning 1))) + (forward-char) + ;; Optional argument + (should (font-latex-faces-present-p 'font-lock-variable-name-face)) + (search-forward "{") + (forward-char) + ;; Mandatory argument: + (should (font-latex-faces-present-p 'font-lock-function-name-face)) + (end-of-line) + + ;; Test for \section macro itself: + (search-forward-regexp "\\\\sec\\(?1:t\\)ion{") + (should (font-latex-faces-present-p 'font-lock-keyword-face + (match-beginning 1))) + (goto-char (match-end 0)) + (forward-char) + ;; Test for the argument of \section: + (should (font-latex-faces-present-p 'font-lock-type-face)) + (end-of-line) + + ;; Test for inline verb: + (search-forward "\\verb|") + (should (font-latex-faces-present-p 'font-latex-verbatim-face)) + (end-of-line) + + ;; Test for inline math: + (search-forward "$") + (should (font-latex-faces-present-p 'font-latex-math-face)) + (search-forward "\\(") + (should (font-latex-faces-present-p 'font-latex-math-face)) + (end-of-line) + + ;; Test for marginpar: + (search-forward "\\marginpar{") + (should (font-latex-faces-present-p 'font-lock-constant-face)) + (end-of-line) + + ;; Test for unfontified macro: + (search-forward "\\seda") + (should (font-latex-faces-present-p 'font-latex-sedate-face)) + (end-of-line) + + ;; Test for font specifiers: + (search-forward "\\textrm{") + (should (font-latex-faces-present-p 'font-lock-type-face)) + (end-of-line) + (search-forward "\\textbf{") + (should (font-latex-faces-present-p 'font-latex-bold-face)) + (end-of-line) + (search-forward "\\textit{") + (should (font-latex-faces-present-p 'font-latex-italic-face)) + (end-of-line) + (search-forward "\\textit{\\textbf{") + (should (font-latex-faces-present-p '(font-latex-italic-face + font-latex-bold-face))) + (end-of-line) + (search-forward "\\emph{") + (should (font-latex-faces-present-p 'font-latex-italic-face)) + (end-of-line) + (search-forward "\\ttfam") + (should (font-latex-faces-present-p 'font-lock-type-face)) + (search-forward "\\ttfamily ") + (should (font-latex-faces-present-p 'font-lock-type-face)) + (end-of-line) + (search-forward "\\itsha") + (should (font-latex-faces-present-p 'font-latex-italic-face)) + (search-forward "\\itshape ") + (should (font-latex-faces-present-p 'font-latex-italic-face)) + (end-of-line) + (search-forward "\\bfseri") + (should (font-latex-faces-present-p 'font-latex-bold-face)) + (search-forward "\\bfseries ") + (should (font-latex-faces-present-p 'font-latex-bold-face)) + (end-of-line) + + ;; Test for math environments: + (search-forward-regexp "\\\\be\\(?1:g\\)in{ma\\(?2:t\\)h}") + (should (font-latex-faces-present-p 'font-lock-keyword-face + (match-beginning 1))) + (should (font-latex-faces-present-p 'font-lock-function-name-face + (match-beginning 2))) + (forward-line) + (skip-chars-forward "[:blank:]") + (should (font-latex-faces-present-p 'font-latex-math-face)) + (LaTeX-find-matching-end) + + (search-forward "\\[") + (forward-line) + (skip-chars-forward "[:blank:]") + (should (font-latex-faces-present-p 'font-latex-math-face)) + + (search-forward "\\[") + (should (font-latex-faces-present-p 'font-latex-math-face)) + (end-of-line) + + (search-forward "\\begin{displaymath}") + (forward-line) + (skip-chars-forward "[:blank:]") + (should (font-latex-faces-present-p 'font-latex-math-face)) + (LaTeX-find-matching-end) + + (search-forward "\\begin{equation}") + (forward-line) + (skip-chars-forward "[:blank:]") + (should (font-latex-faces-present-p 'font-latex-math-face)) + (LaTeX-find-matching-end) + + ;; Test for misc. environments: + (search-forward "\\begin{verbatim}") + (forward-line) + (should (font-latex-faces-present-p 'font-latex-verbatim-face)) + (LaTeX-find-matching-end) + + ;; Check the fontification of \item macro itself: + (search-forward-regexp "\\\\it\\(?1:e\\)m\\[") + (should (font-latex-faces-present-p 'font-lock-keyword-face + (match-beginning 1))) + ;; Now for the optional argument: + (should (font-latex-faces-present-p 'font-lock-variable-name-face)) + (LaTeX-find-matching-end) ))) + ;;; font-latex-test.el ends here diff --git a/tests/make-test-deps.emacs-lisp b/tests/make-test-deps.emacs-lisp index 17a88f4b..cce57205 100644 --- a/tests/make-test-deps.emacs-lisp +++ b/tests/make-test-deps.emacs-lisp @@ -1,6 +1,6 @@ -;; -*- emacs-lisp -*- +;; -*- mode: emacs-lisp; lexical-binding: t; -*- -;; Copyright (C) 2017 Free Software Foundation, Inc. +;; Copyright (C) 2017, 2021 Free Software Foundation, Inc. ;; This file is part of AUCTeX. diff --git a/tests/tex/path-expansion.el b/tests/tex/path-expansion.el index 2246e92c..8bce8109 100644 --- a/tests/tex/path-expansion.el +++ b/tests/tex/path-expansion.el @@ -25,11 +25,12 @@ (ert-deftest TeX-variable-truncation () "Check whether list variable is not truncated as side effect." - (let ((var '("str1" "str2")) + (defvar TeX--var) + (let ((TeX--var '("str1" "str2")) (TeX-kpathsea-path-delimiter nil) (TeX-search-files-type-alist - '((abc "${dummy}" ("str2" var) TeX-file-extensions)))) + '((abc "${dummy}" ("str2" TeX--var) TeX-file-extensions)))) (TeX-search-files-by-type 'abc 'global) - (should (equal var '("str1" "str2"))))) + (should (equal TeX--var '("str1" "str2"))))) ;;; path-expansion.el ends here diff --git a/tex-bar.el b/tex-bar.el index abec658e..06f767a6 100644 --- a/tex-bar.el +++ b/tex-bar.el @@ -83,7 +83,7 @@ If there is no help, the empty string is returned." (defcustom TeX-bar-TeX-buttons '(new-file open-file dired kill-buffer save-buffer cut copy paste undo - [separator nil] tex next-error view bibtex spell) + separator tex next-error view bibtex spell) "List of buttons available in `tex-mode'. It should be a list in the same format of the BUTTONS parameter in function `toolbarx-install-toolbar', often a symbol that @@ -107,7 +107,7 @@ alists, see variable `TeX-bar-TeX-all-button-alists'." (const paste) (const search-forward) (const print-buffer) - (const [separator nil]) + (const separator) (const tex) (const next-error) (const view) @@ -224,7 +224,7 @@ format of the argument MEANING-ALIST in the mentioned function." (defcustom TeX-bar-LaTeX-buttons '(new-file open-file dired kill-buffer save-buffer cut copy paste undo - [separator nil] latex next-error view bibtex spell) + separator latex next-error view bibtex spell) "List of buttons available in `latex-mode'. It should be a list in the same format of the BUTTONS parameter in function `toolbarx-install-toolbar', often a symbol that @@ -248,7 +248,7 @@ alists, see variable `TeX-bar-LaTeX-all-button-alists'." (const paste) (const search-forward) (const print-buffer) - (const [separator nil]) + (const separator) (const latex) (const next-error) (const view) diff --git a/tex-buf.el b/tex-buf.el index 24d287cf..f0e26bc2 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -877,7 +877,7 @@ omitted) and `TeX-region-file'." (TeX-mode-specific-command-list major-mode) nil t nil 'TeX-command-history default)))) ;; If the answer is "latex" it will not be expanded to "LaTeX" - (setq answer (car-safe (TeX-assoc answer TeX-command-list))) + (setq answer (car-safe (assoc-string answer TeX-command-list t))) (if (and answer (not (string-equal answer ""))) answer @@ -906,7 +906,7 @@ QUEUE is non-nil when we are checking for the printer queue." (format " (default %s)" TeX-printer-default) "")) TeX-printer-list)) "")) - (setq printer (or (car-safe (TeX-assoc printer TeX-printer-list)) + (setq printer (or (car-safe (assoc-string printer TeX-printer-list t)) printer)) (not (if (or (null printer) (string-equal "" printer)) (setq printer TeX-printer-default) diff --git a/tex-fold.el b/tex-fold.el index 2cf320e9..b5b19f71 100644 --- a/tex-fold.el +++ b/tex-fold.el @@ -70,7 +70,7 @@ macros, 'math for math macros and 'comment for comments." (const :tag "Comments" comment))) (defcustom TeX-fold-macro-spec-list - `(("[f]" ("footnote" "marginpar")) + '(("[f]" ("footnote" "marginpar")) ("[c]" ("cite")) ("[l]" ("label")) ("[r]" ("ref" "pageref" "eqref")) @@ -89,7 +89,7 @@ macros, 'math for math macros and 'comment for comments." "List of replacement specifiers and macros to fold. The first element of each item can be a string, an integer or a -function symbol. The second element is a list of macros two fold +function symbol. The second element is a list of macros to fold without the leading backslash. If the first element is a string, it will be used as a display diff --git a/tex.el b/tex.el index d50f9741..dcdabf6d 100644 --- a/tex.el +++ b/tex.el @@ -38,10 +38,11 @@ (eval-when-compile (require 'cl-lib)) (require 'texmathp) +;; Require dbus at compile time to get macro definition of +;; `dbus-ignore-errors'. +(eval-when-compile (require 'dbus)) ;; Silence the compiler for functions: -(declare-function dbus-ignore-errors "ext:dbus" - (&rest body)) (declare-function dbus-get-unique-name "ext:dbusbind.c" (bus)) (declare-function dbus-ping "ext:dbus" @@ -56,9 +57,6 @@ nil) (declare-function tex--prettify-symbols-compose-p "ext:tex-mode" (start end match)) -;; spell-buffer was removed in 2008 in favor of ispell -(declare-function spell-buffer "ext:text-mode" - t) ;; Silence the compiler for variables: ;; tex.el: Variables defined somewhere in this file: @@ -101,7 +99,7 @@ ;; Others: (defvar tex--prettify-symbols-alist) ; tex-mode.el (defvar Info-file-list-for-emacs) ; info.el -(defvar dbus-debug) ; dbus.el +(defvar ispell-parser) ; ispell.el (defgroup TeX-file nil "Files used by AUCTeX." @@ -564,8 +562,8 @@ string." ("%(cntxcom)" ConTeXt-expand-command) ("%(execopts)" ConTeXt-expand-options) ("%(extraopts)" (lambda () TeX-command-extra-options)) - ("%(output-dir)" (lambda () (TeX--output-dir-arg "--output-directory="))) - ("%(o-dir)" (lambda () (TeX--output-dir-arg "-o "))) + ("%(output-dir)" TeX--output-dir-arg "--output-directory=") + ("%(o-dir)" TeX--output-dir-arg "-o ") ("%S" TeX-source-correlate-expand-options) ("%dS" TeX-source-specials-view-expand-options) ("%cS" TeX-source-specials-view-expand-client) @@ -663,9 +661,9 @@ Programs should not use these variables directly but the function Each entry is a list with two or more elements. The first element is the string to be expanded. The second element is the name of a function returning the expanded string when called with -the remaining elements as arguments. The special value `file' -will be expanded to the name of the file being processed, with an -optional extension. +the remaining elements as arguments. +The second element can also be a variable name whose value is +such function. Built-in expansions provided in `TeX-expand-list-builtin' can be overwritten by defining expansions strings with the same @@ -1117,10 +1115,6 @@ The following built-in predicates are available: ;; program and the desktop environment, that will be used to set up ;; DBUS communication. -;; Require dbus at compile time to prevent errors due to `dbus-ignore-errors' -;; not being defined. -(eval-when-compile (and (featurep 'dbusbind) - (require 'dbus nil :no-error))) (defun TeX-evince-dbus-p (de app &rest options) "Return non-nil, if an evince-compatible reader is accessible via DBUS. Additional OPTIONS may be given to extend the check. If none are @@ -2576,36 +2570,19 @@ be relative to that." :group 'TeX-file :type 'string) +;; Compatibility alias (defun TeX-split-string (regexp string) - "Return a list of strings. -Given REGEXP the STRING is split into sections which in string was -separated by REGEXP. - -Examples: - - (TeX-split-string \"\:\" \"abc:def:ghi\") - -> (\"abc\" \"def\" \"ghi\") - - (TeX-split-string \" +\" \"dvips -Plw -p3 -c4 testfile.dvi\") - - -> (\"dvips\" \"-Plw\" \"-p3\" \"-c4\" \"testfile.dvi\") - -If REGEXP is nil, or \"\", an error will occur." - - (let ((start 0) result match) - (while (setq match (string-match regexp string start)) - (push (substring string start match) result) - (setq start (match-end 0))) - (push (substring string start) result) - (nreverse result))) + (split-string string regexp)) +(make-obsolete 'TeX-split-string + "use (split-string STRING REGEXP) instead." "AUCTeX 13.0") (defun TeX-parse-path (env) "Return a list if private TeX directories found in environment variable ENV." (let* ((value (getenv env)) (entries (and value - (TeX-split-string - (if (string-match ";" value) ";" ":") - value))) + (split-string + value + (if (string-match ";" value) ";" ":")))) (global (append '("/" "\\") (mapcar #'file-name-as-directory TeX-macro-global))) @@ -3367,14 +3344,14 @@ AUCTeX knows of some macros, and may query for extra arguments. Space will complete and exit." (interactive) (cond ((eq (preceding-char) ?\\) - (call-interactively 'self-insert-command)) + (call-interactively #'self-insert-command)) ((eq (preceding-char) ?.) (let ((TeX-default-macro " ") (minibuffer-local-completion-map TeX-electric-macro-map)) - (call-interactively 'TeX-insert-macro))) + (call-interactively #'TeX-insert-macro))) (t (let ((minibuffer-local-completion-map TeX-electric-macro-map)) - (call-interactively 'TeX-insert-macro))))) + (call-interactively #'TeX-insert-macro))))) (defvar TeX-exit-mark nil "Dynamically bound by `TeX-parse-macro' and `LaTeX-env-args'.") @@ -3743,7 +3720,6 @@ The algorithm is as follows: ;; Ispell support (set (make-local-variable 'ispell-parser) 'tex) - (set (make-local-variable 'ispell-tex-p) t) ;; Redefine some standard variables (make-local-variable 'paragraph-start) @@ -4732,14 +4708,11 @@ Return nil if ELT is not a member of LIST." (when (member elt list) (throw 'found t))))) +;; Compatibility alias (defun TeX-assoc (key list) - "Return non-nil if KEY is `equal' to the car of an element of LIST. -Like assoc, except case insensitive." - (let ((case-fold-search t)) - (TeX-member key list - (lambda (a b) - (string-match (concat "^" (regexp-quote a) "$") - (car b)))))) + (assoc-string key list t)) +(make-obsolete 'TeX-assoc + "use (assoc-string KEY LIST t) instead." "AUCTeX 13.0") (defun TeX-match-buffer (n) "Return the substring corresponding to the N'th match. @@ -6180,7 +6153,7 @@ With prefix argument FORCE, always inserts \" characters." (expand-abbrev) (if (TeX-looking-at-backward "\\\\/\\(}+\\)" 50) (replace-match "\\1" t)) - (call-interactively 'self-insert-command)) + (call-interactively #'self-insert-command)) (defun TeX-insert-braces (arg) "Make a pair of braces around next ARG sexps and leave point inside. @@ -6474,17 +6447,10 @@ NAME may be a package, a command, or a document." (defun TeX-run-ispell (_command _string file) "Run ispell on current TeX buffer." - (cond ((and (string-equal file (TeX-region-file)) - (fboundp 'ispell-region)) - (call-interactively 'ispell-region)) - ((string-equal file (TeX-region-file)) - (call-interactively 'spell-region)) - ((fboundp 'ispell-buffer) - (ispell-buffer)) - ((fboundp 'ispell) - (ispell)) + (cond ((string-equal file (TeX-region-file)) + (call-interactively #'ispell-region)) (t - (spell-buffer)))) + (ispell-buffer)))) (defun TeX-ispell-document (name) "Run ispell on all open files belonging to the current document." @@ -6518,12 +6484,6 @@ NAME may be a package, a command, or a document." (save-excursion (switch-to-buffer buffer) (ispell-buffer)) t))))) -;; Some versions of ispell 3 use this. -(defvar ispell-tex-major-modes nil) -(setq ispell-tex-major-modes - (append '(plain-tex-mode ams-tex-mode latex-mode doctex-mode) - ispell-tex-major-modes)) - (defcustom TeX-ispell-extend-skip-list t "Whether to extend regions selected for skipping during spell checking." :group 'TeX-misc diff --git a/toolbar-x.el b/toolbar-x.el index a1e15a37..903701c2 100644 --- a/toolbar-x.el +++ b/toolbar-x.el @@ -36,9 +36,9 @@ ;; `toolbarx-install-toolbar'). ;; * Supported properties: -;; - All editors: `:image', `:command', `:help', `:enable', -;; `:append-command' and `:prepend-command'; -;; - Emacs only: `:visible' and `:button'; +;; - `:insert', `:image', `:command', `:help', `:enable', +;; `:append-command', `:prepend-command', +;; `:visible' and `:button'; ;; For the precise value-type for each property, see documentation of ;; the function `toolbarx-install-toolbar'. ;; (ps: properties that are particular to an editor are just ignored @@ -51,6 +51,10 @@ ;; (ps: this is valid only for properties that *not* have \`form\' as ;; value type.) +;; * On `refresh time' (a call `toolbarx-refresh', necessary when the +;; toolbar should change), the `:insert' property (if present) is +;; evaluated to decide if button will be displayed. + ;; Properties can be distributed to several buttons, using \`groups\'. ;; Example: (foo (bar baz :enable (mytest)) :help "please") ;; means that `foo', `bar' and `baz' have `:help "please"' and `bar' and @@ -255,10 +259,6 @@ command, COMM is returned." (list comm))) (when app (list app)))))) -;; in Emacs, menus are made of keymaps (vectors are possible, but editors -;; handle `menu titles' differently) meanwhile in XEmacs, menus are lists of -;; vectors - (defun toolbarx-emacs-mount-popup-menu (strings var type &optional title save) "Return an interactive `lambda'-expression that shows a popup menu. @@ -1274,13 +1274,13 @@ properties are obtained!) are: :enable -- a form, evaluated constantly by both editors to determine if a button is active (enabled) or not. - :visible -- in Emacs, a form that is evaluated constantly to + :visible -- a form that is evaluated constantly to determine if a button is visible. - :button -- in Emacs, a cons cell (TYPE . SELECTED) where the + :button -- a cons cell (TYPE . SELECTED) where the TYPE should be `:toggle' or `:radio' and the cdr should be a form. SELECTED is evaluated to determine when the button is - selected.. + selected. :insert -- a form that is evaluated every time that the toolbar is refresh (a call of `toolbarx-refresh') to determine if the @@ -1409,7 +1409,7 @@ supported properties and their basic type are: to determine if the dropdown button is active (enabled) or not. - :dropdown-visible -- a form; in Emacs, it is evaluated + :dropdown-visible -- a form; it is evaluated constantly to determine if the dropdown button is visible. Also, if the symbol `dropdown' is associted in MEANING-ALIST @@ -1465,7 +1465,6 @@ line of buttons. The only property supported for this button is (not (eq 'special (get major-mode 'mode-class))))) - ;; Emacs only (write-file :image "saveas" :command write-file :enable (not @@ -1499,7 +1498,6 @@ line of buttons. The only property supported for this button is :command clipboard-yank :visible (not (eq 'special (get major-mode 'mode-class)))) - ;; Emacs only (search-forward :command nonincremental-search-forward :help "Search forward for a string" :image "search") @@ -1513,23 +1511,19 @@ line of buttons. The only property supported for this button is :command print-buffer :help "Print current buffer with page headings") - ;; Emacs only (customize :image "preferences" :command customize :help "Edit preferences (customize)") - ;; Emacs only (help :image "help" :command (lambda () (interactive) (popup-menu menu-bar-help-menu)) :help "Pop up the Help menu") - ;; Emacs only (kill-buffer :command kill-this-buffer :enable (kill-this-buffer-enabled-p) :help "Discard current buffer" :image "close") - ;; Emacs only (exit-emacs :image "exit" :command save-buffers-kill-emacs :help "Offer to save unsaved buffers, then exit Emacs") @@ -1547,7 +1541,7 @@ The following buttons are available: `open-file', `dired', `save-buffer', `undo', `cut', `copy', `paste', `search-replace', `print-buffer', `spell-buffer', `info'. - `new-file' (Emacs 22+) `write-file', `search-forward', + `new-file', `write-file', `search-forward', `customize', `help', `kill-buffer', `exit-emacs'. To reproduce the default toolbar with use as BUTTON