1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-30 08:08:26 +00:00

Check for horizontally-split windows when shrinking a window.

So far, Org used either `fit-window-to-buffer' or
`shrink-window-if-larger-than-buffer' without any further checks when
displaying one of its many help and selection buffers.  This can cause
problems if the user has set up Emacs to split windows horizontally
rather than vertically, because the window being shrunken then may be
side-by-side with another window, and shrinking the height of one will
also change the other.

With this patch, shrinking a window always goes through the new
function `org-fit-window-to-buffer' which only acts if the current
window spans the whole width of the frame.

Furthermore, this function also helps with compatibility, because it
falls back to `shrink-window-if-larger-than-buffer' if
`fit-window-to-buffer' does not exist, as is the case on older version
of Emacs and XEmacs.
This commit is contained in:
Carsten Dominik 2008-11-03 13:38:25 +01:00
parent 413d9b73b0
commit 293d3311d6
8 changed files with 41 additions and 32 deletions

View File

@ -1,5 +1,18 @@
2008-11-03 Carsten Dominik <dominik@science.uva.nl> 2008-11-03 Carsten Dominik <dominik@science.uva.nl>
* org-compat.el (org-fit-window-to-buffer): New function (not
really, a preliminary and incomplete version was present earlier,
but not used).
* org.el (org-fast-todo-selection, org-fast-tag-selection): Use
`org-fit-window-to-buffer'.
* org-exp.el (org-export): Use `org-fit-window-to-buffer'.
* org-agenda.el (org-agenda-get-restriction-and-command)
(org-fit-agenda-window, org-agenda-convert-date): Use
`org-fit-window-to-buffer'.
* org-exp.el (org-export-as-html): Process href links through * org-exp.el (org-export-as-html): Process href links through
`org-export-html-format-href'. `org-export-html-format-href'.
(org-export-html-format-href): New function. (org-export-html-format-href): New function.
@ -117,8 +130,6 @@
2008-10-25 Carsten Dominik <dominik@science.uva.nl> 2008-10-25 Carsten Dominik <dominik@science.uva.nl>
* org-compat.el (org-fit-window-to-buffer): New function.
* org-agenda.el (org-format-agenda-item) * org-agenda.el (org-format-agenda-item)
(org-agenda-filter-make-matcher): Make sure tags are stored and (org-agenda-filter-make-matcher): Make sure tags are stored and
compared donwcased. compared donwcased.

View File

@ -1585,12 +1585,11 @@ s Search for keywords C Configure custom agenda commands
"Prefix key")))) "Prefix key"))))
prefixes)) prefixes))
(goto-char (point-min)) (goto-char (point-min))
(when (fboundp 'fit-window-to-buffer) (if second-time
(if second-time (if (not (pos-visible-in-window-p (point-max)))
(if (not (pos-visible-in-window-p (point-max))) (org-fit-window-to-buffer))
(fit-window-to-buffer)) (setq second-time t)
(setq second-time t) (org-fit-window-to-buffer))
(fit-window-to-buffer)))
(message "Press key for agenda command%s:" (message "Press key for agenda command%s:"
(if (or restrict-ok org-agenda-overriding-restriction) (if (or restrict-ok org-agenda-overriding-restriction)
(if org-agenda-overriding-restriction (if org-agenda-overriding-restriction
@ -1989,7 +1988,7 @@ VALUE defaults to t."
"Fit the window to the buffer size." "Fit the window to the buffer size."
(and (memq org-agenda-window-setup '(reorganize-frame)) (and (memq org-agenda-window-setup '(reorganize-frame))
(fboundp 'fit-window-to-buffer) (fboundp 'fit-window-to-buffer)
(fit-window-to-buffer (org-fit-window-to-buffer
nil nil
(floor (* (frame-height) (cdr org-agenda-window-frame-fractions))) (floor (* (frame-height) (cdr org-agenda-window-frame-fractions)))
(floor (* (frame-height) (car org-agenda-window-frame-fractions)))))) (floor (* (frame-height) (car org-agenda-window-frame-fractions))))))
@ -5498,8 +5497,7 @@ This is a command that has to be installed in `calendar-mode-map'."
"Chinese: " (calendar-chinese-date-string date) "\n")) "Chinese: " (calendar-chinese-date-string date) "\n"))
(with-output-to-temp-buffer "*Dates*" (with-output-to-temp-buffer "*Dates*"
(princ s)) (princ s))
(if (fboundp 'fit-window-to-buffer) (org-fit-window-to-buffer (get-buffer-window "*Dates*"))))
(fit-window-to-buffer (get-buffer-window "*Dates*")))))
;;; Appointment reminders ;;; Appointment reminders

View File

@ -125,7 +125,7 @@ F Like \"f\", but force using dired in Emacs.
d Delete one attachment, you will be prompted for a file name. d Delete one attachment, you will be prompted for a file name.
D Delete all of a task's attachments. A safer way is D Delete all of a task's attachments. A safer way is
to open the directory in dired and delete from there."))) to open the directory in dired and delete from there.")))
(shrink-window-if-larger-than-buffer (get-buffer-window "*Org Attach*")) (org-fit-window-to-buffer (get-buffer-window "*Org Attach*"))
(message "Select command: [acmlzoOfFdD]") (message "Select command: [acmlzoOfFdD]")
(setq c (read-char-exclusive)) (setq c (read-char-exclusive))
(and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*")))) (and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*"))))

View File

@ -204,9 +204,7 @@ of a different task.")
(+ i (- ?A 10))) m)) (+ i (- ?A 10))) m))
(push s sel-list))) (push s sel-list)))
org-clock-history) org-clock-history)
(if (fboundp 'fit-window-to-buffer) (org-fit-window-to-buffer)
(fit-window-to-buffer)
(shrink-window-if-larger-than-buffer))
(message (or prompt "Select task for clocking:")) (message (or prompt "Select task for clocking:"))
(setq rpl (read-char-exclusive)) (setq rpl (read-char-exclusive))
(cond (cond

View File

@ -150,15 +150,21 @@ that will be added to PLIST. Returns the string that was modified."
string) string)
(put 'org-add-props 'lisp-indent-function 2) (put 'org-add-props 'lisp-indent-function 2)
(defun org-fit-window-to-buffer (&optional window) (defun org-fit-window-to-buffer (&optional window max-height min-height
"Fit the window to the buffer, but only if it is not a side-by-side window." shrink-only)
"Fit WINDOW to the buffer, but only if it is not a side-by-side window.
WINDOW defaults to the selected window. MAX-HEIGHT and MIN-HEIGHT are
passed through to `fit-window-to-buffer'. If SHRINK-ONLY is set, call
`shrink-window-if-larger-than-buffer' instead, the hight limit are
ignored in this case."
(cond ((> (frame-width) (window-width window)) (cond ((> (frame-width) (window-width window))
;; do nothing if another window would suffer ;; do nothing if another window would suffer
) )
((fboundp 'fit-window-to-buffer) ((and (fboundp 'fit-window-to-buffer) (not shrink-only))
(fit-window-to-buffer window)) (fit-window-to-buffer window max-height min-height))
((fboundp 'shrink-window-if-larger-than-buffer) ((fboundp 'shrink-window-if-larger-than-buffer)
(shrink-window-if-larger-than-buffer window)))) (shrink-window-if-larger-than-buffer window)))
(or window (selected-window)))
;; Region compatibility ;; Region compatibility

View File

@ -1062,9 +1062,8 @@ value of `org-export-run-in-background'."
(delete-other-windows) (delete-other-windows)
(with-output-to-temp-buffer "*Org Export/Publishing Help*" (with-output-to-temp-buffer "*Org Export/Publishing Help*"
(princ help)) (princ help))
(if (fboundp 'fit-window-to-buffer) (org-fit-window-to-buffer (get-buffer-window
(fit-window-to-buffer (get-buffer-window "*Org Export/Publishing Help*"))
"*Org Export/Publishing Help*")))
(message "Select command: ") (message "Select command: ")
(setq r1 (read-char-exclusive))) (setq r1 (read-char-exclusive)))
(setq r2 (if (< r1 27) (+ r1 96) r1)) (setq r2 (if (< r1 27) (+ r1 96) r1))

View File

@ -2172,7 +2172,7 @@ $1-> %s\n" orig formula form0 form))
ev (or fmt "NONE") ev (or fmt "NONE")
(if fmt (format fmt (string-to-number ev)) ev))))) (if fmt (format fmt (string-to-number ev)) ev)))))
(setq bw (get-buffer-window "*Substitution History*")) (setq bw (get-buffer-window "*Substitution History*"))
(shrink-window-if-larger-than-buffer bw) (org-fit-window-to-buffer bw)
(unless (and (interactive-p) (not ndown)) (unless (and (interactive-p) (not ndown))
(unless (let (inhibit-redisplay) (unless (let (inhibit-redisplay)
(y-or-n-p "Debugging Formula. Continue to next? ")) (y-or-n-p "Debugging Formula. Continue to next? "))

View File

@ -4429,7 +4429,7 @@ or nil."
(error (make-indirect-buffer (current-buffer) "*org-goto*")))) (error (make-indirect-buffer (current-buffer) "*org-goto*"))))
(with-output-to-temp-buffer "*Help*" (with-output-to-temp-buffer "*Help*"
(princ help)) (princ help))
(shrink-window-if-larger-than-buffer (get-buffer-window "*Help*")) (org-fit-window-to-buffer (get-buffer-window "*Help*"))
(setq buffer-read-only nil) (setq buffer-read-only nil)
(let ((org-startup-truncated t) (let ((org-startup-truncated t)
(org-startup-folded nil) (org-startup-folded nil)
@ -6420,7 +6420,7 @@ used as the link location instead of reading one interactively."
(reverse org-stored-links) "\n")))) (reverse org-stored-links) "\n"))))
(let ((cw (selected-window))) (let ((cw (selected-window)))
(select-window (get-buffer-window "*Org Links*")) (select-window (get-buffer-window "*Org Links*"))
(shrink-window-if-larger-than-buffer) (org-fit-window-to-buffer)
(setq truncate-lines t) (setq truncate-lines t)
(select-window cw)) (select-window cw))
;; Fake a link history, containing the stored links. ;; Fake a link history, containing the stored links.
@ -8121,8 +8121,7 @@ Returns the new TODO keyword, or nil if no state change should occur."
(setq cnt 0))))) (setq cnt 0)))))
(insert "\n") (insert "\n")
(goto-char (point-min)) (goto-char (point-min))
(if (and (not expert) (fboundp 'fit-window-to-buffer)) (if (not expert) (org-fit-window-to-buffer))
(fit-window-to-buffer))
(message "[a-z..]:Set [SPC]:clear") (message "[a-z..]:Set [SPC]:clear")
(setq c (let ((inhibit-quit t)) (read-char-exclusive))) (setq c (let ((inhibit-quit t)) (read-char-exclusive)))
(cond (cond
@ -9507,8 +9506,7 @@ Returns the new tags string, or nil to not change the current settings."
(setq ntable (nreverse ntable)) (setq ntable (nreverse ntable))
(insert "\n") (insert "\n")
(goto-char (point-min)) (goto-char (point-min))
(if (and (not expert) (fboundp 'fit-window-to-buffer)) (if (not expert) (org-fit-window-to-buffer))
(fit-window-to-buffer))
(setq rtn (setq rtn
(catch 'exit (catch 'exit
(while t (while t
@ -9530,8 +9528,7 @@ Returns the new tags string, or nil to not change the current settings."
(delete-other-windows) (delete-other-windows)
(split-window-vertically) (split-window-vertically)
(org-switch-to-buffer-other-window " *Org tags*") (org-switch-to-buffer-other-window " *Org tags*")
(and (fboundp 'fit-window-to-buffer) (org-fit-window-to-buffer)))
(fit-window-to-buffer))))
((or (= c ?\C-g) ((or (= c ?\C-g)
(and (= c ?q) (not (rassoc c ntable)))) (and (= c ?q) (not (rassoc c ntable))))
(org-detach-overlay org-tags-overlay) (org-detach-overlay org-tags-overlay)