[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
hyperlinks in variable's value - links to libraries
From: |
Drew Adams |
Subject: |
hyperlinks in variable's value - links to libraries |
Date: |
Sun, 1 Jan 2006 13:19:50 -0800 |
Between April and June 2005, the code in help-fns.el that defines
`describe-variable' had this line commented out, with this comment:
;; Hyperlinks in variable's value are quite frequently
;; inappropriate e.g C-h v <RET> features <RET>
;; (help-xref-on-pp from (point))
mea culpa - I think I might have been the one to report the bug that the
links in the value of `features' were inappropriate. What I said, however,
was that they should instead be links to the libraries, not links to
something else that happened to have the same name as a library (which was
the "inappropriate" part).
In any case, I disagree with the "fix" of commenting out this line - at the
least, I would like such links to be an option.
In fact, I have a tiny library that does only this: add links to libraries.
This is the entire library (below). I'd suggest it or the equivalent as a
patch. However, adding such links can be slow, so I would like to see an
option for adding links to libraries.
Although it can be slow, it is very useful: if you're checking `features',
for instance (though this is not the only place such links would appear),
you want to know not only if a given library has been loaded, but you (I, at
least) sometimes want to then open one of those libraries. IOW, looking at
`features' should be an entry point to accessing the features listed.
Needless to say, if `describe-variable' is not changed back by uncommenting
that line, I'll also need to add a redefinition of `describe-variable' to my
little library...
---8<--------------------
;; REPLACES ORIGINAL IN `help-mode.el'.
;; Buttonizes names of libraries also.
;; To see the effect, try `C-h v features', and click on a library name.
;;
(defun help-xref-on-pp (from to)
"Add xrefs for symbols in `pp's output between FROM and TO."
(if (> (- to from) 5000) nil
(with-syntax-table emacs-lisp-mode-syntax-table
(save-excursion
(save-restriction
(narrow-to-region from to)
(goto-char (point-min))
(condition-case nil
(while (not (eobp))
(cond
((looking-at "\"") (forward-sexp 1))
((looking-at "#<") (search-forward ">" nil 'move))
((looking-at "\\(\\(\\sw\\|\\s_\\)+\\)")
(let* ((sym (intern-soft (match-string 1)))
(type (cond ((fboundp sym) 'help-function)
((or (memq sym '(t nil))
(keywordp sym))
nil)
((and sym (boundp sym))
'help-variable)
((and sym (locate-library (symbol-name
sym)))
'help-library))))
(when type (help-xref-button 1 type sym)))
(goto-char (match-end 1)))
(t (forward-char 1))))
(error nil)))))))
(define-button-type 'help-library
:supertype 'help-xref
'help-function #'(lambda (x) (find-library (symbol-name x)))
'help-echo (purecopy "mouse-2, RET: find this library"))
- hyperlinks in variable's value - links to libraries,
Drew Adams <=