diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-08-11 21:26:29 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-08-11 21:26:29 +0200 |
commit | bdec9daf57a72dc48a70ae1600b3f331531c229b (patch) | |
tree | 28bcea3958bcc07b3d7379b66e293d1cb1e5f61a /lisp | |
parent | b81de1be90ce287b5aa6d859317c157d988e8cb0 (diff) | |
download | emacs-bdec9daf57a72dc48a70ae1600b3f331531c229b.tar.gz emacs-bdec9daf57a72dc48a70ae1600b3f331531c229b.tar.bz2 emacs-bdec9daf57a72dc48a70ae1600b3f331531c229b.zip |
Allow `tex-buffer' to work on buffers not visiting files
* lisp/textmodes/tex-mode.el (tex-region): Make `tex-buffer' work
again on unsaved files (bug#34082).
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/textmodes/tex-mode.el | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 5169377c136..51216bdbe73 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -2533,7 +2533,10 @@ The value of `tex-command' specifies the command to use to run TeX." (file-name-as-directory (expand-file-name tex-directory))) (tex-out-file (expand-file-name (concat tex-zap-file ".tex") zap-directory)) - (main-file (expand-file-name (tex-main-file))) + ;; We may be running from an unsaved buffer, in which case + ;; there's no point in guessing for a main file name. + (main-file (and buffer-file-name + (expand-file-name (tex-main-file)))) (ismain (string-equal main-file (buffer-file-name))) already-output) ;; Don't delete temp files if we do the same buffer twice in a row. @@ -2542,9 +2545,11 @@ The value of `tex-command' specifies the command to use to run TeX." (let ((default-directory zap-directory)) ; why? ;; We assume the header is fully contained in tex-main-file. ;; We use f-f-ns so we get prompted about any changes on disk. - (with-current-buffer (find-file-noselect main-file) - (setq already-output (tex-region-header tex-out-file - (and ismain beg)))) + (if (not main-file) + (setq already-output 0) + (with-current-buffer (find-file-noselect main-file) + (setq already-output (tex-region-header tex-out-file + (and ismain beg))))) ;; Write out the specified region (but don't repeat anything ;; already written in the header). (write-region (if ismain |