David Kastrup <[EMAIL PROTECTED]> writes:
> Ralf Angeli <[EMAIL PROTECTED]> writes:
>
>> * David Kastrup (2005-05-21) writes:
>>
>>> Ralf Angeli <[EMAIL PROTECTED]> writes:
>>>>
>>>> (TeX-PDF-mode): Run `TeX-PDF-mode-hook'.
>>>
>>> Uh, doesn't define-minor-mode already cater for that?
>>
>> The minor mode function defined by `define-minor-mode' is
>> overwritten by our own. That means our function has to run the hook
>> itself.
>
> Seems a bit braindead, but I should probably not be the one
> complaining about it, having written it myself. I am not sure that
> the technical necessity for having this function take an extra
> argument is still the same as at the time I came up with it, but we
> probably have enough other stuff to worry about.
Ok, to follow up on myself:
Whenever some 50 line functionality I write requires about 5 mails of
explanation until "well, ok, maybe it could work" is the result of the
discussion, the code is obviously unfit for maintenance. Feel free to
quote this at me when I forget it. Which I do quite often.
Since my AUCTeX is at the moment in a complete state of flux, I have
not been able to actually test the following patch, but I think it is
quite saner than the original. The only problem I still see with it
is that "TeX-PDF-mode-on" should really be "TeX-PDF-mode-parsed-on"
and vice versa in order not to confuse people into using it.
If nobody has an objection, I'll check it in. Even though it is late
in the run, the old code does not make sense. And I am afraid that I
still have more invasive stuff to finish in preview-latex, so there
will have to be more testing, anyway.
--- tex.el 16 May 2005 11:28:42 +0200 5.516
+++ tex.el 22 May 2005 14:43:07 +0200
@@ -1029,7 +1029,13 @@
If enabled, PDFTeX will be used as an executable by default.
You can customize an initial value, and you can use the
function `TeX-global-PDF-mode' for toggling this value."
- :group 'TeX-command)
+ :group 'TeX-command
+ (when TeX-Omega-mode
+ (setq TeX-PDF-mode nil))
+ (setq TeX-PDF-mode-parsed nil)
+ (TeX-set-mode-name nil nil t)
+ (setq TeX-output-extension
+ (if TeX-PDF-mode "pdf" "dvi")))
(defun TeX-global-PDF-mode (&optional arg)
"Toggle default for `TeX-PDF-mode'."
@@ -1040,53 +1046,39 @@
(not (default-value 'TeX-PDF-mode))))
(TeX-set-mode-name 'TeX-PDF-mode nil t)))
-(defun TeX-PDF-mode (&optional arg parsed)
- "Toggles PDF mode.
-Interactive ARG if positive switches on, non-positive off.
-
-If PARSED is non-nil, buffer-local values of `TeX-PDF-mode' will not
-get overwritten.
-If the current value was parsed and conflicts with the new value,
-the default will be used instead.
+(defalias 'tex-pdf-mode 'TeX-PDF-mode)
+
+(defvar TeX-PDF-mode-parsed nil
+ "Set if `TeX-PDF-mode' has come about by parsing.")
+
+(make-variable-buffer-local 'TeX-PDF-mode-parsed)
+
+(defun TeX-PDF-mode-parsed (arg)
+ "Change `TeX-PDF-mode' to ARG based on parsing.
+If this conflicts with previous parsed settings,
+just use the default. If an explicit setting is
+already established, don't do anything."
-See `TeX-global-PDF-mode' for toggling the default value."
;; Basically we have the following situations:
;; TeX-PDF-mode-parsed (local-variable-p 'TeX-PDF-mode):
;; nil nil : virgin state
-;; t nil : conflicting parsed info -> use default.
-;; nil t : stably set state
+;; nil t : stably set state (possibly because of conflicting parse info)
;; t t : non-conflicting parsed info
- (interactive "P")
- (if TeX-Omega-mode
- (setq parsed nil arg nil)
- (setq arg (if arg (> (prefix-numeric-value arg) 0)
- (not TeX-PDF-mode))))
- (if parsed
- (if TeX-PDF-mode-parsed
- (unless (eq TeX-PDF-mode arg)
- (kill-local-variable 'TeX-PDF-mode))
- (unless (local-variable-p 'TeX-PDF-mode (current-buffer))
- (setq TeX-PDF-mode-parsed t
- TeX-PDF-mode arg)))
- (if TeX-PDF-mode-parsed
- (setq TeX-PDF-mode-parsed nil))
- (setq TeX-PDF-mode arg))
- (TeX-set-mode-name nil nil t)
- (setq TeX-output-extension
- (if TeX-PDF-mode "pdf" "dvi"))
- TeX-PDF-mode)
-(defalias 'tex-pdf-mode 'TeX-PDF-mode)
+ (if TeX-PDF-mode-parsed
+ (unless (eq TeX-PDF-mode arg)
+ (TeX-PDF-mode (if (default-value 'TeX-PDF-mode) 1 0)))
+ (unless (local-variable-p 'TeX-PDF-mode (current-buffer))
+ (TeX-PDF-mode (if arg 1 0))
+ (setq TeX-PDF-mode-parsed t))))
+
(defun TeX-PDF-mode-on ()
- (TeX-PDF-mode 1 t))
+ "Use only from parsing routines."
+ (TeX-PDF-mode-parsed t))
(defun TeX-PDF-mode-off ()
- (TeX-PDF-mode 0 t))
-
-(defvar TeX-PDF-mode-parsed nil
- "Set if `TeX-PDF-mode' has come about by parsing.")
-
-(make-variable-buffer-local 'TeX-PDF-mode-parsed)
+ "Use only from parsing routines."
+ (TeX-PDF-mode-parsed nil))
(defcustom TeX-DVI-via-PDFTeX nil
"Whether to use PDFTeX also for producing DVI files."
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
_______________________________________________
auctex-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex-devel