branch: main
commit da4a140bd8e031a98665eb9601efdda6f3df4bcb
Merge: 235f420c 255da611
Author: Tassilo Horn <[email protected]>
Commit: Tassilo Horn <[email protected]>
Merge remote-tracking branch 'origin/master'
---
NEWS.org | 4 +
bib-cite.el | 2 +-
doc/changes.texi | 12 ++
doc/preview-latex.texi | 7 +-
latex.el | 16 +--
plain-tex.el | 3 +
preview.el | 24 +++-
style/catchfilebetweentags.el | 2 +-
style/pdfsync.el | 2 +-
style/pstricks.el | 9 +-
tex-info.el | 2 +-
tex.el | 247 +++++++++++++++++++++++-------------------
toolbar-x.el | 6 +-
13 files changed, 199 insertions(+), 137 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 21b98e30..10e890e0 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -10,6 +10,10 @@
** Added
+- Add support for indirect buffers cloned from buffers visiting a file.
+ In indirect buffer, preview-latex works correctly when the command
+ ~preview-region~ is invoked. The command ~preview-document~ puts
+ preview images in the base buffer, not in the indirect buffer itself.
- Add preliminary support for processing files with latexmk. Support
for =dvipdfmx= and the choice for viewer after compilation are not
optimal, yet. Overall, the support comes close to what the
diff --git a/bib-cite.el b/bib-cite.el
index 5a7de98f..7b425cac 100644
--- a/bib-cite.el
+++ b/bib-cite.el
@@ -1903,7 +1903,7 @@ If no master file, then return current default."
;; rather than \input file
(re-search-forward "^[ \t]*\\\\\\(include\\|input\\){"
nil t))))
- (buffer-file-name))
+ (TeX-buffer-file-name))
(t
nil))))
(cond
diff --git a/doc/changes.texi b/doc/changes.texi
index cae91aa2..0d57a654 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -11,6 +11,18 @@
@heading News in 14.1
@itemize @bullet
+@item
+@AUCTeX{} can be used with indirect buffers cloned from buffers visiting a
+file. This feature allows having different perspectives of the same
+buffer (narrowing, folding, previewing, etc). The indirect buffer has the
+same master file as its base buffer.
+
+In indirect buffer, @previewlatex{} works naturally for region preview
+such as @code{preview-region} (@kbd{C-c C-p C-r}), but document preview
+@code{preview-document} (@kbd{C-c C-p C-d}) puts preview images in the
+base buffer, not in the indirect buffer itself. We expect this behavior
+doesn't matter because of the users' intent.
+
@item
@AUCTeX{} changes major mode names. Its primary purpose is to avoid
conflicts with Emacs built-in @TeX{} major modes. It also improves
diff --git a/doc/preview-latex.texi b/doc/preview-latex.texi
index 0c1fb730..0bce9747 100644
--- a/doc/preview-latex.texi
+++ b/doc/preview-latex.texi
@@ -674,7 +674,12 @@ 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.
+when they are opened.
+
+There is a side effect in enabling this option. The preview image doesn't
+turn into construction sign temporarily when you edit the underlying
+@LaTeX{} code and regenerate the preview; it is just replaced by updated
+image when ready. This behavior suppresses flicker in the appearance.
@end vtable
diff --git a/latex.el b/latex.el
index c5965b05..e2d2d88e 100644
--- a/latex.el
+++ b/latex.el
@@ -39,12 +39,12 @@
(require 'subr-x)))
;; Silence the compiler for functions:
-(declare-function outline-level "ext:outline"
- nil)
-(declare-function outline-mark-subtree "ext:outline"
- nil)
-(declare-function turn-off-filladapt-mode "ext:filladapt"
- nil)
+(declare-function multi-prompt "multi-prompt")
+(declare-function multi-prompt-key-value "multi-prompt")
+(declare-function LaTeX-install-toolbar "tex-bar" nil)
+(declare-function outline-level "ext:outline" nil)
+(declare-function outline-mark-subtree "ext:outline" nil)
+(declare-function turn-off-filladapt-mode "ext:filladapt" nil)
;; Silence the compiler for variables:
(defvar outline-heading-alist)
@@ -2569,7 +2569,7 @@ string."
Initial input is the name of the file being visited in the
current buffer, with extension. If OPTIONAL is non-nil, insert
it as an optional argument. Use PROMPT as the prompt string."
- (let ((name (file-name-nondirectory buffer-file-name)))
+ (let ((name (file-name-nondirectory (TeX-buffer-file-name))))
(TeX-argument-insert
(TeX-read-string
(TeX-argument-prompt optional
@@ -2590,7 +2590,7 @@ current buffer, without extension. If OPTIONAL is
non-nil,
insert it as an optional argument. Use PROMPT as the prompt
string."
(let ((name (file-name-sans-extension
- (file-name-nondirectory buffer-file-name))))
+ (file-name-nondirectory (TeX-buffer-file-name)))))
(TeX-argument-insert
(TeX-read-string
(TeX-argument-prompt optional
diff --git a/plain-tex.el b/plain-tex.el
index 5691859d..2b777869 100644
--- a/plain-tex.el
+++ b/plain-tex.el
@@ -30,6 +30,9 @@
(require 'tex)
+;; Silence the compiler for functions:
+(declare-function TeX-install-toolbar "tex-bar" nil)
+
;;; Tool bar
(defcustom plain-TeX-enable-toolbar t
diff --git a/preview.el b/preview.el
index 0a6d782b..31df43f0 100644
--- a/preview.el
+++ b/preview.el
@@ -1213,7 +1213,13 @@ is located."
(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."
+If non-nil, then the preview image remains visible. In either case, the
+TeX code appears either below or to the right of the displayed graphic.
+
+If you enable this option, the preview image doesn't turn into
+construction sign temporarily when you edit the underlying LaTeX code
+and regenerate the preview; it is just replaced by updated image when
+ready. This behavior suppresses flicker in the appearance."
:group 'preview-appearance
:type 'boolean)
@@ -3073,8 +3079,8 @@ pp")
#'desktop-buffer-preview-misc-data)
(add-hook 'pre-command-hook #'preview-mark-point nil t)
(add-hook 'post-command-hook #'preview-move-point nil t)
- (when buffer-file-name
- (let* ((filename (expand-file-name buffer-file-name))
+ (when (TeX-buffer-file-name)
+ (let* ((filename (expand-file-name (TeX-buffer-file-name)))
format-cons)
(when (string-match (concat "\\." TeX-default-extension "\\'")
filename)
@@ -3334,6 +3340,7 @@ call, and in its CDR the final stuff for the placement
hook."
(let (TeX-error-file TeX-error-offset snippet box counters
file line
(lsnippet 0) lstart (lfile "") lline lbuffer lpoint
+ lpos
lcounters
string after-string
offset
@@ -3604,6 +3611,12 @@ name(\\([^)]+\\))\\)\\|\
(car preview-current-region))
(goto-char (car preview-current-region)))
+ ;; Make sure that we don't accidentally match
+ ;; something earlier in the search that follows.
+ (and (eq (current-buffer) lbuffer)
+ (= lline line)
+ (goto-char (max (point) (- (1+ lpos) (length
string)))))
+
(cond
((search-forward (concat string after-string)
(line-end-position) t)
@@ -3639,6 +3652,7 @@ name(\\([^)]+\\))\\)\\|\
string
(line-end-position) t))))
(setq lline line
+ lpos (point)
lbuffer (current-buffer))
(if box
(progn
@@ -4114,8 +4128,8 @@ The function bound to this variable will be called inside
(if preview-preprocess-function
(funcall preview-preprocess-function str)
str))
- (if buffer-file-name
- (file-name-nondirectory buffer-file-name)
+ (if (TeX-buffer-file-name)
+ (file-name-nondirectory (TeX-buffer-file-name))
"<none>")
(TeX-current-offset begin)))
(setq TeX-current-process-region-p t)
diff --git a/style/catchfilebetweentags.el b/style/catchfilebetweentags.el
index 6354f15f..fb63bb7d 100644
--- a/style/catchfilebetweentags.el
+++ b/style/catchfilebetweentags.el
@@ -67,7 +67,7 @@ ENVIRONMENT is ignored."
;; several external files to a singular one.
(let* ((file (file-name-sans-extension
(file-name-nondirectory
- (buffer-file-name (current-buffer)))))
+ (TeX-buffer-file-name (current-buffer)))))
(fn (when LaTeX-catchfilebetweentags-use-numeric-label
(LaTeX-catchfilebetweentags-counter-inc)))
(tag (concat file ":"
diff --git a/style/pdfsync.el b/style/pdfsync.el
index 122f0eb9..e52baf4d 100644
--- a/style/pdfsync.el
+++ b/style/pdfsync.el
@@ -37,7 +37,7 @@
(let* ((line (line-number-at-pos))
(master (TeX-active-master))
(file (file-name-sans-extension
- (file-relative-name (buffer-file-name)
+ (file-relative-name (TeX-buffer-file-name)
(file-name-directory master))))
(pdfsync-file (concat master ".pdfsync"))
(buf-live-p (get-file-buffer pdfsync-file))
diff --git a/style/pstricks.el b/style/pstricks.el
index b5b93df6..f40db099 100644
--- a/style/pstricks.el
+++ b/style/pstricks.el
@@ -1,6 +1,6 @@
;;; pstricks.el --- AUCTeX style for the `pstricks' package. -*-
lexical-binding: t; -*-
-;; Copyright (C) 2007-2022 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2024 Free Software Foundation, Inc.
;; Author: Holger Sparr <[email protected]>
;; Maintainer: [email protected]
@@ -652,9 +652,10 @@ package PNAME"
;;; Environments
(defun LaTeX-pst-env-pspicture (env)
"Create new pspicure environment."
- (let ((opt (multi-prompt-key-value
- (TeX-argument-prompt t "Options" nil)
- '(("showgrid") ("shift"))))
+ (let ((opt (TeX-read-key-val t
+ '(("showgrid" ("true" "false"))
+ ("shift"))
+ "Options"))
(p0 (LaTeX-pst-what "point" "Lower left (default 0,0)" "0,0"))
(p1 (LaTeX-pst-what "point" "Upper right (default 1,1)" "1,1"))
corn)
diff --git a/tex-info.el b/tex-info.el
index 9f919ee3..2a65c3a9 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -700,7 +700,7 @@ value of `Texinfo-mode-hook'."
(set (make-local-variable 'TeX-style-hook-dialect) :texinfo)
(add-hook 'find-file-hook (lambda ()
- (unless (file-exists-p (buffer-file-name))
+ (unless (file-exists-p (TeX-buffer-file-name))
(TeX-master-file nil nil t)))
nil t)
diff --git a/tex.el b/tex.el
index 985cb71e..d2864b5f 100644
--- a/tex.el
+++ b/tex.el
@@ -54,11 +54,13 @@
(bus service path interface method &rest args))
(declare-function dbus-register-signal "ext:dbus"
(bus service path interface signal handler &rest args))
+(declare-function font-latex-setup "font-latex" nil)
(declare-function LaTeX-environment-list "latex" nil)
(declare-function LaTeX-bibliography-list "latex" nil)
(declare-function LaTeX-completion-label-annotation-function "latex" (label))
(declare-function LaTeX-completion-label-list "latex" nil)
(declare-function LaTeX-section-name "latex" (level))
+(declare-function TeX-fold-mode "tex-fold" (&optional arg))
(declare-function comint-exec "ext:comint"
(buffer name command startfile switches))
(declare-function comint-mode "ext:comint" nil)
@@ -673,7 +675,7 @@ string."
;; case the file is in a different subdirectory
("%b" TeX-current-file-name-master-relative)
;; Okular forward PDF search requires absolute path.
- ("%a" (lambda nil (prin1-to-string (expand-file-name (buffer-file-name)))))
+ ("%a" (lambda nil (prin1-to-string (expand-file-name
(TeX-buffer-file-name)))))
;; the following is for preview-latex.
("%m" preview-create-subdirectory)
;; LaTeXMk support
@@ -801,12 +803,12 @@ emacs 24.1 and is then later run by emacs 24.5."
(advice-add 'hack-one-local-variable :after #'TeX--call-minor-mode)
(defun TeX--call-minor-mode (var val &rest _)
"Call minor mode function if minor mode variable is found."
- ;; Instead of checking for each mode explicitly `minor-mode-list'
- ;; could be used. But this may make the byte compiler pop up.
- (when (memq var '(TeX-PDF-mode
- TeX-source-correlate-mode TeX-interactive-mode
- TeX-fold-mode LaTeX-math-mode))
- (funcall var (if (symbol-value val) 1 0))))
+ ;; Instead of checking for each mode explicitly `minor-mode-list'
+ ;; could be used. But this may make the byte compiler pop up.
+ (when (memq var '(TeX-PDF-mode
+ TeX-source-correlate-mode TeX-interactive-mode
+ TeX-fold-mode LaTeX-math-mode))
+ (funcall var (if (symbol-value val) 1 0))))
(defvar TeX-overlay-priority-step 16
"Numerical difference of priorities between nested overlays.
@@ -1251,7 +1253,7 @@ viewer."
(format "/org/%s/%s/Window/0" de app)
(format "org.%s.%s.Window" de app)
"SyncView"
- (buffer-file-name)
+ (TeX-buffer-file-name)
(list :struct :int32 (1+ (TeX-current-offset))
;; FIXME: Using `current-column' here is dubious.
;; Most of CJK letters count as occupying 2 columns,
@@ -1820,7 +1822,7 @@ Else, return nil."
(when (re-search-forward "!offset(\\([---0-9]+\\))" nil t)
(let ((offset (string-to-number (match-string-no-properties 1))))
(when TeX-region-orig-buffer
- (list (expand-file-name (buffer-file-name TeX-region-orig-buffer))
+ (list (expand-file-name (TeX-buffer-file-name
TeX-region-orig-buffer))
(+ line offset) col)))))))
(defcustom TeX-raise-frame-function #'raise-frame
@@ -2040,11 +2042,11 @@ enabled and the `synctex' binary is available."
"Return the page corresponding to the position in the current buffer.
This method assumes that the document was compiled with SyncTeX
enabled and the `synctex' binary is available."
- (let* ((file (file-relative-name (buffer-file-name)
+ (let* ((file (file-relative-name (TeX-buffer-file-name)
(file-name-directory
(TeX-active-master))))
(abs-file (concat (expand-file-name (or (file-name-directory
(TeX-active-master))
- (file-name-directory
(buffer-file-name))))
+ (file-name-directory
(TeX-buffer-file-name))))
"./" file)))
;; It's known that depending on synctex version one of
;; /absolute/path/./foo/bar.tex, foo/bar.tex, or ./foo/bar.tex (relative to
@@ -2379,7 +2381,7 @@ this variable to \"<none>\"."
(TeX-add-local-master))
((or
;; Default `read-file-name' proposes and buffer visits a file.
- (string= (expand-file-name name) (buffer-file-name))
+ (string= (expand-file-name name) (TeX-buffer-file-name))
;; Default of `read-file-name' and buffer does not visit a file.
(string= name default-directory)
;; User typed <RET> in an empty minibuffer.
@@ -2406,80 +2408,84 @@ name of master file if it cannot be determined
otherwise."
(interactive)
(if (eq extension t)
(setq extension TeX-default-extension))
- (let ((my-name (if (buffer-file-name)
- (TeX-strip-extension nil (list TeX-default-extension) t)
- "<none>")))
- (save-excursion
- (save-restriction
- (widen)
- (goto-char (point-min))
- (cond
- ((and TeX-transient-master
- (or (not TeX-master) (eq TeX-master 'shared)))
- (setq TeX-master TeX-transient-master))
- ;; Special value 't means it is own master (a free file).
- ((equal TeX-master my-name)
- (setq TeX-master t))
-
- ;; For files shared between many documents.
- ((and (eq 'shared TeX-master) ask)
- (setq TeX-master
- (let* ((default (TeX-dwim-master))
- (name (read-file-name
- (format "Master file (default %s): "
- (or default "this file"))
- nil default)))
- (cond ((string= name default)
- default)
- ((or
- ;; Default `read-file-name' proposes and
- ;; buffer visits a file.
- (string= (expand-file-name name)
- (buffer-file-name))
- ;; Default of `read-file-name' and
- ;; buffer does not visit a file.
- (string= name default-directory)
- ;; User typed <RET> in an empty minibuffer.
- (string= name ""))
- t)
- (t
- (TeX-strip-extension
- name (list TeX-default-extension) 'path))))))
-
- ;; We might already know the name.
- ((or (eq TeX-master t) (stringp TeX-master)) TeX-master)
-
- ;; Ask the user (but add it as a local variable).
- (ask (TeX-master-file-ask)))))
-
- (let ((name (if (stringp TeX-master)
- TeX-master
- my-name)))
-
- (if (TeX-match-extension name)
- ;; If it already has an extension...
- (if (equal extension TeX-default-extension)
- ;; Use instead of the default extension
- (setq extension nil)
- ;; Otherwise drop it.
- (setq name (TeX-strip-extension name))))
-
- (let* ((reg (TeX--clean-extensions-regexp t))
- (is-output-ext (and reg
- (or (string-match-p reg (concat "."
extension))
- (string= "prv" extension))))
- (output-dir (and is-output-ext
- (TeX--master-output-dir
- (file-name-directory name)
- nondirectory))))
- (if output-dir
- (setq name (concat output-dir (file-name-nondirectory name)))
- ;; Remove directory if needed.
- (if nondirectory
- (setq name (file-name-nondirectory name)))))
- (if extension
- (concat name "." extension)
- name))))
+ (with-current-buffer
+ ;; In case this is an indirect buffer:
+ (or (buffer-base-buffer) (current-buffer))
+ (let ((my-name (if (TeX-buffer-file-name)
+ (TeX-strip-extension nil (list TeX-default-extension) t)
+ "<none>")))
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (cond
+ ((and TeX-transient-master
+ (or (not TeX-master) (eq TeX-master 'shared)))
+ (setq TeX-master TeX-transient-master))
+
+ ;; Special value 't means it is own master (a free file).
+ ((equal TeX-master my-name)
+ (setq TeX-master t))
+
+ ;; For files shared between many documents.
+ ((and (eq 'shared TeX-master) ask)
+ (setq TeX-master
+ (let* ((default (TeX-dwim-master))
+ (name (read-file-name
+ (format "Master file (default %s): "
+ (or default "this file"))
+ nil default)))
+ (cond ((string= name default)
+ default)
+ ((or
+ ;; Default `read-file-name' proposes and
+ ;; buffer visits a file.
+ (string= (expand-file-name name)
+ (TeX-buffer-file-name))
+ ;; Default of `read-file-name' and
+ ;; buffer does not visit a file.
+ (string= name default-directory)
+ ;; User typed <RET> in an empty minibuffer.
+ (string= name ""))
+ t)
+ (t
+ (TeX-strip-extension
+ name (list TeX-default-extension) 'path))))))
+
+ ;; We might already know the name.
+ ((or (eq TeX-master t) (stringp TeX-master)))
+
+ ;; Ask the user (but add it as a local variable).
+ (ask (TeX-master-file-ask)))))
+
+ (let ((name (if (stringp TeX-master)
+ TeX-master
+ my-name)))
+
+ (if (TeX-match-extension name)
+ ;; If it already has an extension...
+ (if (equal extension TeX-default-extension)
+ ;; Use instead of the default extension
+ (setq extension nil)
+ ;; Otherwise drop it.
+ (setq name (TeX-strip-extension name))))
+
+ (let* ((reg (TeX--clean-extensions-regexp t))
+ (is-output-ext (and reg
+ (or (string-match-p reg (concat "."
extension))
+ (string= "prv" extension))))
+ (output-dir (and is-output-ext
+ (TeX--master-output-dir
+ (file-name-directory name)
+ nondirectory))))
+ (if output-dir
+ (setq name (concat output-dir (file-name-nondirectory name)))
+ ;; Remove directory if needed.
+ (if nondirectory
+ (setq name (file-name-nondirectory name)))))
+ (if extension
+ (concat name "." extension)
+ name)))))
(defun TeX-master-directory ()
"Directory of master file."
@@ -2488,17 +2494,15 @@ name of master file if it cannot be determined
otherwise."
(substitute-in-file-name
(expand-file-name
(let ((dir (file-name-directory (TeX-master-file))))
- (if dir (directory-file-name dir) "."))
- (and buffer-file-name
- (file-name-directory buffer-file-name)))))))
+ (if dir (directory-file-name dir) ".")))))))
(defun TeX-add-local-master ()
"Add local variable for `TeX-master'.
Get `major-mode' from master file and enable it."
- (when (and (buffer-file-name)
+ (when (and (TeX-buffer-file-name)
(string-match TeX-one-master
- (file-name-nondirectory (buffer-file-name)))
+ (file-name-nondirectory (TeX-buffer-file-name)))
(not buffer-read-only))
(goto-char (point-max))
(if (re-search-backward "^\\([^\n]+\\)Local Variables:"
@@ -2604,6 +2608,16 @@ ARGNAME is prepended to the quoted output directory. If
(concat argname "\"" out-dir "\"")
"")))
+(defun TeX-master-output-file (extension)
+ "Return the output file with given EXTENSION.
+If `TeX-output-dir' is nil, then defer to `TeX-master-file'. Otherwise,
+return the file of the same name, but in the build directory specified by
+`TeX-output-dir'."
+ (let ((master (TeX-master-file extension)))
+ (if-let ((output-dir (TeX--master-output-dir (TeX-master-directory) t)))
+ (concat output-dir (file-name-nondirectory master))
+ master)))
+
(defcustom TeX-style-local "style"
"Directory containing hand generated TeX information.
@@ -3087,9 +3101,9 @@ FORCE is not nil."
(TeX-run-style-hooks (TeX-strip-extension nil nil t))
;; Run parent style hooks if it has a single parent that isn't itself.
(if (or (not (memq TeX-master '(nil t)))
- (and (buffer-file-name)
+ (and (TeX-buffer-file-name)
(string-match TeX-one-master
- (file-name-nondirectory (buffer-file-name)))))
+ (file-name-nondirectory
(TeX-buffer-file-name)))))
(TeX-run-style-hooks (TeX-master-file)))
(if (and TeX-parse-self
(null (cdr-safe (assoc (TeX-strip-extension nil nil t)
@@ -3881,7 +3895,7 @@ Not intended for direct use for user."
(add-hook 'find-file-hook
(lambda ()
;; Check if we are looking at a new or shared file.
- (when (or (not (file-exists-p (buffer-file-name)))
+ (when (or (not (file-exists-p (TeX-buffer-file-name)))
(eq TeX-master 'shared))
(TeX-master-file nil nil t))
(TeX-update-style t)) nil t))
@@ -4637,7 +4651,7 @@ STRING defaults to the name of the current buffer.
EXTENSIONS defaults to `TeX-file-extensions'."
(if (null string)
- (setq string (or (buffer-file-name) "<none>")))
+ (setq string (or (TeX-buffer-file-name) "<none>")))
(if (null extensions)
(setq extensions TeX-file-extensions))
@@ -4920,7 +4934,7 @@ to look backward for."
(defun TeX-current-file-name-master-relative ()
"Return current filename, relative to master directory."
(file-relative-name
- (buffer-file-name)
+ (TeX-buffer-file-name)
(TeX-master-directory)))
(defun TeX-near-bobp ()
@@ -6269,18 +6283,21 @@ this list.")
Save buffer first including style information.
With optional argument ARG, also reload the style hooks."
(interactive "*P")
- (if arg
- (dolist (var TeX-normal-mode-reset-list)
- (set var nil)))
- (let ((gc-cons-percentage 0.5))
- (let ((TeX-auto-save t))
- (if (buffer-modified-p)
- (save-buffer)
- (TeX-auto-write)))
- (normal-mode)
- ;; See also addition to `find-file-hook' in `TeX-mode'.
- (when (eq TeX-master 'shared) (TeX-master-file nil nil t))
- (TeX-update-style t)))
+ (with-current-buffer
+ ;; In case this is an indirect buffer:
+ (or (buffer-base-buffer) (current-buffer))
+ (if arg
+ (dolist (var TeX-normal-mode-reset-list)
+ (set var nil)))
+ (let ((gc-cons-percentage 0.5))
+ (let ((TeX-auto-save t))
+ (if (buffer-modified-p)
+ (save-buffer)
+ (TeX-auto-write)))
+ (normal-mode)
+ ;; See also addition to `find-file-hook' in `TeX-mode'.
+ (when (eq TeX-master 'shared) (TeX-master-file nil nil t))
+ (TeX-update-style t))))
(defgroup TeX-quote nil
"Quoting in AUCTeX."
@@ -6730,7 +6747,7 @@ NAME may be a package, a command, or a document."
(buffers (buffer-list)))
(while buffers
(let* ((buffer (car buffers))
- (name (buffer-file-name buffer)))
+ (name (TeX-buffer-file-name buffer)))
(setq buffers (cdr buffers))
(when (and name (string-match regexp name))
(save-excursion (switch-to-buffer buffer) (ispell-buffer))
@@ -7096,7 +7113,7 @@ pinned region will get unpinned and vice versa."
TeX-region-extra)))
(TeX-region-create (TeX-region-file TeX-default-extension)
(buffer-substring-no-properties begin end)
- (file-name-nondirectory (buffer-file-name))
+ (file-name-nondirectory (TeX-buffer-file-name))
(TeX-current-offset begin))))
(defun TeX-command-region (&optional override-confirm)
@@ -7588,14 +7605,14 @@ ORIGINALS which are modified but not saved yet."
(setq existingoriginals (cons filepath existingoriginals)))))))
(while buffers
(let* ((buffer (car buffers))
- (name (buffer-file-name buffer)))
+ (name (TeX-buffer-file-name buffer)))
(setq buffers (cdr buffers))
(if (and name (member name existingoriginals))
(progn
(and (buffer-modified-p buffer)
(or (not TeX-save-query)
(y-or-n-p (concat "Save file "
- (buffer-file-name buffer)
+ (TeX-buffer-file-name buffer)
"? ")))
(with-current-buffer buffer (save-buffer)))))))
(dolist (eo existingoriginals)
@@ -10430,6 +10447,12 @@ warnings and bad boxes"
#'TeX-master-file))))
(error "Unable to find what command to run")))
+(defun TeX-buffer-file-name (&optional BUFFER)
+ "Return name of file BUFFER is visiting, or nil if none.
+No argument or nil as argument means use the current buffer.
+If BUFFER is indirect, return the file that the base buffer is visiting."
+ (buffer-file-name (or (buffer-base-buffer BUFFER) BUFFER)))
+
(provide 'tex)
;; Local Variables:
diff --git a/toolbar-x.el b/toolbar-x.el
index d97035fd..f8e8ae91 100644
--- a/toolbar-x.el
+++ b/toolbar-x.el
@@ -1462,11 +1462,11 @@ line of buttons. The only property supported for this
button is
:command save-buffer
:enable (and
(buffer-modified-p)
- (buffer-file-name)
+ (buffer-file-name (buffer-base-buffer))
(not (window-minibuffer-p
(frame-selected-window menu-updating-frame))))
:help "Save current buffer to its file"
- :visible (or buffer-file-name
+ :visible (or (buffer-file-name (buffer-base-buffer))
(not (eq 'special
(get major-mode 'mode-class)))))
@@ -1476,7 +1476,7 @@ line of buttons. The only property supported for this
button is
(window-minibuffer-p
(frame-selected-window menu-updating-frame)))
:help "Write current buffer to another file"
- :visible (or buffer-file-name
+ :visible (or (buffer-file-name (buffer-base-buffer))
(not (eq 'special (get major-mode 'mode-class)))))
(undo :image "undo"