From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual
Date: Tue, 05 Jun 2018 21:51:17 +0200 [thread overview]
Message-ID: <87lgbtm2q2.fsf@gmail.com> (raw)
In-Reply-To: 83tvqh9sqp.fsf@gnu.org
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 <rpluim@gmail.com>
* lisp/textmodes/texinfo.el (texinfo-insert-dwim-@ref): New
function. Insert appropriate type of reference based on
surrounding text.
(texinfo-mode-map): Add binding for texinfo-insert-dwim-@ref.
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}.
\f
* Changes in Specialized Modes and Packages in Emacs 27.1
+** Texinfo
+*** New function for inserting @pxref, @xref, or @ref commands.
+The function 'texinfo-insert-dwim-@ref', 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" 'texinfo-insert-@uref)
(define-key map "\C-c\C-ct" 'texinfo-insert-@table)
(define-key map "\C-c\C-cs" 'texinfo-insert-@samp)
+ (define-key map "\C-c\C-cr" 'texinfo-insert-dwim-@ref)
(define-key map "\C-c\C-cq" 'texinfo-insert-@quotation)
(define-key map "\C-c\C-co" 'texinfo-insert-@noindent)
(define-key map "\C-c\C-cn" 'texinfo-insert-@node)
@@ -825,6 +826,36 @@ texinfo-insert-@quotation
"Insert the string `@quotation' in a Texinfo buffer."
\n "@quotation" \n _ \n)
+(define-skeleton texinfo-insert-dwim-@ref
+ "Insert appropriate `@pxref{...}', `@xref{}', or `@pef{}' 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 texinfo-insert-@samp
"Insert a `@samp{...}' command in a Texinfo buffer.
A numeric argument says how many words the braces should surround.
next prev parent reply other threads:[~2018-06-05 19:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 7:33 bug#31636: 27.0.50; lockfile syntax searchable from info manual Brady Trainor
2018-05-29 8:40 ` Robert Pluim
2018-05-29 11:24 ` Noam Postavsky
2018-05-29 13:17 ` Robert Pluim
2018-05-29 16:46 ` Eli Zaretskii
2018-05-29 19:06 ` Robert Pluim
2018-05-30 2:42 ` Eli Zaretskii
2018-05-31 10:29 ` Robert Pluim
2018-06-01 8:52 ` Eli Zaretskii
2018-06-01 10:47 ` Robert Pluim
2018-06-01 13:00 ` Eli Zaretskii
2018-06-01 13:24 ` Robert Pluim
2018-06-01 13:25 ` Robert Pluim
2018-06-01 13:42 ` Robert Pluim
2018-06-04 9:41 ` Robert Pluim
2018-06-04 10:39 ` Andreas Schwab
2018-06-04 14:02 ` Robert Pluim
2018-06-04 16:06 ` Eli Zaretskii
2018-06-04 15:55 ` Eli Zaretskii
2018-06-04 17:17 ` Robert Pluim
2018-06-05 15:07 ` Eli Zaretskii
2018-06-05 19:51 ` Robert Pluim [this message]
2018-06-05 20:08 ` Noam Postavsky
2018-06-06 7:43 ` Robert Pluim
2018-06-06 13:13 ` Noam Postavsky
2018-06-06 13:51 ` Robert Pluim
2018-06-06 14:41 ` Noam Postavsky
2018-06-06 14:51 ` Robert Pluim
2018-05-29 19:20 ` Paul Eggert
2018-05-30 2:42 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lgbtm2q2.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.