[Top][All Lists]

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

Re: Multi-tty design (Re: Reordering etc/NEWS)

From: David Kastrup
Subject: Re: Multi-tty design (Re: Reordering etc/NEWS)
Date: Wed, 23 May 2007 21:24:49 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

Richard Stallman <address@hidden> writes:

>     An empty string, perhaps.  I severely doubt that most loops through
>     process-environment will be prepared to encounter a non-string
>     argument (doing string-match on all encountered elements would be sort
>     of a natural operation).  An empty string, in contrast, would probably
>     not do much harm, I suppose.
> If there are many such loops, and changing them would be hard, this
> might be an important factor.

The problem is that such loops are the _obvious_ thing for
manipulating process-environment.  So we need not only bother about
code inside of Emacs, but also in external packages.

For example, AUCTeX contains

(defun preview-set-texinputs (&optional remove)
  "Add `preview-TeX-style-dir' into `TEXINPUTS' variables.
With prefix argument REMOVE, remove it again."
  (interactive "P")
  (let ((case-fold-search nil)
        (preview-TeX-style-dir (preview-TeX-style-cooked))
    (if remove
          (setq pattern (concat "\\`\\(TEXINPUTS[^=]*\\)=\\(.*\\)"
                                (regexp-quote preview-TeX-style-dir)))
          (dolist (env (copy-sequence process-environment))
            (if (string-match pattern env)
                (setenv (match-string 1 env)
                        (and (or (< (match-beginning 2) (match-end 2))
                                 (< (match-end 0) (length env)))
                             (concat (match-string 2 env)
                                     (substring env (match-end 0))))))))
      (setq pattern (regexp-quote preview-TeX-style-dir))
      (dolist (env (cons "TEXINPUTS=" (copy-sequence process-environment)))
        (if (string-match "\\`\\(TEXINPUTS[^=]*\\)=" env)
            (unless (string-match pattern env)
              (setenv (match-string 1 env)
                      (concat preview-TeX-style-dir
                              (substring env (match-end 0))))))))))

This will throw an error if process-environment contains non-strings.
I would not consider this untypical or unnatural.

> Otherwise, we should do the cleanest thing, and use nil, and change
> those loops.

If code has to specifically cater for nil, pretty much the whole point
of the shared tail construct (namely not having to change existing
code) is gone.  We could then equally well just have two separate
variables for the shared and separate parts of the environment.

David Kastrup, Kriemhildstr. 15, 44793 Bochum

reply via email to

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