help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: interactive interface to supply variables


From: Emanuel Berg
Subject: Re: interactive interface to supply variables
Date: Sun, 15 Dec 2013 01:09:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

This proved to be not so easy as I thought.

I installed emacs24-el and in help-fns.el I saw how
they did it in `describe-variable' - this is a
variation of their method, only, to determine if it is
a variable, they use

(or (get vv 'variable-documentation)
    (and (boundp vv)
         (not (keywordp vv)))))

while I use `boundp' only - I don't know what
`keywordp' brings. However, `boundp' isn't optimal for
unbounded variables (of course) - in those cases, it
should be communicated that there is such a variable,
only it isn't bound. `symbolp' perhaps in combination
with something else (because sumbolp is too inclusive).

Anyway, check it out.

(defun describe-variable-short (var)
  (interactive
   (let*((v            (variable-at-point))
         (var-at-point (not (eq v 0)))
         (v-name       (if var-at-point (symbol-name v)))
         (v-final
          (completing-read
           ;; prompt
           (format " Variable%s: " (if var-at-point
                                       (format " (default %s)" v)
                                       ""))
           obarray                   ; from this set (all objects?)
           (lambda (vv) (boundp vv)) ; delimit set
           t                         ; require match
           nil                       ; no insert to minibuffer (?)
           nil                       ; no history
           v-name                    ; default
          )))
   `(,(intern v-final))))
  (message (format " %s: %s" (symbol-name var) (symbol-value var))) )
(global-set-key "\C-hV" 'describe-variable-short)

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


reply via email to

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