From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Vivier Subject: [PATCH] Fix other commands for exiting narrowing Date: Mon, 18 Feb 2019 02:02:33 +0100 Message-ID: <87imxh3o46.fsf@hidden> References: <20190218002547.30325-1-leo.vivier@gmail.com> <20190218002547.30325-2-leo.vivier@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:60515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvXKm-00069r-JG for emacs-orgmode@gnu.org; Sun, 17 Feb 2019 20:03:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvXKl-0005q6-9J for emacs-orgmode@gnu.org; Sun, 17 Feb 2019 20:03:00 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42570) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gvXKk-0005lP-UO for emacs-orgmode@gnu.org; Sun, 17 Feb 2019 20:02:59 -0500 Received: by mail-wr1-x444.google.com with SMTP id r5so3123064wrg.9 for ; Sun, 17 Feb 2019 17:02:37 -0800 (PST) Received: from thinkpad.localdomain (lcs07-lyo-176-188-242-162.sfr.lns.abo.bbox.fr. [176.188.242.162]) by smtp.gmail.com with ESMTPSA id r15sm13015063wrt.37.2019.02.17.17.02.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Feb 2019 17:02:34 -0800 (PST) In-Reply-To: <20190218002547.30325-2-leo.vivier@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org * lisp/org.el (org-kill-buffer): Create a wrapper for kill-buffer to handle last newline deletion. (org-kill-buffer-and-window): Create a wrapper for kill-buffer-and-window to handle last newline deletion. * lisp/org-keys.el (org-remap): Remap kill-buffer and kill-buffer-and-window to org wrappers. --- I'd forgotten to patch the commands for exiting indirect buffers spawned by `org-tree-to-indirect-buffer'. This needs to be squashed with the first commit. Sorry for the bother. lisp/org-keys.el | 2 ++ lisp/org.el | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lisp/org-keys.el b/lisp/org-keys.el index 26a3852b3..0f4fd5b6d 100644 --- a/lisp/org-keys.el +++ b/lisp/org-keys.el @@ -533,6 +533,8 @@ COMMANDS is a list of alternating OLDDEF NEWDEF command names." 'delete-backward-char 'org-delete-backward-char 'kill-line 'org-kill-line 'kill-region 'org-kill-region + 'kill-buffer 'org-kill-bufer + 'kill-buffer-and-window 'org-kill-buffer-and-window 'widen 'org-widen 'open-line 'org-open-line 'yank 'org-yank diff --git a/lisp/org.el b/lisp/org.el index 02130ab6a..292807138 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7442,6 +7442,27 @@ frame is not changed." (make-indirect-buffer buffer bname 'clone) (error (make-indirect-buffer buffer bname))))) +(defun org-kill-buffer (&optional buffer-or-name) + "Kill the buffer specified by BUFFER-OR-NAME. +The argument may be a buffer or the name of an existing buffer. +Argument nil or omitted means kill the current buffer. Return t if the +buffer is actually killed, nil otherwise. + +Wrapper for org. See `kill-buffer' for more info." + (interactive) + (when (buffer-base-buffer) + (org-widen)) + (kill-buffer buffer-or-name)) + +(defun org-kill-buffer-and-window () + "Kill the current buffer and delete the selected window. + +Wrapper for org. See `kill-buffer-and-window' for more info." + (interactive) + (when (buffer-base-buffer) + (org-widen)) + (kill-buffer-and-window)) + (defun org-set-frame-title (title) "Set the title of the current frame to the string TITLE." (modify-frame-parameters (selected-frame) (list (cons 'name title)))) -- 2.20.1