branch: externals/auctex commit ff9b4e3810c8b22ecaad41a8d97bab854cbfe704 Merge: ab15f6845b 4731168eca Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge remote-tracking branch 'origin/master' --- NEWS.org | 35 +++++++++++++++------ context.el | 9 ++++-- doc/auctex.texi | 10 +++--- doc/changes.texi | 14 +++++++++ doc/preview-latex.texi | 8 +++++ preview.el | 84 ++++++++++++++++++++++++++++++++++++++++---------- tex-fold.el | 1 + tex.el | 43 ++++++++++++++++++++++++-- 8 files changed, 169 insertions(+), 35 deletions(-) diff --git a/NEWS.org b/NEWS.org index 1c741b10e0..21b98e3072 100644 --- a/NEWS.org +++ b/NEWS.org @@ -14,12 +14,29 @@ for =dvipdfmx= and the choice for viewer after compilation are not optimal, yet. Overall, the support comes close to what the =auctex-latexmk= library provides. -- Support query and insert of ~mcite~ compatibility macros - (=style/biblatex.el=). -- Support the =\verbatiminput*= macro (=style/verbatim.el=). -- Add new custom variable ~TeX-fold-auto-reveal~ which contols how the +- Add new command ~TeX-fold-section~ (bound to =C-c C-o C-s=) which + hides all configured macros in the section containing point when + ~TeX-fold-mode~ is active. The unfold counterpart + ~TeX-fold-clearout-section~ is bound to =C-c C-o s=. +- Add new custom option ~TeX-fold-auto-reveal~ which contols how the original source text is revealed when user clicks the folded portion by mouse. +- Add new custom option ~TeX-fold-region-functions~ which is a list of + additional functions to call when folding a region. +- Add new custom option ~preview-protect-point~ which determines whether + previews generated on top of the current point should be temporarily + opened (~nil~ by default). +- Add new custom option ~preview-leave-open-previews-visible~ which + determines if the preview code stays visible once opened. +- Support query and insert of ~mcite~ compatibility macro + (=style/biblatex.el=). +- Support the =\verbatiminput*= macro (=style/verbatim.el=). + +** Fixed + +- Adjust options when processing files with ConTeXt: Remove obsolete + =--texutil=, use =--synctex=repeat= and omit =--nonstop= when + ~TeX-source-correlate-mode~ is enabled. * [14.0.4] - 2024-03-31 @@ -27,11 +44,11 @@ - Support completion for many commands described in =clsguide.tex=, =fntguide.tex= and =usrguide.tex=. -- Provide new custom variable ~LaTeX-flymake-chktex-options~ to enable - or disable specific warnings of =chktex= backend used by Flymake. -- Provide new custom variable ~TeX-kill-process-without-query~ which - controls if user is asked before aborting a running process for a - TeX document. +- Provide new custom option ~LaTeX-flymake-chktex-options~ to enable or + disable specific warnings of =chktex= backend used by Flymake. +- Provide new custom option ~TeX-kill-process-without-query~ which + controls if user is asked before aborting a running process for a TeX + document. ** Fixed diff --git a/context.el b/context.el index 29bbccd66a..0d5b9adbd1 100644 --- a/context.el +++ b/context.el @@ -1747,8 +1747,13 @@ Use `ConTeXt-Mark-version' to choose the command." ((string= ConTeXt-Mark-version "IV") (concat (if TeX-source-correlate-mode - "--synctex=1 ") - (unless TeX-interactive-mode + "--synctex=repeat ") + ;; Omit nonstop option when we set synctex option. According to + ;; Jim <zlists+cont...@jdvb.ca> in bug#70399 report, + ;; "if context is called with "--nonstopmode" (or "--nonstop") + ;; the "--synctex=..." request to create a synctex file is + ;; over-ridden." + (unless (or TeX-interactive-mode TeX-source-correlate-mode) ConTeXt-texexec-option-nonstop))) ;; In any other case fall back on Mark II. (t diff --git a/doc/auctex.texi b/doc/auctex.texi index 066dfbb07a..4d338c3977 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -2667,9 +2667,9 @@ containing point. @end deffn @deffn Command TeX-fold-section -@kindex C-c C-o C-p -(@kbd{C-c C-o C-p}) Hide all configured macros in the section -containing point. +@kindex C-c C-o C-s +(@kbd{C-c C-o C-s}) Hide all configured macros in the section containing +point. @end deffn @deffn Command TeX-fold-macro @@ -2725,8 +2725,8 @@ paragraph containing point. @end deffn @deffn Command TeX-fold-clearout-section -@kindex C-c C-o p -(@kbd{C-c C-o p}) Permanently unfold all macros and environments in the +@kindex C-c C-o s +(@kbd{C-c C-o s}) Permanently unfold all macros and environments in the section containing point. @end deffn diff --git a/doc/changes.texi b/doc/changes.texi index 098195ac0a..cae91aa2fe 100644 --- a/doc/changes.texi +++ b/doc/changes.texi @@ -187,6 +187,20 @@ In Fold mode, the original source text is revealed when you click the folded portion by mouse. You can customize the detailed behavior by new customize option @code{TeX-fold-auto-reveal}. +@item +@AUCTeX{} adjusts @ConTeXt{} option. +@itemize @minus +@item +Obsolete option @option{--texutil} was removed. +@item +Now synctex option is @option{--synctex=repeat} instead of +@option{--synctex=1} for @ConTeXt{}. +@item +@AUCTeX{} omits @option{--nonstop} option when +@code{TeX-source-correlate-mode} is enabled because @command{context} +ignores @option{--synctex} option if @option{--nonstop} is present. +@end itemize + @item @AUCTeX{} now requires GNU Emacs 27.1 or higher. @end itemize diff --git a/doc/preview-latex.texi b/doc/preview-latex.texi index 4aba7cb5e5..0c1fb730a1 100644 --- a/doc/preview-latex.texi +++ b/doc/preview-latex.texi @@ -668,6 +668,14 @@ when this is needed is in accordingly @code{split} is one entry in @code{preview-inner-environments}. +@item preview-protect-point +This boolean variable determines whether previews generated on top of the +current point should be temporarily opened. Default value is @code{nil}. + +@item preview-leave-open-previews-visible +This boolean variable determines whether to leave preview images visible +(above their generating TeX code) when they are opened. + @end vtable @node The preview images, Misplaced previews, The Emacs interface, For advanced users diff --git a/preview.el b/preview.el index 2f59a04fb8..0a6d782b23 100644 --- a/preview.el +++ b/preview.el @@ -1210,6 +1210,13 @@ is located." (setcdr (car img) (cdar replacement)) (setcdr img (cdr replacement)))) +(defcustom preview-leave-open-previews-visible nil + "Whether to leave previews visible when they are opened. +If nil, then the TeX preview icon is used when the preview is opened. +If non-nil, then the preview image is moved above the text." + :group 'preview-appearance + :type 'boolean) + (defun preview-gs-place (ov snippet box run-buffer tempdir ps-file _imagetype) "Generate an image placeholder rendered over by Ghostscript. This enters OV into all proper queues in order to make it render @@ -1231,7 +1238,21 @@ for the file extension." (overlay-put ov 'queued (vector box nil snippet)) (overlay-put ov 'preview-image - (list (preview-icon-copy preview-nonready-icon))) + (let ((default (list (preview-icon-copy preview-nonready-icon)))) + (if preview-leave-open-previews-visible + (if-let ((img + (car + (delq + nil + (mapcar + (lambda (ovr) + (and + (eq (overlay-start ovr) (overlay-start ov)) + (overlay-get ovr 'preview-image))) + (overlays-at (overlay-start ov))))))) + img + default) + default))) (preview-add-urgentization #'preview-gs-urgentize ov run-buffer) (list ov)) @@ -1895,6 +1916,11 @@ Disable it if that is the case. Ignores text properties." text (overlay-get ov 'preview-prechange))) (overlay-put ov 'insert-in-front-hooks nil) (overlay-put ov 'insert-behind-hooks nil) + (when (and preview-leave-open-previews-visible + (eq (overlay-get ov 'preview-state) 'active)) + ;; This is so that remote commands, such as `undo', + ;; open active previews before disabling them. + (preview-toggle ov)) (preview-disable ov))))) (error nil)) (overlay-put ov 'preview-prechange nil)) @@ -2190,10 +2216,12 @@ active (`transient-mark-mode'), it is run through `preview-region'." "Change overlay behaviour of OVR after source edits." (overlay-put ovr 'queued nil) (preview-remove-urgentization ovr) - (overlay-put ovr 'preview-image nil) + (unless preview-leave-open-previews-visible + (overlay-put ovr 'preview-image nil)) (overlay-put ovr 'timestamp nil) (setcdr (overlay-get ovr 'strings) (preview-disabled-string ovr)) - (preview-toggle ovr) + (unless preview-leave-open-previews-visible + (preview-toggle ovr)) (overlay-put ovr 'preview-state 'disabled) (dolist (filename (overlay-get ovr 'filenames)) (condition-case nil @@ -2213,17 +2241,20 @@ a hook in some cases" (preview-delete-file filename) (file-error nil))))) -(defun preview-clearout (&optional start end timestamp) +(defun preview-clearout (&optional start end timestamp exception) "Clear out all previews in the current region. When called interactively, the current region is used. Non-interactively, the region between START and END is affected. Those two values default to the borders of the entire buffer. If TIMESTAMP is non-nil, previews -with a `timestamp' property of it are kept." +with a `timestamp' property of it are kept. If EXCEPTION +is a non-nil overlay, then it is not cleared." (interactive "r") (dolist (ov (overlays-in (or start (point-min)) (or end (point-max)))) - (and (overlay-get ov 'preview-state) + (and (or (not exception) + (not (eq ov exception))) + (overlay-get ov 'preview-state) (not (and timestamp (equal timestamp (overlay-get ov 'timestamp)))) (preview-delete ov)))) @@ -2429,7 +2460,9 @@ visible. For efficiency reasons it is expected that the buffer is already selected and unnarrowed." (concat (preview-make-clickable (overlay-get ov 'preview-map) - preview-icon + (if preview-leave-open-previews-visible + (overlay-get ov 'preview-image) + preview-icon) "\ %s redisplays preview %s more options") @@ -2550,6 +2583,10 @@ it gets deleted as well." (defvar-local preview-buffer-has-counters nil) +(defvar-local preview-current-region nil + "Cons cell (begin . end) tracking the region currently being previewed. +Set in `preview-region', cleared in `preview-place-preview'.") + (defun preview-place-preview (snippet start end box counters tempdir place-opts) "Generate and place an overlay preview image. @@ -2564,7 +2601,7 @@ PLACE-OPTS are additional arguments passed into a list with additional info from the placement hook. Those lists get concatenated together and get passed to the close hook." - (preview-clearout start end tempdir) + (setq preview-current-region nil) (let ((ov (make-overlay start end nil nil nil))) (overlay-put ov 'priority (TeX-overlay-prioritize start end)) (overlay-put ov 'preview-map @@ -2582,7 +2619,8 @@ to the close hook." place-opts) (overlay-put ov 'strings (list (preview-active-string ov))) - (preview-toggle ov t)))) + (preview-toggle ov t) + (preview-clearout start end tempdir ov)))) (defun preview-counter-find (begin) "Fetch the next preceding or next preview-counters property. @@ -3268,8 +3306,6 @@ Return a new string." (setq result (concat result string)) result)) -(defvar-local preview--region-begin nil) - (defvar preview-find-end-function nil "Function used to compute the end position for a new overlay. The function bound to this variable will be called inside @@ -3278,6 +3314,13 @@ beginning of the overlay. This is intended to be used in conjunction with `preview-preprocess-function' when the latter introduces significant modifications.") +(defcustom preview-protect-point nil + "Temporarily open new previews that would obscure point. +If non-nil, then any new preview whose bounds contain point is +temporarily opened, as if the user had entered it via movement commands." + :group 'preview-appearance + :type 'boolean) + (defvar preview-locating-previews-message "locating previews...") (defun preview-parse-messages (open-closure) @@ -3298,6 +3341,7 @@ call, and in its CDR the final stuff for the placement hook." (run-buffer (current-buffer)) (run-directory default-directory) tempdir + point-current close-data open-data fast-hook @@ -3520,6 +3564,7 @@ name(\\([^)]+\\))\\)\\|\ (setq lfile file)) (save-excursion (save-restriction + (setq point-current (point)) (widen) ;; a fast hook might have positioned us already: (if (number-or-marker-p string) @@ -3554,10 +3599,10 @@ name(\\([^)]+\\))\\)\\|\ ;; The following addresses the bug described at ;; https://lists.gnu.org/archive/html/bug-auctex/2023-03/msg00007.html ;; (bug#62445) - (and preview--region-begin + (and preview-current-region (< (point) - preview--region-begin) - (goto-char preview--region-begin)) + (car preview-current-region)) + (goto-char (car preview-current-region))) (cond ((search-forward (concat string after-string) @@ -3618,7 +3663,14 @@ name(\\([^)]+\\))\\)\\|\ (cons lcounters counters) tempdir (cdr open-data)))) - (setq close-data (nconc ovl close-data))) + (setq close-data (nconc ovl close-data)) + (when (and preview-protect-point + (<= region-beg point-current) + (< point-current region-end)) + ;; Temporarily open the preview if it + ;; would bump the point. + (preview-toggle (car ovl)) + (push (car ovl) preview-temporary-opened))) (with-current-buffer run-buffer (preview-log-error (list 'error @@ -4067,7 +4119,7 @@ The function bound to this variable will be called inside "<none>") (TeX-current-offset begin))) (setq TeX-current-process-region-p t) - (setq preview--region-begin begin) + (setq preview-current-region (cons begin end)) (preview-generate-preview (TeX-region-file) (preview-do-replacements (TeX-command-expand diff --git a/tex-fold.el b/tex-fold.el index 19e35a2c05..62f0834c6f 100644 --- a/tex-fold.el +++ b/tex-fold.el @@ -51,6 +51,7 @@ (autoload 'LaTeX-backward-paragraph "latex") (autoload 'LaTeX-find-matching-begin "latex") (autoload 'LaTeX-find-matching-end "latex") +(autoload 'LaTeX-mark-section "latex") (autoload 'ConTeXt-find-matching-start "context") (autoload 'ConTeXt-find-matching-stop "context") (autoload 'Texinfo-find-env-start "tex-info") diff --git a/tex.el b/tex.el index 18689f408c..985cb71e9b 100644 --- a/tex.el +++ b/tex.el @@ -211,7 +211,7 @@ If nil, none is specified." TeX-run-TeX nil (AmSTeX-mode) :help "Run AMSTeX") ;; support for ConTeXt --pg ;; first version of ConTeXt to support nonstopmode: 2003.2.10 - ("ConTeXt" "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t" + ("ConTeXt" "%(cntxcom) --once %(extraopts) %(execopts)%t" TeX-run-TeX nil (ConTeXt-mode) :help "Run ConTeXt once") ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t" TeX-run-TeX nil @@ -250,6 +250,9 @@ If nil, none is specified." ("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Convert PostScript file to PDF") + ("LaTeXMk" "latexmk %(latexmk-out) %(file-line-error) \ +%`%(extraopts) %S%(mode)%' %t" + TeX-run-format nil (LaTeX-mode docTeX-mode) :help "Run LaTeXMk") ("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Run makeglossaries to create glossary file") @@ -672,7 +675,40 @@ string." ;; Okular forward PDF search requires absolute path. ("%a" (lambda nil (prin1-to-string (expand-file-name (buffer-file-name))))) ;; the following is for preview-latex. - ("%m" preview-create-subdirectory)) + ("%m" preview-create-subdirectory) + ;; LaTeXMk support + ("%(latexmk-out)" + (lambda () + (cond ((eq TeX-engine 'xetex) + " -pdfxe") + ((eq TeX-engine 'luatex) + (cond ((and TeX-PDF-mode + (TeX-PDF-from-DVI)) + " -dvilua -pdfdvi") + ((and (not TeX-PDF-mode) + TeX-DVI-via-PDFTeX) + " -dvilua -ps") + ;; This covers the case: + ;; (and TeX-PDF-mode (not (TeX-PDF-from-DVI))) + (t + " -pdflua"))) + ;; This covers everything else since we ignore 'omega: + (t + (cond ((and TeX-PDF-mode + (not (TeX-PDF-from-DVI))) + " -pdf") + ((and TeX-PDF-mode + (string= (TeX-PDF-from-DVI) "Dvips")) + " -pdfps") + ;; FIXME: This might be inaccurate: + ((and TeX-PDF-mode + (string= (TeX-PDF-from-DVI) "Dvipdfmx")) + " -pdfdvi") + ((and (not TeX-PDF-mode) + TeX-DVI-via-PDFTeX) + " -pdflatex -dvi -ps") + (t + " -dvi -ps"))))))) "List of built-in expansion strings for TeX command names. This should not be changed by the user who can use @@ -2200,7 +2236,8 @@ Must be the car of an entry in `TeX-command-list'." "\\.glo" "\\.gls" "\\.idx" "\\.ilg" "\\.ind" "\\.lof" "\\.log" "\\.lot" "\\.nav" "\\.out" "\\.snm" "\\.toc" "\\.url" "\\.synctex\\.gz" - "\\.bcf" "\\.run\\.xml" "\\.fls" "-blx\\.bib") + "\\.bcf" "\\.run\\.xml" "\\.fls" "-blx\\.bib" + "\\.fdb_latexmk") "List of regexps matching suffixes of files to be cleaned. Used as a default in TeX, LaTeX and docTeX mode.")