unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* hyperlinks in variable's value - links to libraries
@ 2006-01-01 21:19 Drew Adams
  2006-01-06  3:23 ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2006-01-01 21:19 UTC (permalink / raw)


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"))

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-01-09  1:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-01 21:19 hyperlinks in variable's value - links to libraries Drew Adams
2006-01-06  3:23 ` Drew Adams
2006-01-06  4:44   ` Stefan Monnier
2006-01-06  9:14     ` Lennart Borgman
2006-01-06 17:10     ` Drew Adams
2006-01-09  1:35       ` Stefan Monnier
2006-01-06  4:47   ` Nick Roberts
2006-01-06 17:10     ` Drew Adams
2006-01-06 22:35       ` Nick Roberts
2006-01-07  1:01         ` Drew Adams
2006-01-07  2:14           ` Nick Roberts
2006-01-07 15:38             ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).