[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 243ee46 10/14: Allow to switch to all empty buffers (read-
From: |
Oleh Krehel |
Subject: |
[elpa] master 243ee46 10/14: Allow to switch to all empty buffers (read-only as well) |
Date: |
Thu, 04 Jun 2015 17:05:18 +0000 |
branch: master
commit 243ee467fce4017598deed3f72cad5e128fd762b
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow to switch to all empty buffers (read-only as well)
* ace-window.el (aw-window-list): Stop filtering out empty read-only
buffers.
(aw-empty-buffers-list): New defvar, store empty buffers here.
(aw--done): Return empty buffers to their empty state (they had a single
space inserted in order for overlay to work).
(aw--lead-overlay): Insert a space into an empty buffer.
(aw-select): Move inserting a space into `aw--lead-overlay'.
---
ace-window.el | 87 ++++++++++++++++++++++++++++++--------------------------
1 files changed, 47 insertions(+), 40 deletions(-)
diff --git a/ace-window.el b/ace-window.el
index 0a9d9b8..96403f9 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -136,15 +136,11 @@ This will make `ace-window' act different from
`other-window' for
(sort
(cl-remove-if
(lambda (w)
- (let ((f (window-frame w))
- (b (window-buffer w)))
+ (let ((f (window-frame w)))
(or (not (and (frame-live-p f)
(frame-visible-p f)))
(string= "initial_terminal" (terminal-name f))
- (aw-ignored-p w)
- (with-current-buffer b
- (and buffer-read-only
- (= 0 (buffer-size b)))))))
+ (aw-ignored-p w))))
(cl-case aw-scope
(global
(cl-mapcan #'window-list (frame-list)))
@@ -165,6 +161,10 @@ This will make `ace-window' act different from
`other-window' for
(nconc minor-mode-alist
(list '(ace-window-mode ace-window-mode))))
+(defvar aw-empty-buffers-list nil
+ "Store the read-only empty buffers which had to be modified.
+Modify them back eventually.")
+
(defun aw--done ()
"Clean up mode line and overlays."
;; mode line
@@ -172,41 +172,52 @@ This will make `ace-window' act different from
`other-window' for
;; background
(mapc #'delete-overlay aw-overlays-back)
(setq aw-overlays-back nil)
- (avy--remove-leading-chars))
+ (avy--remove-leading-chars)
+ (dolist (b aw-empty-buffers-list)
+ (with-current-buffer b
+ (when (string= (buffer-string) " ")
+ (let ((inhibit-read-only t))
+ (delete-region (point-min) (point-max))))))
+ (setq aw-empty-buffers-list nil))
(defun aw--lead-overlay (path leaf)
"Create an overlay using PATH at LEAF.
LEAF is (PT . WND)."
- (let* ((pt (car leaf))
- (wnd (cdr leaf))
- (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
- (old-str (or
- (ignore-errors
- (with-selected-window wnd
- (buffer-substring pt (1+ pt))))
- ""))
- (new-str
- (concat
- (cl-case aw-leading-char-style
- (char
- (apply #'string (last path)))
- (path
- (apply #'string (reverse path)))
- (t
- (error "Bad `aw-leading-char-style': %S"
- aw-leading-char-style)))
- (cond ((string-equal old-str "\t")
- (make-string (1- tab-width) ?\ ))
- ((string-equal old-str "\n")
- "\n")
+ (let ((wnd (cdr leaf)))
+ (with-selected-window wnd
+ (when (= 0 (buffer-size))
+ (push (current-buffer) aw-empty-buffers-list)
+ (let ((inhibit-read-only t))
+ (insert " ")))
+ (let* ((pt (car leaf))
+ (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
+ (old-str (or
+ (ignore-errors
+ (with-selected-window wnd
+ (buffer-substring pt (1+ pt))))
+ ""))
+ (new-str
+ (concat
+ (cl-case aw-leading-char-style
+ (char
+ (apply #'string (last path)))
+ (path
+ (apply #'string (reverse path)))
(t
- (make-string
- (max 0 (1- (string-width old-str)))
- ?\ ))))))
- (overlay-put ol 'face 'aw-leading-char-face)
- (overlay-put ol 'window wnd)
- (overlay-put ol 'display new-str)
- (push ol avy--overlays-lead)))
+ (error "Bad `aw-leading-char-style': %S"
+ aw-leading-char-style)))
+ (cond ((string-equal old-str "\t")
+ (make-string (1- tab-width) ?\ ))
+ ((string-equal old-str "\n")
+ "\n")
+ (t
+ (make-string
+ (max 0 (1- (string-width old-str)))
+ ?\ ))))))
+ (overlay-put ol 'face 'aw-leading-char-face)
+ (overlay-put ol 'window wnd)
+ (overlay-put ol 'display new-str)
+ (push ol avy--overlays-lead)))))
(defun aw--make-backgrounds (wnd-list)
"Create a dim background overlay for each window on WND-LIST."
@@ -289,10 +300,6 @@ Amend MODE-LINE to the mode line for the duration of the
selection."
(t
(let ((candidate-list
(mapcar (lambda (wnd)
- ;; can't jump if the buffer is empty
- (with-current-buffer (window-buffer wnd)
- (when (= 0 (buffer-size))
- (insert " ")))
(cons (aw-offset wnd) wnd))
wnd-list)))
(aw--make-backgrounds wnd-list)
- [elpa] master cf91510 05/14: README.md: Add a section on midway switch, (continued)
- [elpa] master cf91510 05/14: README.md: Add a section on midway switch, Oleh Krehel, 2015/06/04
- [elpa] master e777570 04/14: Allow to change window action midway, Oleh Krehel, 2015/06/04
- [elpa] master 1487ae1 07/14: Update README.md, Oleh Krehel, 2015/06/04
- [elpa] master eef897e 08/14: Update README.md, Oleh Krehel, 2015/06/04
- [elpa] master dd84ff6 09/14: Fix aw-ignore-current for 3 windows, Oleh Krehel, 2015/06/04
- [elpa] master 56ef753 06/14: Allow to midway switch from less than 3 windows, Oleh Krehel, 2015/06/04
- [elpa] master c82d439 03/14: Update requires, Oleh Krehel, 2015/06/04
- [elpa] master 155b6c6 11/14: ace-window.el: Bump version, Oleh Krehel, 2015/06/04
- [elpa] master 4546f20 01/14: Allow to switch the action in the middle of ace-window, Oleh Krehel, 2015/06/04
- [elpa] master e5638b1 12/14: ace-window.el (aw-swap-invert): New defcustom, Oleh Krehel, 2015/06/04
- [elpa] master 243ee46 10/14: Allow to switch to all empty buffers (read-only as well),
Oleh Krehel <=
- [elpa] master 97a2f93 13/14: Small changes to README, Oleh Krehel, 2015/06/04
- [elpa] master a4ab5a4 14/14: Merge commit '97a2f9340b19c1b8c31455b3219fb88f39d38f1b' from ace-window, Oleh Krehel, 2015/06/04