* David Kastrup (2005-05-06) writes:
> Ralf Angeli <[EMAIL PROTECTED]> writes:
>
>> Look, I am arguing from a user's point of view, not from an
>> application's point of view.
>>
>>> This has been the behavior for AUCTeX from ancient history to 11.13 or
>>> so, and nobody complained worth noting.
>>
>> Not an argument.
>
> Decide yourself. If you are talking about the user's point of view,
> it is absurd to discard user feedback as "not an argument".
That's not what I did. I discarded non(!)-feedback as "not an
argument".
Anyway, we still need to solve the problem of the master file question
not being asked in the 'shared case. With the current implementation
I'd probably just ask the question at when the file is loaded. This
can be achieved by the following change:
--- tex.el 6 May 2005 15:48:42 -0000 5.510
+++ tex.el 6 May 2005 17:01:04 -0000
@@ -2247,7 +2247,8 @@
(make-local-hook 'find-file-hooks))
(add-hook 'find-file-hooks (lambda ()
;; Test if we are looking at a new file.
- (unless (file-exists-p (buffer-file-name))
+ (when (or (not (file-exists-p
(buffer-file-name)))
+ (eq TeX-master 'shared))
(TeX-master-file nil nil t))
(TeX-update-style t)) nil t))
Putting aside the problem with incorrect font locking, this might not
be the optimal solution overall because the question will be asked
without this being actually necessary, but with the current
implementation it is the best I can come up with.
While I dislike the solution used until AUCTeX 11.14 for the reasons
explained earlier, I wanted to have a look at it nevertheless both as
a possible basis for a better implementation and for working with an
alternative approach which would better support the 'shared case. And
while this feels to me like laying a gun in the hand of somebody else,
you can find a patch reverting the implementation to 11.14 attached to
this mail.
Some remarks. As mentioned earlier, the dynamic parts of the menus
are now implemented with menu filters. Contrary to what we discussed
earlier, the filter functions will be called as soon as
`easy-menu-add' is executed which means _very_ early during mode
setup. So after applying the patch, loading a LaTeX file won't work
correctly anymore. While playing with it, I saw the strangest errors,
like ending up in fundamental mode or getting a backtrace about trying
to use a menu from within a menu-entry. You should be able to
reproduce the latter by executing
emacs -Q -eval "(progn (setq debug-on-error t) (require 'tex-site) (setq
TeX-auto-save t) (setq TeX-parse-self t) (setq-default TeX-master nil))"
nonexistent.tex
Also one will be able to see again the GTK file chooser popping up
even when files are loaded by keyboard commands as discussed 1.5 years
ago in <URL:http://thread.gmane.org/gmane.emacs.auc-tex/1137>.
I am not sure if it is an Emacs bug that the menu filters are called
during menu creation. Maybe somebody else can shed some light on
this.
--
Ralf
Index: tex.el
===================================================================
RCS file: /cvsroot/auctex/auctex/tex.el,v
retrieving revision 5.510
diff -u -r5.510 tex.el
--- tex.el 6 May 2005 15:48:42 -0000 5.510
+++ tex.el 6 May 2005 17:28:27 -0000
@@ -1183,34 +1183,8 @@
(stringp TeX-master)))
(return (with-current-buffer buf TeX-master))))))
-(defun TeX-master-file-ask ()
- "Ask for master file, set `TeX-master' and add local variables."
- (interactive)
- (if (TeX-local-master-p)
- (error "Master file already set")
- (setq TeX-master
- (let ((default (TeX-dwim-master)))
- (or
- (and (eq 'dwim TeX-master) default)
- (TeX-strip-extension
- (condition-case name
- (read-file-name (format "Master file: (default %s) "
- (or default "this file"))
- nil (or default "<default>"))
- (quit "<quit>"))
- (list TeX-default-extension)
- 'path))))
- (cond ((string-equal TeX-master "<quit>")
- (setq TeX-master t))
- ((or (string-equal TeX-master "<default>")
- (string-equal TeX-master ""))
- (setq TeX-master t)
- (TeX-add-local-master))
- (t
- (TeX-add-local-master)))))
-
-(defun TeX-master-file (&optional extension nondirectory ask)
- "Set and return the name of the master file for the current document.
+(defun TeX-master-file (&optional extension nondirectory)
+ "Return the name of the master file for the current document.
If optional argument EXTENSION is non-nil, add that file extension to
the name. Special value t means use `TeX-default-extension'.
@@ -1218,12 +1192,8 @@
If optional second argument NONDIRECTORY is non-nil, do not include
the directory.
-If optional third argument ASK is non-nil, ask the user for the
-name of master file if it cannot be determined otherwise.
-
Currently it will check for the presence of a ``Master:'' line in
the beginning of the file, but that feature will be phased out."
- (interactive)
(if (eq extension t)
(setq extension TeX-default-extension))
(let ((my-name (if (buffer-file-name)
@@ -1239,7 +1209,7 @@
(setq TeX-master t))
;; For files shared between many documents.
- ((and (eq 'shared TeX-master) ask)
+ ((eq 'shared TeX-master)
(setq TeX-master
(TeX-strip-extension
(let ((default (or (TeX-dwim-master) "this file")))
@@ -1267,12 +1237,32 @@
(TeX-add-local-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)))
-
+ (t
+ (setq TeX-master
+ (let ((default (TeX-dwim-master)))
+ (or
+ (and (eq 'dwim TeX-master) default)
+ (TeX-strip-extension
+ (condition-case name
+ (read-file-name (format "Master file: (default %s) "
+ (or default "this file"))
+ nil (or default "<default>"))
+ (quit "<quit>"))
+ (list TeX-default-extension)
+ 'path))))
+ (cond ((string-equal TeX-master "<quit>")
+ (setq TeX-master t))
+ ((or (string-equal TeX-master "<default>")
+ (string-equal TeX-master ""))
+ (setq TeX-master t)
+ (TeX-add-local-master))
+ (t
+ (TeX-add-local-master)))))))
+
+ (let ((name (if (eq TeX-master t)
+ my-name
+ TeX-master)))
+
(if (TeX-match-extension name)
;; If it already have an extension...
(if (equal extension TeX-default-extension)
@@ -1362,15 +1352,6 @@
(when (eq major-mode 'doctex-mode)
(insert "% " TeX-esc "fi\n"))))))
-(defun TeX-local-master-p ()
- "Return non-nil if there is a `TeX-master' entry in local variables spec.
-Return nil otherwise."
- (save-excursion
- ;; XXX: Checking -*- line necessary as well?
- (goto-char (point-max))
- (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move)
- (re-search-forward "^%+ *TeX-master:" nil t)))
-
;;; Style Paths
(defcustom TeX-style-global (expand-file-name "style" TeX-data-directory)
@@ -2227,29 +2208,7 @@
(add-hook 'local-write-file-hooks 'TeX-safe-auto-write)
(add-hook 'write-file-hooks 'TeX-safe-auto-write))
(make-local-variable 'TeX-auto-update)
- (setq TeX-auto-update t)
-
- ;; Let `TeX-master-file' be called after a new file was opened and
- ;; call `TeX-update-style' on any file opened. (The addition to the
- ;; hook has to be made here because its local value will be deleted
- ;; by `kill-all-local-variables' if it is added e.g. in `tex-mode'.)
- ;;
- ;; `TeX-update-style' has to be called before
- ;; `global-font-lock-mode', which may also be specified in
- ;; `find-file-hooks', gets called. Otherwise style-based
- ;; fontification will break (in XEmacs). That means, `add-hook'
- ;; cannot be called with a non-nil value of the APPEND argument.
- ;;
- ;; `(TeX-master-file nil nil t)' has to be called *before*
- ;; `TeX-update-style' as the latter will call `TeX-master-file'
- ;; without the `ask' bit set.
- (if (= emacs-major-version 20)
- (make-local-hook 'find-file-hooks))
- (add-hook 'find-file-hooks (lambda ()
- ;; Test if we are looking at a new file.
- (unless (file-exists-p (buffer-file-name))
- (TeX-master-file nil nil t))
- (TeX-update-style t)) nil t))
+ (setq TeX-auto-update t))
;;; Plain TeX mode
@@ -3255,9 +3214,6 @@
(define-key map "\C-c\C-w" 'TeX-toggle-debug-boxes)
;; From tex-fold.el
(define-key map "\C-c\C-o\C-f" 'TeX-fold-mode)
-
- ;; Multifile
- (define-key map "\C-c_" 'TeX-master-file-ask) ;*** temporary
map)
"Keymap for common TeX and LaTeX commands.")
@@ -3422,9 +3378,6 @@
:help "Switch to buffer of Master File, or buffer of last TeX command"]
["Save Document" TeX-save-document
:help "Save all buffers associated with the current Master File"]
- ["Set Master File" TeX-master-file-ask
- :active (not (TeX-local-master-p))
- :help "Set the main file to run TeX commands on"]
["Reset Buffer" TeX-normal-mode
:help "Save and reparse the current buffer for style information"]
["Reset AUCTeX" (TeX-normal-mode t) :keys "C-u C-c C-n"
_______________________________________________
auctex-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex-devel