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

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

RE: [External] : Re: help doesn't buttonize some functions


From: Drew Adams
Subject: RE: [External] : Re: help doesn't buttonize some functions
Date: Fri, 27 Aug 2021 05:52:25 +0000

> 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: winmail.dat>>


reply via email to

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