From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Charles A. Roelli" Newsgroups: gmane.emacs.bugs Subject: bug#26712: other-window/frame versions of find-library Date: Wed, 17 May 2017 21:16:57 +0200 Message-ID: References: <8897133a-0836-23a6-6bbe-aecc6ec8b7c8@aurox.ch> <9b566259-457c-faf2-10e1-42c084afccea@aurox.ch> <83tw4k61bv.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------D7798D19D40F5A54289FF741" X-Trace: blaine.gmane.org 1495048700 28862 195.159.176.226 (17 May 2017 19:18:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 17 May 2017 19:18:20 +0000 (UTC) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cc: 26712@debbugs.gnu.org, p.stephani2@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 17 21:18:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1dB4Sb-0007Br-5d for geb-bug-gnu-emacs@m.gmane.org; Wed, 17 May 2017 21:18:13 +0200 Original-Received: from localhost ([::1]:50459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB4Sb-0003se-MC for geb-bug-gnu-emacs@m.gmane.org; Wed, 17 May 2017 15:18:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB4SV-0003sJ-Mv for bug-gnu-emacs@gnu.org; Wed, 17 May 2017 15:18:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB4SQ-0002H7-Nb for bug-gnu-emacs@gnu.org; Wed, 17 May 2017 15:18:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB4SQ-0002H2-KL for bug-gnu-emacs@gnu.org; Wed, 17 May 2017 15:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dB4SQ-0005Be-Fh for bug-gnu-emacs@gnu.org; Wed, 17 May 2017 15:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Charles A. Roelli" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 17 May 2017 19:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26712 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 26712-submit@debbugs.gnu.org id=B26712.149504863319882 (code B ref 26712); Wed, 17 May 2017 19:18:02 +0000 Original-Received: (at 26712) by debbugs.gnu.org; 17 May 2017 19:17:13 +0000 Original-Received: from localhost ([127.0.0.1]:51320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dB4Rc-0005Ab-Uu for submit@debbugs.gnu.org; Wed, 17 May 2017 15:17:13 -0400 Original-Received: from sinyavsky.aurox.ch ([37.35.109.145]:49802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dB4Ra-0005AM-JP for 26712@debbugs.gnu.org; Wed, 17 May 2017 15:17:11 -0400 Original-Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id 287582242E for <26712@debbugs.gnu.org>; Wed, 17 May 2017 19:12:42 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= content-type:content-type:in-reply-to:mime-version:user-agent :date:date:message-id:from:from:references:to:subject:subject; s=dkim; t=1495048359; x=1495912360; bh=ZypMGR4kBXn6xMvmeSfN1ADp FBULF5bOi+9TO2inl7w=; b=Oz2ebLlvYd1/B+L6pm0Cg8Nsh+v32wXpV4YWLiYK It54CPaiKOsqo2RUS2z9Th+6PX08/qnvs8RK8ROqKSbM0NpLnqEx7rSw/4I7txhI 9C6x8gCov2X4bpEvEX3A4SX+AS6DnYthsl82bHpSVQecSNt0NrIhwex/EZIoWwv4 FdQ= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Original-Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id IJmBPLfGer6c for <26712@debbugs.gnu.org>; Wed, 17 May 2017 19:12:39 +0000 (UTC) Original-Received: from [192.168.1.121] (179.133.105.92.dynamic.wline.res.cust.swisscom.ch [92.105.133.179]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id C20402242B; Wed, 17 May 2017 19:12:38 +0000 (UTC) In-Reply-To: <83tw4k61bv.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:132577 Archived-At: This is a multi-part message in MIME format. --------------D7798D19D40F5A54289FF741 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Thank you for your comments. Please see again the attachment. On 16/05/2017 21:36, Eli Zaretskii wrote: >> +** Two new commands 'find-library-other-window' and >> +'find-library-other-frame'. > This is too terse. A few words regarding what these do would be much > better. Updated: +** Two new commands for finding the source code of Emacs Lisp +libraries: 'find-library-other-window' and 'find-library-other-frame'. + >> +(defun find-library (library) >> + "Find the Emacs Lisp source of the LIBRARY near point. > This is confusing, IMO. Suggest to reword: > > Find the Emacs Lisp source of LIBRARY. > Interactively, prompt for LIBRARY using the one at or near point as > the default. Thanks, I've updated it. >> +(defun read-library-name () >> + "Read and return a library name, defaulting to the one near point." > I would explain here what constitutes a "library name", i.e. how does > the function determine the library name at point. +A library name is the filename of an Emacs Lisp library located +in a directory under `load-path' (or `find-function-source-path', +if non-nil)." >> +(defun find-library-other-window (library) >> + "Find, in another window, the file defining LIBRARY at or near point. > Any reason why the wording is different from that of find-library? Nope, I've also amended this. --------------D7798D19D40F5A54289FF741 Content-Type: text/x-patch; name="0001-New-commands-find-library-other-window-find-library-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-New-commands-find-library-other-window-find-library-.pa"; filename*1="tch" >From 44f5a4f6fce2002c4d0c0030a3ef60d31f4b649a Mon Sep 17 00:00:00 2001 From: Charles A. Roelli Date: Wed, 17 May 2017 21:13:17 +0200 Subject: [PATCH] New commands: find-library-other-window, find-library-other-frame * lisp/emacs-lisp/find-func.el (find-library-other-window) (find-library-other-frame): New commands to complement the existing `find-library' command. (read-library-name): New function to read a library name. --- etc/NEWS | 3 + lisp/emacs-lisp/find-func.el | 92 ++++++++++++++++++++++++++---------------- 2 files changed, 60 insertions(+), 35 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 25f0f18..2b04ea5 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -344,6 +344,9 @@ for DNS-querying functions 'nslookup-host', 'dns-lookup-host', and 'run-dig'. Each function now accepts an optional name server argument interactively (with a prefix argument) and non-interactively. +** Two new commands for finding the source code of Emacs Lisp +libraries: 'find-library-other-window' and 'find-library-other-frame'. + * Editing Changes in Emacs 26.1 diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index d0acc14..9b98f05 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -271,43 +271,65 @@ find-function-C-source (cons (current-buffer) (match-beginning 0)))) ;;;###autoload -(defun find-library (library &optional other-window) +(defun find-library (library) "Find the Emacs Lisp source of LIBRARY. -LIBRARY should be a string (the name of the library). If the -optional OTHER-WINDOW argument (i.e., the command argument) is -specified, pop to a different window before displaying the -buffer." - (interactive - (let* ((dirs (or find-function-source-path load-path)) - (suffixes (find-library-suffixes)) - (table (apply-partially 'locate-file-completion-table - dirs suffixes)) - (def (if (eq (function-called-at-point) 'require) - ;; `function-called-at-point' may return 'require - ;; with `point' anywhere on this line. So wrap the - ;; `save-excursion' below in a `condition-case' to - ;; avoid reporting a scan-error here. - (condition-case nil - (save-excursion - (backward-up-list) - (forward-char) - (forward-sexp 2) - (thing-at-point 'symbol)) - (error nil)) - (thing-at-point 'symbol)))) - (when (and def (not (test-completion def table))) - (setq def nil)) - (list - (completing-read (if def - (format "Library name (default %s): " def) - "Library name: ") - table nil nil nil nil def) - current-prefix-arg))) + +Interactively, prompt for LIBRARY using the one at or near point." + (interactive (list (read-library-name))) + (prog1 + (switch-to-buffer (find-file-noselect (find-library-name library))) + (run-hooks 'find-function-after-hook))) + +(defun read-library-name () + "Read and return a library name, defaulting to the one near point. + +A library name is the filename of an Emacs Lisp library located +in a directory under `load-path' (or `find-function-source-path', +if non-nil)." + (let* ((dirs (or find-function-source-path load-path)) + (suffixes (find-library-suffixes)) + (table (apply-partially 'locate-file-completion-table + dirs suffixes)) + (def (if (eq (function-called-at-point) 'require) + ;; `function-called-at-point' may return 'require + ;; with `point' anywhere on this line. So wrap the + ;; `save-excursion' below in a `condition-case' to + ;; avoid reporting a scan-error here. + (condition-case nil + (save-excursion + (backward-up-list) + (forward-char) + (forward-sexp 2) + (thing-at-point 'symbol)) + (error nil)) + (thing-at-point 'symbol)))) + (when (and def (not (test-completion def table))) + (setq def nil)) + (completing-read (if def + (format "Library name (default %s): " def) + "Library name: ") + table nil nil nil nil def))) + +;;;###autoload +(defun find-library-other-window (library) + "Find the Emacs Lisp source of LIBRARY in another window. + +See `find-library' for more details." + (interactive (list (read-library-name))) + (prog1 + (switch-to-buffer-other-window (find-file-noselect + (find-library-name library))) + (run-hooks 'find-function-after-hook))) + +;;;###autoload +(defun find-library-other-frame (library) + "Find the Emacs Lisp source of LIBRARY in another frame. + +See `find-library' for more details." + (interactive (list (read-library-name))) (prog1 - (funcall (if other-window - 'pop-to-buffer - 'pop-to-buffer-same-window) - (find-file-noselect (find-library-name library))) + (switch-to-buffer-other-frame (find-file-noselect + (find-library-name library))) (run-hooks 'find-function-after-hook))) ;;;###autoload -- 1.7.4.4 --------------D7798D19D40F5A54289FF741--