[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 196/287: Clean up open last closed buffer. (Issue #237)
From: |
Matthew Fidler |
Subject: |
[elpa] 196/287: Clean up open last closed buffer. (Issue #237) |
Date: |
Wed, 02 Jul 2014 14:45:56 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit 87480c19f9b7c9ff24c249de9c1de413ec4a0084
Author: Matthew L. Fidler <address@hidden>
Date: Mon Jun 23 08:37:08 2014 -0500
Clean up open last closed buffer. (Issue #237)
---
ergoemacs-functions.el | 21 ++++++++++++++-------
ergoemacs-mode.el | 2 ++
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/ergoemacs-functions.el b/ergoemacs-functions.el
index a210229..ea6ef26 100644
--- a/ergoemacs-functions.el
+++ b/ergoemacs-functions.el
@@ -1267,6 +1267,14 @@ by `ergoemacs-maximum-number-of-files-to-open'.
;; status to offer save
;; This custome kill buffer is close-current-buffer.
(defvar ergoemacs-single-command-keys)
+(defun ergoemacs-save-buffer-to-recently-closed ()
+ "If the buffer is a file, add the path to the list
`ergoemacs-recently-closed-buffers'"
+ (when (not (equal buffer-file-name nil))
+ (setq ergoemacs-recently-closed-buffers
+ (cons (cons (buffer-name) (buffer-file-name))
ergoemacs-recently-closed-buffers))
+ (when (> (length ergoemacs-recently-closed-buffers)
ergoemacs-recently-closed-buffers-max)
+ (setq ergoemacs-recently-closed-buffers (butlast
ergoemacs-recently-closed-buffers 1)))))
+
(declare-function ergoemacs-get-override-function "ergoemacs-shortcuts.el")
(declare-function minibuffer-keyboard-quit "delsel.el")
(declare-function org-edit-src-save "org-src.el")
@@ -1280,7 +1288,6 @@ Similar to (kill-buffer (current-buffer)) with the
following addition:
• If the buffer is editing a source file in an org-mode file, prompt the user
to save before closing.
• If the buffer is editing a CAPTUREd task in an org-mode file, prompt the
user to save before closing.
• If the buffer is editing a magit commit, prompt the user to save the commit
before closing.
-• If the buffer is a file, add the path to the list
`ergoemacs-recently-closed-buffers'.
• If it is the minibuffer, exit the minibuffer
A emacs buffer is one who's name starts with *.
@@ -1328,11 +1335,6 @@ Else it is a user buffer."
(org-edit-src-save)
(set-buffer-modified-p nil)))
;; save to a list of closed buffer
- (when (not (equal buffer-file-name nil))
- (setq ergoemacs-recently-closed-buffers
- (cons (cons (buffer-name) (buffer-file-name))
ergoemacs-recently-closed-buffers))
- (when (> (length ergoemacs-recently-closed-buffers)
ergoemacs-recently-closed-buffers-max)
- (setq ergoemacs-recently-closed-buffers (butlast
ergoemacs-recently-closed-buffers 1))))
(kill-buffer (current-buffer))
;; if emacs buffer, switch to a user buffer
(if (string-match "^*" (buffer-name))
@@ -1344,7 +1346,12 @@ Else it is a user buffer."
(defun ergoemacs-open-last-closed ()
"Open the last closed file."
(interactive)
- (find-file (cdr (pop ergoemacs-recently-closed-buffers)) ) )
+ (let ((file (cdr (pop ergoemacs-recently-closed-buffers))))
+ (if file
+ (if (file-exists-p file)
+ (find-file file)
+ (error "File %s seems to have been deleted." file))
+ (error "No recent file has been closed"))))
;;; Text scaling functions
(defun ergoemacs-text-scale-normal-size ()
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index d0f15ff..0b48376 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -478,6 +478,7 @@ bindings the keymap is:
(ergoemacs-enable-c-advices)
(setq ergoemacs-unbind-keys t)
(add-hook 'pre-command-hook 'ergoemacs-pre-command-hook)
+ (add-hook 'kill-buffer-hook 'ergoemacs-save-buffer-to-recently-closed)
(ergoemacs-populate-pre-command-hook)
(ergoemacs-debug-heading "Ergoemacs-mode turned ON."))
;; turn off ergoemacs-mode
@@ -499,6 +500,7 @@ bindings the keymap is:
(when am
(set am ergoemacs-old-ns-alternate-modifier))))
(remove-hook 'pre-command-hook 'ergoemacs-pre-command-hook)
+ (remove-hook 'kill-buffer-hook 'ergoemacs-save-buffer-to-recently-closed)
(ergoemacs-populate-pre-command-hook t)
;; Revert `substitute-command-keys' and `completing-read'
(ergoemacs-enable-c-advices 'disable)
- [elpa] 122/287: Fix byte-compile files, (continued)
- [elpa] 122/287: Fix byte-compile files, Matthew Fidler, 2014/07/02
- [elpa] 123/287: Add w32-shell-execute for ignoring linux byte-compile errors, Matthew Fidler, 2014/07/02
- [elpa] 99/287: Remove ergoemacs-test.el, Matthew Fidler, 2014/07/02
- [elpa] 110/287: Fix Byte Compiler issues for ergoemacs-functions.el, Matthew Fidler, 2014/07/02
- [elpa] 120/287: Removed some of the issues with ergoemacs-theme-engine.el, Matthew Fidler, 2014/07/02
- [elpa] 105/287: move misplaced function, Matthew Fidler, 2014/07/02
- [elpa] 187/287: Change to eieio-named, Matthew Fidler, 2014/07/02
- [elpa] 98/287: Modified ergoemacs-init not to depend on anything..., Matthew Fidler, 2014/07/02
- [elpa] 137/287: Get old-style fixed & variable layouts, Matthew Fidler, 2014/07/02
- [elpa] 143/287: Make test dir the same as work dir, Matthew Fidler, 2014/07/02
- [elpa] 196/287: Clean up open last closed buffer. (Issue #237),
Matthew Fidler <=
- [elpa] 100/287: Reduce Readme.md and add build status, Matthew Fidler, 2014/07/02
- [elpa] 94/287: Fixed shortcut keys., Matthew Fidler, 2014/07/02
- [elpa] 127/287: Update documentation again., Matthew Fidler, 2014/07/02
- [elpa] 203/287: Fix the C-e test, Matthew Fidler, 2014/07/02
- [elpa] 198/287: More flexible redo, Issue #239, Matthew Fidler, 2014/07/02
- [elpa] 96/287: Fix shortcut keys again., Matthew Fidler, 2014/07/02
- [elpa] 199/287: Update ergoemacs-test-layout so it wont parse the function, Matthew Fidler, 2014/07/02
- [elpa] 135/287: Fix defcustom, Matthew Fidler, 2014/07/02
- [elpa] 104/287: Fix many compiler warnings with ergoemacs-advices.el, Matthew Fidler, 2014/07/02
- [elpa] 97/287: First attempt for Cask without Cask (I'm on windows), Matthew Fidler, 2014/07/02