From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Pierre-Yves Luyten Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] open bookmark in other frame Date: Thu, 11 Oct 2018 23:50:19 +0200 Message-ID: <9f2ed5a8-96c0-aa6c-b9c8-3b0f73f20aa6@luyten.fr> References: <9d4a9ab3-d802-447e-3c74-81373b7e6101@luyten.fr> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------CB858B98153D1FBEF507BA9C" X-Trace: blaine.gmane.org 1539294558 24368 195.159.176.226 (11 Oct 2018 21:49:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 11 Oct 2018 21:49:18 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 To: Drew Adams , emacs-devel@gnu.org, Karl Fogel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 11 23:49:13 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 1gAipV-000692-AJ for ged-emacs-devel@m.gmane.org; Thu, 11 Oct 2018 23:49:13 +0200 Original-Received: from localhost ([::1]:37315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAirW-0003ct-QJ for ged-emacs-devel@m.gmane.org; Thu, 11 Oct 2018 17:51:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAiqq-0003cc-8k for emacs-devel@gnu.org; Thu, 11 Oct 2018 17:50:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAiqn-00022d-0J for emacs-devel@gnu.org; Thu, 11 Oct 2018 17:50:36 -0400 Original-Received: from 1.mo6.mail-out.ovh.net ([46.105.56.136]:44125) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAiql-0001el-I7 for emacs-devel@gnu.org; Thu, 11 Oct 2018 17:50:32 -0400 Original-Received: from player788.ha.ovh.net (unknown [10.109.159.140]) by mo6.mail-out.ovh.net (Postfix) with ESMTP id A8AE7188FA4 for ; Thu, 11 Oct 2018 23:50:22 +0200 (CEST) Original-Received: from [192.168.4.20] (85-170-98-108.rev.numericable.fr [85.170.98.108]) (Authenticated sender: py@luyten.fr) by player788.ha.ovh.net (Postfix) with ESMTPSA id 424AA18009C; Thu, 11 Oct 2018 23:50:19 +0200 (CEST) In-Reply-To: Content-Language: en-US-large X-Ovh-Tracer-Id: 14239819072976629891 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudelgddtvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.56.136 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:230340 Archived-At: This is a multi-part message in MIME format. --------------CB858B98153D1FBEF507BA9C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 10/11/18 12:06 AM, Drew Adams wrote: >> people sometimes use several frames, so i would like to make opening >> bookmark one shot. Attached patch adds two funcs, >> "bookmark-jump-other-frame" and the equivalent from the bookmarks menu, >> "bookmark-bmenu-other-frame" > > My suggestions in this regard, FWIW: > > 1. Don't use `view-buffer-other-frame'. > Select the buffer, and not just read-only. Jumping to a bookmark > typically puts you at its location (hence select), and the buffer is > typically not put in a read-only mode. IOW, do the equivalent of > this, or similar: > > (let ((pop-up-frames t)) (bookmark-jump-other-window bookmark) > > 2. Don't use `F' as the key binding in the bookmark-list buffer. > `F' is more often used for files than for frames. Maybe use `5'. > > (I use `J 5' in Bookmark+. `J' is a prefix for the jump commands > in the bookmark-list buffer. The `5' is from `C-x 5' bindings for > other-frame. I bind the command to `C-x 5 B' and `C-x j 5' globally. > `C-x j' is a global prefix key for bookmark jump commands.) > So here is the new version of the patch 1. Use pop-up-frames variable to avoid a read-only mode on new frame. I also had to use (other-frame 1) to ensure new frame is raised. 2. Use "5" binding both in bookmark-map, and bookmark-bmenu-mode-map 3. Split in two commits, one per new function I tried to respect the conventions on the log. The patches are generated using git format-patch. Regards Pierre-Yves --------------CB858B98153D1FBEF507BA9C Content-Type: text/x-patch; name="0001-lisp-bookmark.el-bookmark-jump-other-frame-new-funct.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-lisp-bookmark.el-bookmark-jump-other-frame-new-funct.pa"; filename*1="tch" >From fb477d9f3bfc39f18788aa735dc70f542b513377 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Luyten Date: Thu, 11 Oct 2018 23:40:32 +0200 Subject: [PATCH 1/2] * lisp/bookmark.el (bookmark-jump-other-frame): new function Add the new function bookmark-jump-other-frame Bind to bookmark-map --- lisp/bookmark.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 58a279473d..5ee5248b97 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -209,6 +209,7 @@ A non-nil value may result in truncated bookmark names." (define-key map "j" 'bookmark-jump) (define-key map "g" 'bookmark-jump) ;"g"o (define-key map "o" 'bookmark-jump-other-window) + (define-key map "5" 'bookmark-jump-other-frame) (define-key map "i" 'bookmark-insert) (define-key map "e" 'edit-bookmarks) (define-key map "f" 'bookmark-insert-location) ;"f"ind @@ -1124,6 +1125,14 @@ DISPLAY-FUNC would be `switch-to-buffer-other-window'." bookmark-current-bookmark))) (bookmark-jump bookmark 'switch-to-buffer-other-window)) +(defun bookmark-jump-other-frame (bookmark) + "Jump to BOOKMARK in another frame. See `bookmark-jump' for more." + (interactive + (list (bookmark-completing-read "Jump to bookmark (in another frame)" + bookmark-current-bookmark))) + (let ((pop-up-frames t)) + (bookmark-jump bookmark 'display-buffer)) + (other-frame 1)) (defun bookmark-jump-noselect (bookmark) "Return the location pointed to by BOOKMARK (see `bookmark-jump'). -- 2.19.0 --------------CB858B98153D1FBEF507BA9C Content-Type: text/x-patch; name="0002-lisp-bookmark.el-bookmark-bmenu-other-frame-new-func.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-lisp-bookmark.el-bookmark-bmenu-other-frame-new-func.pa"; filename*1="tch" >From d059307d9776cb316816eecd01b6115a0335f857 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Luyten Date: Thu, 11 Oct 2018 23:41:44 +0200 Subject: [PATCH 2/2] * lisp/bookmark.el (bookmark-bmenu-other-frame): new function Add bookmark-bmenu-other-frame function Document it Bind function to bookmark-bmenu-mode-map --- lisp/bookmark.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 5ee5248b97..e89252960c 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -1570,6 +1570,7 @@ unique numeric suffixes \"<2>\", \"<3>\", etc." (set-keymap-parent map special-mode-map) (define-key map "v" 'bookmark-bmenu-select) (define-key map "w" 'bookmark-bmenu-locate) + (define-key map "5" 'bookmark-bmenu-other-frame) (define-key map "2" 'bookmark-bmenu-2-window) (define-key map "1" 'bookmark-bmenu-1-window) (define-key map "j" 'bookmark-bmenu-this-window) @@ -1711,6 +1712,8 @@ Bookmark names preceded by a \"*\" have annotations. \\[bookmark-bmenu-this-window] -- select this bookmark in place of the bookmark menu buffer. \\[bookmark-bmenu-other-window] -- select this bookmark in another window, so the bookmark menu bookmark remains visible in its window. +\\[bookmark-bmenu-other-frame] -- select this bookmark in another frame, + so the bookmark menu bookmark remains visible in its window. \\[bookmark-bmenu-switch-other-window] -- switch the other window to this bookmark. \\[bookmark-bmenu-rename] -- rename this bookmark (prompts for new name). \\[bookmark-bmenu-relocate] -- relocate this bookmark's file (prompts for new file). @@ -1979,6 +1982,12 @@ With a prefix arg, prompts for a file to save them in." (let ((bookmark (bookmark-bmenu-bookmark))) (bookmark--jump-via bookmark 'switch-to-buffer-other-window))) +(defun bookmark-bmenu-other-frame () + "Select this line's bookmark in other frame, leaving bookmark menu visible." + (interactive) + (let ((pop-up-frames t)) + (bookmark-jump bookmark 'display-buffer)) + (other-frame 1)) (defun bookmark-bmenu-switch-other-window () "Make the other window select this line's bookmark. -- 2.19.0 --------------CB858B98153D1FBEF507BA9C--