emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Leo Vivier <leo.vivier@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fix other commands for exiting narrowing
Date: Mon, 18 Feb 2019 02:02:33 +0100	[thread overview]
Message-ID: <87imxh3o46.fsf@hidden> (raw)
In-Reply-To: <20190218002547.30325-2-leo.vivier@gmail.com>


* 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

  reply	other threads:[~2019-02-18  1:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-18  0:25 [PATCH 1/2] Fix narrowing for 1-line subtrees Leo Vivier
2019-02-18  0:25 ` [PATCH 2/2] Prevent deletion of newline added by narrowing Leo Vivier
2019-02-18  1:02   ` Leo Vivier [this message]
2019-02-18  1:21     ` [PATCH] Fix other commands for exiting narrowing (2) Leo Vivier
2019-02-18 17:18       ` [PATCH] Fix problems Leo Vivier
2019-02-19 10:01 ` [PATCH 1/2] Fix narrowing for 1-line subtrees Nicolas Goaziou
2019-02-19 10:24   ` Leo Vivier
2019-02-19 10:35     ` [PATCH] Fix narrowing for 1-line subtrees (squashed) Leo Vivier
2019-02-19 12:05     ` [PATCH 1/2] Fix narrowing for 1-line subtrees Nicolas Goaziou
2019-02-19 13:37       ` Leo Vivier
2019-02-19 15:28         ` Leo Vivier
2019-02-19 15:40           ` Leo Vivier
2019-02-20 13:25             ` Nicolas Goaziou
2019-02-20 13:36               ` Leo Vivier
2019-02-21 15:38                 ` [PATCH] Fix narrowed " Leo Vivier
2019-02-21 15:41                   ` Leo Vivier
2019-02-21 15:43                     ` [PATCH] Fix spaces with `org-remove-timestamp-with-keyword' Leo Vivier
2019-02-22 20:23                     ` [PATCH] Fix narrowed 1-line subtrees Leo Vivier
2019-02-22 20:54                       ` Leo Vivier
2019-02-22 21:53                         ` Samuel Wales
2019-02-22 22:04                           ` Leo Vivier
2019-02-22 23:58                             ` Samuel Wales
2019-02-23 10:43                               ` Leo Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87imxh3o46.fsf@hidden \
    --to=leo.vivier@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).