Skip to content

Commit

Permalink
Omit f-f hooks and more with TeX-region-create
Browse files Browse the repository at this point in the history
* tex-buf.el (TeX-region-create): Disable finding of appropriate
major-mode for region file.  Also disable file-local vars, and
don't run find-file-hook functions.  Also, make the region file
read-only to prevent accidental editing where actually the real
file should have been edited (happens easily with source
correlation mode).
  • Loading branch information
tsdh committed Nov 18, 2014
1 parent 622c054 commit 15edd9b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2014-11-18 Tassilo Horn <tsdh@gnu.org>

* tex-buf.el (TeX-region-create): Disable finding of appropriate
major-mode for region file. Also disable file-local vars, and
don't run find-file-hook functions. Also, make the region file
read-only to prevent accidental editing where actually the real
file should have been edited (happens easily with source
correlation mode).

2014-11-16 Mos� Giordano <mose@gnu.org>

* Makefile.in (WEMACSDATAROOTDIR, WEMACSSITELISP): New variables.
Expand Down
55 changes: 32 additions & 23 deletions tex-buf.el
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,14 @@ original file."
(font-lock-auto-fontify nil)
(font-lock-mode-enable-list nil)
;; And insert them into the FILE buffer.
(file-buffer (let ((TeX-transient-master t))
(file-buffer (let (;; Don't query for master file
(TeX-transient-master t)
;; Don't choose a special mode (and call its hooks)
(auto-mode-alist nil)
(magic-mode-alist nil)
(enable-local-variables nil)
;; Don't run any f-f hooks
(find-file-hook nil))
(find-file-noselect file)))
;; But remember original content.
original-content
Expand Down Expand Up @@ -1462,29 +1469,31 @@ original file."
original (TeX-master-directory)))
master-name (TeX-quote-filename master-name))
(with-current-buffer file-buffer
(setq buffer-undo-list t)
(setq buffer-read-only t
buffer-undo-list t)
(setq original-content (buffer-string))
(erase-buffer)
(when (boundp 'buffer-file-coding-system)
(setq buffer-file-coding-system
(with-current-buffer master-buffer buffer-file-coding-system)))
(insert "\\message{ !name(" master-name ")}"
header
TeX-region-extra
"\n\\message{ !name(" original ") !offset(")
(insert (int-to-string (- offset
(1+ (TeX-current-offset))))
") }\n"
region
"\n\\message{ !name(" master-name ") !offset(")
(insert (int-to-string (- trailer-offset
(1+ (TeX-current-offset))))
") }\n"
trailer)
(run-hooks 'TeX-region-hook)
(if (string-equal (buffer-string) original-content)
(set-buffer-modified-p nil)
(save-buffer 0)))))
(let ((inhibit-read-only t))
(erase-buffer)
(when (boundp 'buffer-file-coding-system)
(setq buffer-file-coding-system
(with-current-buffer master-buffer buffer-file-coding-system)))
(insert "\\message{ !name(" master-name ")}"
header
TeX-region-extra
"\n\\message{ !name(" original ") !offset(")
(insert (int-to-string (- offset
(1+ (TeX-current-offset))))
") }\n"
region
"\n\\message{ !name(" master-name ") !offset(")
(insert (int-to-string (- trailer-offset
(1+ (TeX-current-offset))))
") }\n"
trailer)
(run-hooks 'TeX-region-hook)
(if (string-equal (buffer-string) original-content)
(set-buffer-modified-p nil)
(save-buffer 0))))))

(defun TeX-region-file (&optional extension nondirectory)
"Return TeX-region file name with EXTENSION.
Expand Down

0 comments on commit 15edd9b

Please sign in to comment.