emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/auctex 15edd9b 23/36: Omit f-f hooks and more with TeX-


From: Stefan Monnier
Subject: [elpa] externals/auctex 15edd9b 23/36: Omit f-f hooks and more with TeX-region-create
Date: Fri, 28 Nov 2014 17:25:48 +0000

branch: externals/auctex
commit 15edd9b6047f7cdd46081f99226805dbd7625599
Author: Tassilo Horn <address@hidden>
Date:   Tue Nov 18 09:33:28 2014 +0100

    Omit f-f hooks and more with TeX-region-create
    
    * 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).
---
 ChangeLog  |    9 +++++++++
 tex-buf.el |   55 ++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cf0acfd..e3cd0cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-11-18  Tassilo Horn  <address@hidden>
+
+       * 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  <address@hidden>
 
        * Makefile.in (WEMACSDATAROOTDIR, WEMACSSITELISP): New variables.
diff --git a/tex-buf.el b/tex-buf.el
index b6a3a31..3810ea9 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -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
@@ -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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]