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: Sat, 29 Apr 2017 21:46:22 +0200 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------EF0BE04BCDFCD31021E97DF3" X-Trace: blaine.gmane.org 1493495231 16890 195.159.176.226 (29 Apr 2017 19:47:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 29 Apr 2017 19:47:11 +0000 (UTC) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 To: 26712@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 29 21:47:07 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 1d4YKh-0004II-7m for geb-bug-gnu-emacs@m.gmane.org; Sat, 29 Apr 2017 21:47:07 +0200 Original-Received: from localhost ([::1]:42264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4YKl-0002nQ-DK for geb-bug-gnu-emacs@m.gmane.org; Sat, 29 Apr 2017 15:47:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4YKf-0002kx-GP for bug-gnu-emacs@gnu.org; Sat, 29 Apr 2017 15:47:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d4YKc-0002AR-Cv for bug-gnu-emacs@gnu.org; Sat, 29 Apr 2017 15:47:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d4YKc-0002AN-92 for bug-gnu-emacs@gnu.org; Sat, 29 Apr 2017 15:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d4YKc-0002fD-3A for bug-gnu-emacs@gnu.org; Sat, 29 Apr 2017 15:47: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: Sat, 29 Apr 2017 19:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 26712 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.149349521110218 (code B ref -1); Sat, 29 Apr 2017 19:47:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Apr 2017 19:46:51 +0000 Original-Received: from localhost ([127.0.0.1]:46660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d4YKR-0002ek-BR for submit@debbugs.gnu.org; Sat, 29 Apr 2017 15:46:51 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48115) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d4YKQ-0002eV-05 for submit@debbugs.gnu.org; Sat, 29 Apr 2017 15:46:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d4YKJ-0001yQ-Bp for submit@debbugs.gnu.org; Sat, 29 Apr 2017 15:46:44 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:40308) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d4YKJ-0001yM-99 for submit@debbugs.gnu.org; Sat, 29 Apr 2017 15:46:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4YKH-0002cS-NW for bug-gnu-emacs@gnu.org; Sat, 29 Apr 2017 15:46:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d4YKE-0001wR-Jv for bug-gnu-emacs@gnu.org; Sat, 29 Apr 2017 15:46:41 -0400 Original-Received: from [195.159.176.226] (port=39998 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d4YKE-0001ve-Bs for bug-gnu-emacs@gnu.org; Sat, 29 Apr 2017 15:46:38 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1d4YK2-0003gU-DH for bug-gnu-emacs@gnu.org; Sat, 29 Apr 2017 21:46:26 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 179 Original-X-Complaints-To: usenet@blaine.gmane.org X-Mozilla-News-Host: news://news.gmane.org:119 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:132117 Archived-At: This is a multi-part message in MIME format. --------------EF0BE04BCDFCD31021E97DF3 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Attached is a patch to add other-window/frames version of the `find-library' command. BTW, after I added the two new commands and rebuilt Emacs (with just `make'), I could not complete to them with `M-x find-library- TAB'. I could only do this after loading the `find-func' library that contains them. So I ran `make bootstrap' instead and then I could complete to them as expected. I guess this means the autoloads had not been updated with just `make'... which command should I have run? Bootstrapping takes awhile. --------------EF0BE04BCDFCD31021E97DF3 Content-Type: text/x-patch; name="0001-find-library-other-window-find-library-other-frame-N.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-find-library-other-window-find-library-other-frame-N.pa"; filename*1="tch" >From 9e4f4ba788635240b84ccdaa336760aacaa93417 Mon Sep 17 00:00:00 2001 From: Charles A. Roelli Date: Sat, 29 Apr 2017 19:40:11 +0200 Subject: [PATCH] find-library-other-window, find-library-other-frame: New commands * lisp/emacs-lisp/find-func.el (find-library-other-window) (find-library-other-frame): New commands to complement the existing `find-library' command. (find-library-read): New function to read a library name. (find-function-do-it): Fix indentation. ; * etc/NEWS (Changes in Emacs 26.1): Mention the new commands. --- etc/NEWS | 3 + lisp/emacs-lisp/find-func.el | 100 +++++++++++++++++++++++++----------------- 2 files changed, 63 insertions(+), 40 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 9d4c72d..0425996 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -340,6 +340,9 @@ want to reverse the direction of the scroll, customize ** Emacsclient has a new option -u/--suppress-output. The option suppresses display of return values from the server process. +** Two new commands '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..1aea30c 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -271,42 +271,62 @@ find-function-C-source (cons (current-buffer) (match-beginning 0)))) ;;;###autoload -(defun find-library (library &optional other-window) - "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))) +(defun find-library (library) + "Find the Emacs Lisp source of the LIBRARY near point. + +LIBRARY should be a string (the name of the library)." + (interactive (find-library-read)) + (prog1 + (funcall 'switch-to-buffer + (find-file-noselect (find-library-name library))) + (run-hooks 'find-function-after-hook))) + +(defun find-library-read () + "Read and return a library name, defaulting to the one near point." + (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)))) + +;;;###autoload +(defun find-library-other-window (library) + "Find, in another window, the file defining LIBRARY at or near point. + +See `find-library' for more details." + (interactive (find-library-read)) + (prog1 + (funcall '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, in another frame, the file defining LIBRARY at or near point. + +See `find-library' for more details." + (interactive (find-library-read)) (prog1 - (funcall (if other-window - 'pop-to-buffer - 'pop-to-buffer-same-window) + (funcall 'switch-to-buffer-other-frame (find-file-noselect (find-library-name library))) (run-hooks 'find-function-after-hook))) @@ -470,11 +490,11 @@ find-function-do-it Set mark before moving, if the buffer already existed." (let* ((orig-point (point)) - (orig-buffers (buffer-list)) - (buffer-point (save-excursion - (find-definition-noselect symbol type))) - (new-buf (car buffer-point)) - (new-point (cdr buffer-point))) + (orig-buffers (buffer-list)) + (buffer-point (save-excursion + (find-definition-noselect symbol type))) + (new-buf (car buffer-point)) + (new-point (cdr buffer-point))) (when buffer-point (when (memq new-buf orig-buffers) (push-mark orig-point)) -- 1.7.4.4 --------------EF0BE04BCDFCD31021E97DF3--