From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: [PATCH] Implement texinfo @ref dwim Date: Tue, 05 Feb 2019 13:10:07 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="183291"; mail-complaints-to="usenet@blaine.gmane.org" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 05 13:13:47 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gqzbm-000lRY-Jy for ged-emacs-devel@m.gmane.org; Tue, 05 Feb 2019 13:13:46 +0100 Original-Received: from localhost ([127.0.0.1]:59037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqzbl-0005Jc-CB for ged-emacs-devel@m.gmane.org; Tue, 05 Feb 2019 07:13:45 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqzaH-0005Gz-RB for emacs-devel@gnu.org; Tue, 05 Feb 2019 07:12:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqzYK-0007Gz-Ui for emacs-devel@gnu.org; Tue, 05 Feb 2019 07:10:13 -0500 Original-Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:34477) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gqzYK-0007Gg-JF for emacs-devel@gnu.org; Tue, 05 Feb 2019 07:10:12 -0500 Original-Received: by mail-wm1-x332.google.com with SMTP id y185so12383494wmd.1 for ; Tue, 05 Feb 2019 04:10:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:mail-followup-to:mail-copies-to:gmane-reply-to-list :date:message-id:mime-version; bh=eSn29JBAkA2b32e+kFTJ0PeSm3/XCL2VXcf2HicFd7k=; b=Hky7ZcBkUFIwLM3CxHOCEi4W3GEujQG4KliugHQe+emxt/eY3vklQ4mXIMHxIzB1xw D7IJFaHDGSpICWfzDZibZH/8g8YP2zpz6Nv7TQdGcUo3zzLl63uQCawUnt26gRrNSg3q YC7VxFmHMgM7ICE8bnGMbFjLIldRlgQg0c48JxWh4OONNTTuQ2uvh627GXRB97uNN+xK Rm+IjDwadDHre9/McFsCcIXDYWEgEP5bMbpOPXx0j2wq7AYulz8fARXi/JnPSncLSuQj 8C8cKKaXHUAx7ZR9lrFjQ/mA7f7CFQXaL2r4YEFZI7BkJIF57P/2u5QUVZCNxqtdcdax Gztg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:mail-followup-to:mail-copies-to :gmane-reply-to-list:date:message-id:mime-version; bh=eSn29JBAkA2b32e+kFTJ0PeSm3/XCL2VXcf2HicFd7k=; b=BePltsxOu8LSDr+vZf+V7GDSe6MuLQHeQgvlQ8N+5zQ9BdTjX8o3ub6j0U5ZU0r2H0 2XLknA3mPOP2AR6Q4LcCGZED96elf53nvCp4NIeMZcMbNjJom9KQ+J6hNbE4kbbD3xHd f1awFG0GPr4vQGU8DwSNk6La8GPztg6Iq5sgZ0are43JeJd7JGGw1BKecn+Vn5xbQSfQ KiFlh4aXJ5CcVEswwc9DAbsQCDhZIfPjp0Gvwi9tm23KZMDMz6b8eca/OMLw03ttlhJm N7oLKseTnGo5xtmyirgcw4RJVGofZdUQFCtwdJFIiyJy9qbX25hmPnwdfo4YdCRine+T WQ7g== X-Gm-Message-State: AHQUAuY5qMZJXn7Fj5NwsDW3ptRTAuREXI2p7dnlSWrjw+Hfa4B+o+uV 1gYBLefpnJVjwqy7TrgRLz/jjdKP X-Google-Smtp-Source: AHgI3IZnPOoh8GDZ8xHj8c0NLzpYweuzbpMfEnvIFaDsrNi3lefhjpKmhUDKJuLUDiOMSbUExECJoQ== X-Received: by 2002:a1c:dd04:: with SMTP id u4mr3533277wmg.84.1549368609702; Tue, 05 Feb 2019 04:10:09 -0800 (PST) Original-Received: from rpluim-mac ([2a01:e34:ecfc:a860:1dc2:6257:c250:f8ca]) by smtp.gmail.com with ESMTPSA id h135sm18108999wmd.21.2019.02.05.04.10.07 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 05 Feb 2019 04:10:08 -0800 (PST) Mail-Followup-To: emacs-devel@gnu.org Mail-Copies-To: never Gmane-Reply-To-List: yes X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:232984 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This has been sitting around in my patch queue for a while, and I=CA=BCd like to get it in so I can also get the manual update into the texinfo project. I think I=CA=BCve addressed all the comments from the last time around. Robert --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-dwim-function-for-inserting-ref-variants.patch >From 808733302749552e7928af4e6125b026b5db1ddd Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 5 Feb 2019 10:49:09 +0100 Subject: [PATCH] Add dwim function for inserting @ref variants To: emacs-devel@gnu.org * lisp/textmodes/texinfo.el (texinfo-insert-dwim-@ref): New function. Insert @ref variant based on surrounding context. (texinfo-mode-map): Add binding for texinfo-insert-dwim-@ref. * etc/NEWS: Describe new texinfo dwim reference functionality. --- etc/NEWS | 8 ++++++++ lisp/textmodes/texinfo.el | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 9bbe6befcf..d6f0232732 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -472,6 +472,14 @@ To enable it, set the new defcustom 'diff-font-lock-prettify' to t. of the file under version control if point is on an old changed line, or to the new revision of the file otherwise. +** 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. diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index 1a900122f9..67a4081708 100644 --- a/lisp/textmodes/texinfo.el +++ b/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,37 @@ 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 `@ref{}' 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 + ((eq (char-before) ?\() + "@pxref{") + ;; beginning of sentence + ((looking-back (sentence-end) (point-at-bol 0)) + "@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. -- 2.20.1.142.g77556354bb --=-=-=--