From: Stefan Kangas Date: Mon, 9 Dec 2024 03:01:44 +0000 (+0100) Subject: Make setting tex-dvi-view-command to an sexp obsolete X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fb05493204c7268484dd441b22c09da6260bdfe7;p=emacs.git Make setting tex-dvi-view-command to an sexp obsolete This is more in line with how we generally handle user options for commands to call. Later, we can get rid of the 'eval' call. * lisp/textmodes/tex-mode.el (tex-view): Warn if tex-dvi-view-command is set to an sexp instead of a string; say that this use is obsolete. (tex-dvi-view-command): Change the default value to a string. Update docstring to reflect the above obsoletion. (cherry picked from commit 9b4af418ddc3328c8756f3ca21ba25f161c65b65) --- diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 65ad12ec5ec..21593733e1b 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -199,17 +199,17 @@ use." ;;;###autoload (defcustom tex-dvi-view-command - `(cond - ((eq window-system 'x) ,(purecopy "xdvi")) - ((eq window-system 'w32) ,(purecopy "yap")) - (t ,(purecopy "dvi2tty * | cat -s"))) + (cond ((eq window-system 'x) (purecopy "xdvi")) + ((eq window-system 'w32) (purecopy "yap")) + (t (purecopy "dvi2tty * | cat -s"))) "Command used by \\[tex-view] to display a `.dvi' file. -If it is a string, that specifies the command directly. If this string contains an asterisk (`*'), that is replaced by the file name; otherwise, the file name, preceded by a space, is added at the end. -If the value is a form, it is evaluated to get the command to use." - :type '(choice (const nil) string sexp) +For backwards-compatibility, the value can also be a form, in which case +it is evaluated to get the command to use. This is now obsolete, and +will lead to a warning. Set it to a string instead." + :type '(choice (const nil) string) :risky t :group 'tex-view) @@ -2751,6 +2751,7 @@ Runs the shell command defined by `tex-alt-dvi-print-command'." (interactive) (tex-print t)) +(defvar tex-view--warned-once nil) (defun tex-view () "Preview the last `.dvi' file made by running TeX under Emacs. This means, made using \\[tex-region], \\[tex-buffer] or \\[tex-file]. @@ -2763,7 +2764,14 @@ because there is no standard value that would generally work." ;; Restart the TeX shell if necessary. (or (tex-shell-running) (tex-start-shell)) - (let ((tex-dvi-print-command (eval tex-dvi-view-command t))) + (let ((tex-dvi-print-command + (if (stringp tex-dvi-view-command) + tex-dvi-view-command + (unless tex-view--warned-once + (warn (concat "Setting `tex-dvi-view-command' to an S-expression" + " is obsolete since Emacs " "31.1")) + (setq tex-view--warned-once t)) + (eval tex-dvi-view-command t)))) (tex-print))) (defun tex-append (file-name suffix)