unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* RE: [External] : Re: help doesn't buttonize some functions
@ 2021-08-27  5:52 Drew Adams
  2021-08-27  6:19 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2021-08-27  5:52 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 2489 bytes --]

> Maybe some regexp somewhere where functions that contain
> non-alphanums aren't buttonized?
> 
> E.g., `string=' isn't buttonized

Yes, it is.

Quoted names beginning with non-word chars aren't
buttonized.  Other names are.

The fault (but by design, I'm sure) is with this
variable defined in `help-mode.el':

(defconst help-xref-symbol-regexp
  (purecopy (concat "\\(\\<\\(\\(variable\\|option\\)\\|"  ; Link to var
 		    "\\(function\\|command\\|call\\)\\|"   ; Link to function
 		    "\\(face\\)\\|"			   ; Link to face
 		    "\\(symbol\\|program\\|property\\)\\|" ; Don't link
		    "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)"
		    "[ \t\n]+\\)?"
		    ;; Note starting with word-syntax character:
		    "['`']\\(\\sw\\(\\sw\\|\\s_\\)+\\|`\\)['']"))
  "Regexp matching doc string references to symbols.

The words preceding the quoted symbol can be used in doc strings to
distinguish references to variables, functions and symbols.")

This is the culprit - it says that the quoted name
must begin with a word-constituent char (\sw):

 ;; Note starting with word-syntax character:
 "['`']\\(\\sw\\(\\sw\\|\\s_\\)+\\|`\\)['']"
          ^^^^

You need to change that to this (and remove the call
to `purecopy'):

 "['`']\\(\\(\\sw\\|\\s_\\)+\\|`\\)['']"

But first `M-x load-library help-mode.el' (not .elc),
then redefine var `help-xref-symbol-regexp' as above.

You can use setq or defconst - doesn't matter:

(setq help-xref-symbol-regexp
      (concat "\\(\\<\\(\\(variable\\|option\\)\\|"	 ; Link to var
 	      "\\(function\\|command\\|call\\)\\|" ; Link to function
 	      "\\(face\\)\\|"			   ; Link to face
 	      "\\(symbol\\|program\\|property\\)\\|" ; Don't link
	      "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)"
	      "[ \t\n]+\\)?"
	      ;; Note starting with word-syntax character:
	      "['`']\\(\\(\\sw\\|\\s_\\)+\\|`\\)['']"))

Then you can test with this:

(defun test-fun ()
  "`=foo' is not `foo=' or `string='." )
(defun =foo () "EEEEEEEEEEEEEE" 42)
(defun foo= () "OOOOOOOOOOOOOO" "42")

Then `C-h f test-fun' buttonizes all of those.

This is using the Emacs 27.2 version of that var.
Other Emacs versions use different regexps for it,
but they all insist that the function, variable,
etc. name start with a word-constituent char.

The likely reason is that otherwise stuff gets
buttonized that shouldn't be.  IOW, starting with
a word char is a heuristic/trade-off.


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14031 bytes --]

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

end of thread, other threads:[~2021-08-31  8:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-27  5:52 [External] : Re: help doesn't buttonize some functions Drew Adams
2021-08-27  6:19 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-27  6:39   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-27 16:10   ` Drew Adams
2021-08-28  1:55     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-28  4:14       ` Drew Adams
2021-08-31  8:01       ` Emanuel Berg via Users list for the GNU Emacs text editor

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