From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: bug#31636: 27.0.50; lockfile syntax searchable from info manual Date: Tue, 05 Jun 2018 21:51:17 +0200 Message-ID: <87lgbtm2q2.fsf@gmail.com> References: <20180529073311.EEA09102DA@mailuser.nyi.internal> <876036hn2e.fsf@gmail.com> <87tvqqd7rp.fsf@gmail.com> <87r2lufvo9.fsf@gmail.com> <83r2luv28h.fsf@gnu.org> <87a7sib7ty.fsf@gmail.com> <83in75vp8l.fsf@gnu.org> <87wovkyv6l.fsf@gmail.com> <83tvqmga79.fsf@gnu.org> <87h8mmu6jp.fsf@gmail.com> <83k1rifyqo.fsf@gnu.org> <87y3fyskns.fsf@gmail.com> <87tvqmsjww.fsf@gmail.com> <87bmcqlwhn.fsf@gmail.com> <8336y2czrp.fsf@gnu.org> <87zi0a5v4z.fsf@gmail.com> <83tvqh9sqp.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1528228195 25759 195.159.176.226 (5 Jun 2018 19:49:55 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Jun 2018 19:49:55 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 05 21:49:51 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQHxm-0006b1-V9 for ged-emacs-devel@m.gmane.org; Tue, 05 Jun 2018 21:49:51 +0200 Original-Received: from localhost ([::1]:48797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQHzt-0005tN-Rl for ged-emacs-devel@m.gmane.org; Tue, 05 Jun 2018 15:52:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQHzH-0005tI-Qu for emacs-devel@gnu.org; Tue, 05 Jun 2018 15:51:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQHzE-0003BC-MP for emacs-devel@gnu.org; Tue, 05 Jun 2018 15:51:23 -0400 Original-Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:54370) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQHzE-0003Ax-Dm; Tue, 05 Jun 2018 15:51:20 -0400 Original-Received: by mail-wm0-x22b.google.com with SMTP id o13-v6so7144679wmf.4; Tue, 05 Jun 2018 12:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:mail-followup-to:mail-copies-to :gmane-reply-to-list:date:message-id:mime-version :content-transfer-encoding; bh=fp3K47WDNCO9/G80OSGd+bfeugwMeFDt31hqgwzQZEg=; b=Tqk5LrqCh8YI6xdku8ekaUpmsVWGEjqXnt7Ed1+aYHwN1h2gMdaOB4+xS5E8R3rJAD vvAJKrJ+eltRhc4W8xHLJbvAEu3OWgvUNtq1yq7F14pmqIfjDmfQtIqBoTaGjv9C7r7K 9GRN0jyHgmTjPB3RSJWpngNRMqU6jcTvOKFndV7czPeO3yozx4QI70AI1KJjYrsmml7f xjlULu0SK6/ZXJlXUbgkRy2kCHFNgW/A4mM5BPZTEMNKaMHGiS2ydXdhklXVK+lKYhLT ErUvDoMC6LVYtFp5BpLNxiFmWvUTFp82eMgPMo9kKJuW0hzglJf8FdAVcRouvtRYhysE ZK9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:mail-followup-to :mail-copies-to:gmane-reply-to-list:date:message-id:mime-version :content-transfer-encoding; bh=fp3K47WDNCO9/G80OSGd+bfeugwMeFDt31hqgwzQZEg=; b=KlnIUYqPdjVDoG6pbsXLs7pSyL+D2E93Ufl7nxGNWpzxgH68kkxVwoQpK5z9WxXAdL Uf8PZPYO+2AMrDdnodHDkIpNYIkOqCG1qWrbgw9jv1cD88W2DfZqQBMApSPoo+G+I5em 9cv8hbQR6QIv7g2SazUCrz166PHNoRjv1vSYD2eVeaxegHtpRxtF1jPweE4h4MAsaeWr PB79LarP3cuISXLQk27PBIIYltIIy6wQKzW7ejnSUnd3yjTHo7exyxKYz4w6DNktRt/v uhN/iW/rlyJSYaLd8R3kpC7kVgUYyBXEJZZ7nBWSB+nFiBgTmbnL7uolo+BQRoiDXl7c xSRA== X-Gm-Message-State: APt69E1QTZCS9JaMa+vNfW9FG4NAdt3d9whTyJRz9pnN6geiaV/+S1JD vpoYsoCGa4R3djhGt5A5YY7gMphxUCU= X-Google-Smtp-Source: ADUXVKIHrBzRxcQs84KAbGXU0iM+pavFev491PbIkru9Ml4FYQezWN+a1NDlOyW4nlXxmixwxMcujQ== X-Received: by 2002:a1c:e0c6:: with SMTP id x189-v6mr382476wmg.52.1528228278867; Tue, 05 Jun 2018 12:51:18 -0700 (PDT) Original-Received: from rpluim (vav06-1-78-207-202-134.fbx.proxad.net. [78.207.202.134]) by smtp.gmail.com with ESMTPSA id w15-v6sm19886587wro.52.2018.06.05.12.51.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 12:51:18 -0700 (PDT) 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:400c:c09::22b 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:226047 Archived-At: 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=CA=BCll need to send them a patch as well. 2018-06-05 Robert Pluim * 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}. * Changes in Specialized Modes and Packages in Emacs 27.1 =20 +** 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) =20 +(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.