Function: texinfo-insert-dwim-@ref
texinfo-insert-dwim-@ref is an interactive and byte-compiled function
defined in texinfo.el.gz.
Signature
(texinfo-insert-dwim-@ref &optional STR ARG)
Documentation
Insert appropriate @pxref{...}, @xref{}, or @ref{} command.
Looks at text around point to decide what to insert; an unclosed preceding open parenthesis results in '@pxref{}', point at the beginning of a sentence or at (point-min) yields '@xref{}', any other location (including inside a word), will result in '@ref{}' at the nearest previous whitespace or beginning-of-line. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces.
This is a skeleton command (see skeleton-insert).
Normally the skeleton text is inserted at point, with nothing "inside".
If there is a highlighted region, the skeleton text is wrapped
around the region text.
A prefix argument ARG says to wrap the skeleton around the next ARG words. A prefix argument of -1 says to wrap around region, even if not highlighted. A prefix argument of zero says to wrap around zero words---that is, nothing. This is a way of overriding the use of a highlighted region.
Probably introduced at or before Emacs version 27.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/texinfo.el.gz
(define-skeleton texinfo-insert-dwim-@ref
"Insert appropriate `@pxref{...}', `@xref{}', or `@ref{}' command.
Looks at text around point to decide what to insert; an unclosed
preceding open parenthesis results in '@pxref{}', point at the
beginning of a sentence or at (point-min) yields '@xref{}', any
other location (including inside a word), will result in '@ref{}'
at the nearest previous whitespace or beginning-of-line. A
numeric argument says how many words the braces should surround.
The default is not to surround any existing words with the
braces."
nil
(cond
;; parenthesis
((looking-back "([^)]*" (line-beginning-position 0))
"@pxref{")
;; beginning of sentence or buffer
((or (looking-back (sentence-end) (line-beginning-position 0))
(= (point) (point-min)))
"@xref{")
;; bol or eol
((looking-at "^\\|$")
"@ref{")
;; inside word
((not (eq (char-syntax (char-after)) ? ))
(skip-syntax-backward "^ " (line-beginning-position))
"@ref{")
;; everything else
(t
"@ref{"))
_ "}")