emacs-devel
[Top][All Lists]
Advanced

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

Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual


From: Robert Pluim
Subject: Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual
Date: Tue, 05 Jun 2018 21:51:17 +0200

Latest version attached. I now limit the skip-syntax-backward to the
current line.

I have no idea how it was working correctly before, unless I somehow
managed to mess up the syntax table in my texinfo buffer (or more
likely I tested in a non-texinfo buffer). Testing appreciated.

((char-syntax (char-before)) at bol is '?>' in texinfo mode, which is
somewhat surprising, since it's '? ' in text mode)

Since the texinfo mode info documentation is part of the texinfo
package, Iʼll need to send them a patch as well.

2018-06-05  Robert Pluim  <address@hidden>

        * lisp/textmodes/texinfo.el (address@hidden): New
        function. Insert appropriate type of reference based on
        surrounding text.
        (texinfo-mode-map): Add binding for address@hidden

diff --git i/etc/NEWS w/etc/NEWS
index 01dcb441a7..a06bd442c2 100644
--- i/etc/NEWS
+++ w/etc/NEWS
@@ -171,6 +171,13 @@ interface that's more like functions like 
@code{search-forward}.

 * Changes in Specialized Modes and Packages in Emacs 27.1
 
+** Texinfo
+*** New function for inserting @pxref, @xref, or @ref commands.
+The function 'address@hidden', bound to 'C-c C-c r' by
+default, inserts one of three types of references based on the text
+surrounding point, namely @pxref after a parenthesis, @xref at the
+start of a sentence, else @ref.
+
 ** Browse-url
 *** The function 'browse-url-emacs' can now visit a URL in selected window.
 It now treats the optional 2nd argument to mean that the URL should be
diff --git i/lisp/textmodes/texinfo.el w/lisp/textmodes/texinfo.el
index ff723a4fb9..67333ddcf2 100644
--- i/lisp/textmodes/texinfo.el
+++ w/lisp/textmodes/texinfo.el
@@ -470,6 +470,7 @@ texinfo-mode-map
     (define-key map "\C-c\C-cu"    'address@hidden)
     (define-key map "\C-c\C-ct"    'address@hidden)
     (define-key map "\C-c\C-cs"    'address@hidden)
+    (define-key map "\C-c\C-cr"    'address@hidden)
     (define-key map "\C-c\C-cq"    'address@hidden)
     (define-key map "\C-c\C-co"    'address@hidden)
     (define-key map "\C-c\C-cn"    'address@hidden)
@@ -825,6 +826,36 @@ address@hidden
   "Insert the string address@hidden' in a Texinfo buffer."
   \n "@quotation" \n _ \n)
 
+(define-skeleton address@hidden
+  "Insert appropriate address@hidden', address@hidden', or address@hidden' 
command.
+Looks at text around point to decide what to insert; point after
+a parenthesis results in '@pxref{}', at the beginning of a
+sentence 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 "\(")
+    "@pxref{")
+   ;; beginning of sentence
+   ((looking-back (sentence-end))
+    "@xref{")
+   ;; bol or eol
+   ((looking-at "^\\|$")
+    "@ref{")
+   ;; inside word
+   ((not (eq (char-syntax (char-after)) ? ))
+    (skip-syntax-backward "^ " (point-at-bol))
+    "@ref{")
+   ;; everything else
+   (t
+    "@ref{"))
+  _ "}")
+
 (define-skeleton address@hidden
   "Insert a address@hidden' command in a Texinfo buffer.
 A numeric argument says how many words the braces should surround.



reply via email to

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