diff options
| author | David Aspinall | 2004-04-02 16:42:34 +0000 |
|---|---|---|
| committer | David Aspinall | 2004-04-02 16:42:34 +0000 |
| commit | 5235cfdf400896c6a8497243f0ba4d1a3bb97aa0 (patch) | |
| tree | 26ced5eddf751d045770b7fd0eecc82c62953a3d | |
| parent | 6188ab140ae39a314c5a2dce75126cda2da3d228 (diff) | |
Add various GNU <-> XE compatibility functions for display.
| -rw-r--r-- | generic/proof-compat.el | 120 |
1 files changed, 81 insertions, 39 deletions
diff --git a/generic/proof-compat.el b/generic/proof-compat.el index fa2ab37a..abd05843 100644 --- a/generic/proof-compat.el +++ b/generic/proof-compat.el @@ -176,49 +176,41 @@ and replace a sub-expression, e.g. The GNU Emacs implementation of easy-menu-define has a very handy :visible keyword. To use that when it's available, we use this constant.") + +(or (fboundp 'frame-parameter) + (defalias 'frame-parameter 'frame-property)) + +(or (boundp 'window-size-fixed) + (defvar window-size-fixed nil + "Fudged version of GNU Emacs' setting. Completely ignored.")) + +(or (fboundp 'window-text-height) + (defalias 'window-text-height 'window-text-area-height)) + +(or (fboundp 'set-window-text-height) +(defun set-window-text-height (window height) + "Sets the height in lines of the text display area of WINDOW to HEIGHT. +This doesn't include the mode-line (or header-line if any) or any +partial-height lines in the text display area. + +If WINDOW is nil, the selected window is used. + +Note that the current implementation of this function cannot always set +the height exactly, but attempts to be conservative, by allocating more +lines than are actually needed in the case where some error may be present." + (let ((delta (- height (window-text-height window)))) + (unless (zerop delta) + (let ((window-min-height 1)) + (if (and window (not (eq window (selected-window)))) + (save-selected-window + (select-window window) + (enlarge-window delta)) + (enlarge-window delta))))))) -;; Add get-window-with-predicate from Emacs 21.2.1 to XE 21.4.12 -;; Reason: unidentified function(!) calls this during PG startup -(or (fboundp 'get-window-with-predicate) -(defun get-window-with-predicate (predicate &optional minibuf - all-frames default) - "Return a window satisfying PREDICATE. - -This function cycles through all visible windows using `walk-windows', -calling PREDICATE on each one. PREDICATE is called with a window as -argument. The first window for which PREDICATE returns a non-nil -value is returned. If no window satisfies PREDICATE, DEFAULT is -returned. - -Optional second arg MINIBUF t means count the minibuffer window even -if not active. MINIBUF nil or omitted means count the minibuffer iff -it is active. MINIBUF neither t nor nil means not to count the -minibuffer even if it is active. - -Several frames may share a single minibuffer; if the minibuffer -counts, all windows on all frames that share that minibuffer count -too. Therefore, if you are using a separate minibuffer frame -and the minibuffer is active and MINIBUF says it counts, -`walk-windows' includes the windows in the frame from which you -entered the minibuffer, as well as the minibuffer window. - -ALL-FRAMES is the optional third argument. -ALL-FRAMES nil or omitted means cycle within the frames as specified above. -ALL-FRAMES = `visible' means include windows on all visible frames. -ALL-FRAMES = 0 means include windows on all visible and iconified frames. -ALL-FRAMES = t means include windows on all frames including invisible frames. -If ALL-FRAMES is a frame, it means include windows on that frame. -Anything else means restrict to the selected frame." - (catch 'found - (walk-windows #'(lambda (window) - (when (funcall predicate window) - (throw 'found window))) - minibuf all-frames) - default))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; -;;; GNU Emacs compatibility +;;; GNU Emacs compatibility with XEmacs ;;; ;; Chars (borrowed from x-symbol-emacs.el compatability file) @@ -408,6 +400,56 @@ The modified ALIST is returned." (setq alist (cdr alist))) (nreverse newalist)))) +(or (fboundp 'frames-of-buffer) +;; From XEmacs 21.4.12, aliases expanded +(defun frames-of-buffer (&optional buffer visible-only) + "Return list of frames that BUFFER is currently being displayed on. +If the buffer is being displayed on the currently selected frame, that frame +is first in the list. VISIBLE-ONLY will only list non-iconified frames." + (let ((list (get-buffer-window-list buffer)) + (cur-frame (selected-frame)) + next-frame frames save-frame) + + (while list + (if (memq (setq next-frame (window-frame (car list))) + frames) + nil + (if (eq cur-frame next-frame) + (setq save-frame next-frame) + (and + (or (not visible-only) + (frame-visible-p next-frame)) + (setq frames (append frames (list next-frame)))))) + (setq list (cdr list))) + + (if save-frame + (append (list save-frame) frames) + frames)))) + +;; These functions are used in the intricate logic around +;; shrink-to-fit. + +;; window-leftmost-p, window-rightmost-p: my implementations +(or (fboundp 'window-leftmost-p) + (defun window-leftmost-p (window) + (zerop (car (window-edges window))))) + +(or (fboundp 'window-rightmost-p) + (defun window-rightmost-p (window) + (>= (nth 2 (window-edges window)) + (frame-width (window-frame window))))) + +;; with-selected-windown from XEmacs 21.4.12 +(or (fboundp 'with-selected-window) +(defmacro with-selected-window (window &rest body) + "Execute forms in BODY with WINDOW as the selected window. +The value returned is the value of the last form in BODY." + `(save-selected-window + (select-window ,window) + ,@body))) + + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; |
