diff options
| author | Juri Linkov | 2014-07-08 11:02:50 +0300 |
|---|---|---|
| committer | Juri Linkov | 2014-07-08 11:02:50 +0300 |
| commit | f0f70ec0bc55e452ea29b5cf3f532740966b0192 (patch) | |
| tree | e77dfa2fabf062231d851071670138f28d1d2566 | |
| parent | f298de5264c86bbb76ccec727779dabe16e6b9c3 (diff) | |
| download | emacs-f0f70ec0bc55e452ea29b5cf3f532740966b0192.tar.gz emacs-f0f70ec0bc55e452ea29b5cf3f532740966b0192.zip | |
* lisp/window.el (with-displayed-buffer-window): New macro.
(with-temp-buffer-window, with-current-buffer-window):
Use `macroexp-let2' to evaluate and bind variables
in the same order as macro arguments.
(display-buffer--action-function-custom-type): Add
`display-buffer-below-selected' and `display-buffer-at-bottom'.
* lisp/minibuffer.el (minibuffer-completion-help): Replace
`with-output-to-temp-buffer' with `with-displayed-buffer-window'
with actions that display *Completions* at-bottom when called
from the minibuffer, or below-selected in a normal buffer.
Associate `window-height' with `fit-window-to-buffer'.
Let-bind `pop-up-windows' to nil.
* lisp/dired.el (dired-mark-pop-up): Use `with-displayed-buffer-window'
instead of `with-current-buffer-window'.
Fixes: debbugs:17809
| -rw-r--r-- | lisp/ChangeLog | 19 | ||||
| -rw-r--r-- | lisp/dired.el | 28 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 25 | ||||
| -rw-r--r-- | lisp/window.el | 77 |
4 files changed, 114 insertions, 35 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a8b5f935d9a..cc864810c8c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2014-07-08 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | * window.el (with-displayed-buffer-window): New macro. | ||
| 4 | (with-temp-buffer-window, with-current-buffer-window): | ||
| 5 | Use `macroexp-let2' to evaluate and bind variables | ||
| 6 | in the same order as macro arguments. | ||
| 7 | (display-buffer--action-function-custom-type): Add | ||
| 8 | `display-buffer-below-selected' and `display-buffer-at-bottom'. | ||
| 9 | |||
| 10 | * minibuffer.el (minibuffer-completion-help): Replace | ||
| 11 | `with-output-to-temp-buffer' with `with-displayed-buffer-window' | ||
| 12 | with actions that display *Completions* at-bottom when called | ||
| 13 | from the minibuffer, or below-selected in a normal buffer. | ||
| 14 | Associate `window-height' with `fit-window-to-buffer'. | ||
| 15 | Let-bind `pop-up-windows' to nil. | ||
| 16 | |||
| 17 | * dired.el (dired-mark-pop-up): Use `with-displayed-buffer-window' | ||
| 18 | instead of `with-current-buffer-window'. (Bug#17809) | ||
| 19 | |||
| 1 | 2014-07-07 Luke Lee <luke.yx.lee@gmail.com> | 20 | 2014-07-07 Luke Lee <luke.yx.lee@gmail.com> |
| 2 | 21 | ||
| 3 | * progmodes/hideif.el (hide-ifdef-env): Change to global. | 22 | * progmodes/hideif.el (hide-ifdef-env): Change to global. |
diff --git a/lisp/dired.el b/lisp/dired.el index a241fb3b339..25b70219c7d 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -3103,20 +3103,20 @@ argument or confirmation)." | |||
| 3103 | ;; Mark *Marked Files* window as softly-dedicated, to prevent | 3103 | ;; Mark *Marked Files* window as softly-dedicated, to prevent |
| 3104 | ;; other buffers e.g. *Completions* from reusing it (bug#17554). | 3104 | ;; other buffers e.g. *Completions* from reusing it (bug#17554). |
| 3105 | (display-buffer-mark-dedicated 'soft)) | 3105 | (display-buffer-mark-dedicated 'soft)) |
| 3106 | (with-current-buffer buffer | 3106 | (with-displayed-buffer-window |
| 3107 | (with-current-buffer-window | 3107 | buffer |
| 3108 | buffer | 3108 | (cons 'display-buffer-below-selected |
| 3109 | (cons 'display-buffer-below-selected | 3109 | '((window-height . fit-window-to-buffer))) |
| 3110 | '((window-height . fit-window-to-buffer))) | 3110 | #'(lambda (window _value) |
| 3111 | #'(lambda (window _value) | 3111 | (with-selected-window window |
| 3112 | (with-selected-window window | 3112 | (unwind-protect |
| 3113 | (unwind-protect | 3113 | (apply function args) |
| 3114 | (apply function args) | 3114 | (when (window-live-p window) |
| 3115 | (when (window-live-p window) | 3115 | (quit-restore-window window 'kill))))) |
| 3116 | (quit-restore-window window 'kill))))) | 3116 | ;; Handle (t FILE) just like (FILE), here. That value is |
| 3117 | ;; Handle (t FILE) just like (FILE), here. That value is | 3117 | ;; used (only in some cases), to mean just one file that was |
| 3118 | ;; used (only in some cases), to mean just one file that was | 3118 | ;; marked, rather than the current line file. |
| 3119 | ;; marked, rather than the current line file. | 3119 | (with-current-buffer buffer |
| 3120 | (dired-format-columns-of-files | 3120 | (dired-format-columns-of-files |
| 3121 | (if (eq (car files) t) (cdr files) files)) | 3121 | (if (eq (car files) t) (cdr files) files)) |
| 3122 | (remove-text-properties (point-min) (point-max) | 3122 | (remove-text-properties (point-min) (point-max) |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index e7e08342b47..f8b77cddbc5 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -1794,8 +1794,29 @@ variables.") | |||
| 1794 | ;; window, mark it as softly-dedicated, so bury-buffer in | 1794 | ;; window, mark it as softly-dedicated, so bury-buffer in |
| 1795 | ;; minibuffer-hide-completions will know whether to | 1795 | ;; minibuffer-hide-completions will know whether to |
| 1796 | ;; delete the window or not. | 1796 | ;; delete the window or not. |
| 1797 | (display-buffer-mark-dedicated 'soft)) | 1797 | (display-buffer-mark-dedicated 'soft) |
| 1798 | (with-output-to-temp-buffer "*Completions*" | 1798 | ;; Disable `pop-up-windows' temporarily to allow |
| 1799 | ;; `display-buffer--maybe-pop-up-frame-or-window' | ||
| 1800 | ;; in the display actions below to pop up a frame | ||
| 1801 | ;; if `pop-up-frames' is non-nil, but not to pop up a window. | ||
| 1802 | (pop-up-windows nil)) | ||
| 1803 | (with-displayed-buffer-window | ||
| 1804 | "*Completions*" | ||
| 1805 | ;; This is a copy of `display-buffer-fallback-action' | ||
| 1806 | ;; where `display-buffer-use-some-window' is replaced | ||
| 1807 | ;; with `display-buffer-at-bottom'. | ||
| 1808 | `((display-buffer--maybe-same-window | ||
| 1809 | display-buffer-reuse-window | ||
| 1810 | display-buffer--maybe-pop-up-frame-or-window | ||
| 1811 | ;; Use `display-buffer-below-selected' for inline completions, | ||
| 1812 | ;; but not in the minibuffer (e.g. in `eval-expression') | ||
| 1813 | ;; for which `display-buffer-at-bottom' is used. | ||
| 1814 | ,(if (and completion-in-region-mode-predicate | ||
| 1815 | (not (minibuffer-selected-window))) | ||
| 1816 | 'display-buffer-below-selected | ||
| 1817 | 'display-buffer-at-bottom)) | ||
| 1818 | (window-height . fit-window-to-buffer)) | ||
| 1819 | nil | ||
| 1799 | ;; Remove the base-size tail because `sort' requires a properly | 1820 | ;; Remove the base-size tail because `sort' requires a properly |
| 1800 | ;; nil-terminated list. | 1821 | ;; nil-terminated list. |
| 1801 | (when last (setcdr last nil)) | 1822 | (when last (setcdr last nil)) |
diff --git a/lisp/window.el b/lisp/window.el index 28dd6a8ab26..e1c79659773 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -185,16 +185,19 @@ argument replaces this)." | |||
| 185 | (let ((buffer (make-symbol "buffer")) | 185 | (let ((buffer (make-symbol "buffer")) |
| 186 | (window (make-symbol "window")) | 186 | (window (make-symbol "window")) |
| 187 | (value (make-symbol "value"))) | 187 | (value (make-symbol "value"))) |
| 188 | `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name)) | 188 | (macroexp-let2 nil vbuffer-or-name buffer-or-name |
| 189 | (standard-output ,buffer) | 189 | (macroexp-let2 nil vaction action |
| 190 | ,window ,value) | 190 | (macroexp-let2 nil vquit-function quit-function |
| 191 | (setq ,value (progn ,@body)) | 191 | `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) |
| 192 | (with-current-buffer ,buffer | 192 | (standard-output ,buffer) |
| 193 | (setq ,window (temp-buffer-window-show ,buffer ,action))) | 193 | ,window ,value) |
| 194 | 194 | (setq ,value (progn ,@body)) | |
| 195 | (if (functionp ,quit-function) | 195 | (with-current-buffer ,buffer |
| 196 | (funcall ,quit-function ,window ,value) | 196 | (setq ,window (temp-buffer-window-show ,buffer ,vaction))) |
| 197 | ,value)))) | 197 | |
| 198 | (if (functionp ,vquit-function) | ||
| 199 | (funcall ,vquit-function ,window ,value) | ||
| 200 | ,value))))))) | ||
| 198 | 201 | ||
| 199 | (defmacro with-current-buffer-window (buffer-or-name action quit-function &rest body) | 202 | (defmacro with-current-buffer-window (buffer-or-name action quit-function &rest body) |
| 200 | "Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer. | 203 | "Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer. |
| @@ -205,16 +208,50 @@ BODY." | |||
| 205 | (let ((buffer (make-symbol "buffer")) | 208 | (let ((buffer (make-symbol "buffer")) |
| 206 | (window (make-symbol "window")) | 209 | (window (make-symbol "window")) |
| 207 | (value (make-symbol "value"))) | 210 | (value (make-symbol "value"))) |
| 208 | `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name)) | 211 | (macroexp-let2 nil vbuffer-or-name buffer-or-name |
| 209 | (standard-output ,buffer) | 212 | (macroexp-let2 nil vaction action |
| 210 | ,window ,value) | 213 | (macroexp-let2 nil vquit-function quit-function |
| 211 | (with-current-buffer ,buffer | 214 | `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) |
| 212 | (setq ,value (progn ,@body)) | 215 | (standard-output ,buffer) |
| 213 | (setq ,window (temp-buffer-window-show ,buffer ,action))) | 216 | ,window ,value) |
| 217 | (with-current-buffer ,buffer | ||
| 218 | (setq ,value (progn ,@body)) | ||
| 219 | (setq ,window (temp-buffer-window-show ,buffer ,vaction))) | ||
| 220 | |||
| 221 | (if (functionp ,vquit-function) | ||
| 222 | (funcall ,vquit-function ,window ,value) | ||
| 223 | ,value))))))) | ||
| 224 | |||
| 225 | (defmacro with-displayed-buffer-window (buffer-or-name action quit-function &rest body) | ||
| 226 | "Show a buffer BUFFER-OR-NAME and evaluate BODY in that buffer. | ||
| 227 | This construct is like `with-current-buffer-window' but unlike that | ||
| 228 | displays the buffer specified by BUFFER-OR-NAME before running BODY." | ||
| 229 | (declare (debug t)) | ||
| 230 | (let ((buffer (make-symbol "buffer")) | ||
| 231 | (window (make-symbol "window")) | ||
| 232 | (value (make-symbol "value"))) | ||
| 233 | (macroexp-let2 nil vbuffer-or-name buffer-or-name | ||
| 234 | (macroexp-let2 nil vaction action | ||
| 235 | (macroexp-let2 nil vquit-function quit-function | ||
| 236 | `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) | ||
| 237 | (standard-output ,buffer) | ||
| 238 | ,window ,value) | ||
| 239 | (with-current-buffer ,buffer | ||
| 240 | (setq ,window (temp-buffer-window-show ,buffer ,vaction))) | ||
| 241 | |||
| 242 | (let ((inhibit-read-only t) | ||
| 243 | (inhibit-modification-hooks t)) | ||
| 244 | (setq ,value (progn ,@body))) | ||
| 245 | |||
| 246 | (set-window-point ,window (point-min)) | ||
| 247 | |||
| 248 | (when (functionp (cdr (assq 'window-height (cdr ,vaction)))) | ||
| 249 | (ignore-errors | ||
| 250 | (funcall (cdr (assq 'window-height (cdr ,vaction))) ,window))) | ||
| 214 | 251 | ||
| 215 | (if (functionp ,quit-function) | 252 | (if (functionp ,vquit-function) |
| 216 | (funcall ,quit-function ,window ,value) | 253 | (funcall ,vquit-function ,window ,value) |
| 217 | ,value)))) | 254 | ,value))))))) |
| 218 | 255 | ||
| 219 | ;; The following two functions are like `window-next-sibling' and | 256 | ;; The following two functions are like `window-next-sibling' and |
| 220 | ;; `window-prev-sibling' but the WINDOW argument is _not_ optional (so | 257 | ;; `window-prev-sibling' but the WINDOW argument is _not_ optional (so |
| @@ -5980,6 +6017,8 @@ The actual non-nil value of this variable will be copied to the | |||
| 5980 | (const display-buffer-pop-up-window) | 6017 | (const display-buffer-pop-up-window) |
| 5981 | (const display-buffer-same-window) | 6018 | (const display-buffer-same-window) |
| 5982 | (const display-buffer-pop-up-frame) | 6019 | (const display-buffer-pop-up-frame) |
| 6020 | (const display-buffer-below-selected) | ||
| 6021 | (const display-buffer-at-bottom) | ||
| 5983 | (const display-buffer-in-previous-window) | 6022 | (const display-buffer-in-previous-window) |
| 5984 | (const display-buffer-use-some-window) | 6023 | (const display-buffer-use-some-window) |
| 5985 | (function :tag "Other function")) | 6024 | (function :tag "Other function")) |