summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-29 10:30:11 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-29 10:31:24 +0200
commit31afe4b718099f9c60885f106948c40c57d8a730 (patch)
tree8b614c90c7e83bbcced68ece670d6b48e0b8b9f3
parent4d568fc83ca73b48a7546c8b528e492b2c387d19 (diff)
downloadorg-mode-31afe4b718099f9c60885f106948c40c57d8a730.tar.gz
Move window-related function to "org-macs.el"
* lisp/org.el (org-switch-to-buffer-other-window): * lisp/org-compat.el (org-fit-window-to-buffer): Move functions... * lisp/org-macs.el: ... here.
-rw-r--r--lisp/org-compat.el17
-rw-r--r--lisp/org-macs.el25
-rw-r--r--lisp/org.el7
3 files changed, 24 insertions, 25 deletions
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 66854fa..cd4cff4 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -478,23 +478,6 @@ use of this function is for the stuck project list."
((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
(w32-get-clipboard-data))))
-(defun org-fit-window-to-buffer (&optional window max-height min-height
- 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 height limit is
-ignored in this case."
- (cond ((if (fboundp 'window-full-width-p)
- (not (window-full-width-p window))
- ;; do nothing if another window would suffer
- (> (frame-width) (window-width window))))
- ((and (fboundp 'fit-window-to-buffer) (not shrink-only))
- (fit-window-to-buffer window max-height min-height))
- ((fboundp 'shrink-window-if-larger-than-buffer)
- (shrink-window-if-larger-than-buffer window)))
- (or window (selected-window)))
-
;; `set-transient-map' is only in Emacs >= 24.4
(defalias 'org-set-transient-map
(if (fboundp 'set-transient-map)
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index efa7481..b1485b3 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -191,7 +191,7 @@ because otherwise all these markers will point to nowhere."
-;;; Buffer
+;;; Buffer and windows
(defun org-base-buffer (buffer)
"Return the base buffer of BUFFER, if it has one. Else return the buffer."
@@ -209,6 +209,29 @@ not an indirect buffer."
(or (buffer-base-buffer buf) buf)
nil)))
+(defun org-switch-to-buffer-other-window (&rest args)
+ "Switch to buffer in a second window on the current frame.
+In particular, do not allow pop-up frames.
+Returns the newly created buffer."
+ (org-no-popups (apply #'switch-to-buffer-other-window args)))
+
+(defun org-fit-window-to-buffer (&optional window max-height min-height
+ 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 height limit is
+ignored in this case."
+ (cond ((if (fboundp 'window-full-width-p)
+ (not (window-full-width-p window))
+ ;; Do nothing if another window would suffer.
+ (> (frame-width) (window-width window))))
+ ((and (fboundp 'fit-window-to-buffer) (not shrink-only))
+ (fit-window-to-buffer window max-height min-height))
+ ((fboundp 'shrink-window-if-larger-than-buffer)
+ (shrink-window-if-larger-than-buffer window)))
+ (or window (selected-window)))
+
;;; File
diff --git a/lisp/org.el b/lisp/org.el
index 092bd97..f316a3e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -21397,13 +21397,6 @@ Returns the number of empty lines passed."
(goto-char (min (point) pos))
(count-lines (point) pos)))
-(defun org-switch-to-buffer-other-window (&rest args)
- "Switch to buffer in a second window on the current frame.
-In particular, do not allow pop-up frames.
-Returns the newly created buffer."
- (org-no-popups
- (apply 'switch-to-buffer-other-window args)))
-
(defun org-replace-escapes (string table)
"Replace %-escapes in STRING with values in TABLE.
TABLE is an association list with keys like \"%a\" and string values.