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: Mon, 04 Jun 2018 11:41:24 +0200

>>>> (I noticed that texinfo.el has no bindings for inserting @ref,
>>>> @xref, and @pxref, should I add some?  C-cC-c[rp] are free, but x is
>>>> already used for @example, so 'C-cC-cX'? Or maybe 'C-cC-cC-x' for
>>>> @xref?)
>>>
>>> How about using just "C-c C-c r" and letting it intuit the exact form
>>> from the context?  @xref is only used at the beginning of a sentence,
>>> and @pxref should normally follow an open paren.
>>>
>>
>> OK. Iʼll think about how best to add that.

Hereʼs a simple implementation, no doubt Iʼve missed some corner cases.

diff --git i/lisp/textmodes/texinfo.el w/lisp/textmodes/texinfo.el
index c2ceee6e6b..b696b81c1c 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)
@@ -826,6 +827,31 @@ 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
+in a Texinfo buffer depending on surrounding context.
+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
+   ;; parenthetical
+   ((looking-back "\(")
+    "@pxref{")
+   ;; beginning of sentence
+   ((looking-back "  ")
+    "@xref{")
+   ;; bol or eol
+   ((looking-at "^\\|$")
+    "@ref{")
+   ;; inside word
+   ((not (eq (char-syntax (char-after)) ? ))
+    (skip-syntax-backward "^ ")
+    "@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]