Now on revision 106343. ------------------------------------------------------------ revno: 106343 committer: Glenn Morris branch nick: trunk timestamp: Wed 2011-11-09 21:36:48 -0500 message: Always use svn --non-interactive in vc-svn.el (bug#9993) * lisp/vc/vc-svn.el (vc-svn-create-repo, vc-svn-modify-change-comment): Call svn via vc-svn-command rather than vc-do-command. (vc-svn-command): Add --non-interactive. (vc-svn-update, vc-svn-merge-news): No need for --non-interactive. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-11-10 02:17:45 +0000 +++ lisp/ChangeLog 2011-11-10 02:36:48 +0000 @@ -1,5 +1,10 @@ 2011-11-10 Glenn Morris + * vc/vc-svn.el (vc-svn-create-repo, vc-svn-modify-change-comment): + Call svn via vc-svn-command rather than vc-do-command. + (vc-svn-command): Add --non-interactive. (Bug#9993) + (vc-svn-update, vc-svn-merge-news): No need for --non-interactive. + * emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions): Add toggle-read-only. (Bug#7292) * files.el (toggle-read-only): Mention that it should only === modified file 'lisp/vc/vc-svn.el' --- lisp/vc/vc-svn.el 2011-03-03 07:27:52 +0000 +++ lisp/vc/vc-svn.el 2011-11-10 02:36:48 +0000 @@ -263,8 +263,8 @@ (defun vc-svn-create-repo () "Create a new SVN repository." (vc-do-command "*vc*" 0 "svnadmin" '("create" "SVN")) - (vc-do-command "*vc*" 0 vc-svn-program '(".") - "checkout" (concat "file://" default-directory "SVN"))) + (vc-svn-command "*vc*" 0 "." "checkout" + (concat "file://" default-directory "SVN"))) (defun vc-svn-register (files &optional rev comment) "Register FILES into the SVN version-control system. @@ -334,7 +334,6 @@ ;; Check out a particular version (or recreate the file). (vc-file-setprop file 'vc-working-revision nil) (apply 'vc-svn-command nil 0 file - "--non-interactive" ; bug#4280 "update" (cond ((null rev) "-rBASE") @@ -373,7 +372,7 @@ (message "Merging changes into %s..." file) ;; (vc-file-setprop file 'vc-working-revision nil) (vc-file-setprop file 'vc-checkout-time 0) - (vc-svn-command nil 0 file "--non-interactive" "update") ; see bug#7152 + (vc-svn-command nil 0 file "update") ;; Analyze the merge result reported by SVN, and set ;; file properties accordingly. (with-current-buffer (get-buffer "*vc*") @@ -425,7 +424,7 @@ or svn+ssh://." (let (tempfile host remotefile directory fileurl-p) (with-temp-buffer - (vc-do-command (current-buffer) 0 vc-svn-program nil "info") + (vc-svn-command (current-buffer) 0 nil "info") (goto-char (point-min)) (unless (re-search-forward "Repository Root: \\(file://\\(/.*\\)\\)\\|\\(svn\\+ssh://\\([^/]+\\)\\(/.*\\)\\)" nil t) (error "Repository information is unavailable")) @@ -581,12 +580,19 @@ (defun vc-svn-command (buffer okstatus file-or-list &rest flags) "A wrapper around `vc-do-command' for use in vc-svn.el. The difference to vc-do-command is that this function always invokes `svn', -and that it passes `vc-svn-global-switches' to it before FLAGS." +and that it passes \"--non-interactive\" and `vc-svn-global-switches' to +it before FLAGS." + ;; Might be nice if svn defaulted to non-interactive if stdin not tty. + ;; http://svn.haxx.se/dev/archive-2008-05/0762.shtml + ;; http://svn.haxx.se/dev/archive-2009-04/0094.shtml + ;; Maybe newer ones do? + (or (member "--non-interactive" + (setq flags (if (stringp vc-svn-global-switches) + (cons vc-svn-global-switches flags) + (append vc-svn-global-switches flags)))) + (setq flags (cons "--non-interactive" flags))) (apply 'vc-do-command (or buffer "*vc*") okstatus vc-svn-program file-or-list - (if (stringp vc-svn-global-switches) - (cons vc-svn-global-switches flags) - (append vc-svn-global-switches - flags)))) + flags)) (defun vc-svn-repository-hostname (dirname) (with-temp-buffer ------------------------------------------------------------ revno: 106342 committer: Glenn Morris branch nick: trunk timestamp: Wed 2011-11-09 21:17:45 -0500 message: toggle-read-only fixes for bugs#7292, 10006. * doc/lispref/buffers.texi (Read Only Buffers): Expand a bit on why toggle-read-only should only be used interactively. * lisp/files.el (toggle-read-only): Mention that it should only be used interactively. * lisp/emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions): Add toggle-read-only. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-11-09 16:18:33 +0000 +++ doc/lispref/ChangeLog 2011-11-10 02:17:45 +0000 @@ -1,3 +1,8 @@ +2011-11-10 Glenn Morris + + * buffers.texi (Read Only Buffers): Expand a bit on why + toggle-read-only should only be used interactively. (Bug#7292) + 2011-11-09 Chong Yidong * windows.texi (Window Sizes): Document window-pixel-edges, === modified file 'doc/lispref/buffers.texi' --- doc/lispref/buffers.texi 2011-10-09 12:26:29 +0000 +++ doc/lispref/buffers.texi 2011-11-10 02:17:45 +0000 @@ -748,10 +748,11 @@ @deffn Command toggle-read-only &optional arg This command toggles whether the current buffer is read-only. It is -intended for interactive use; do not use it in programs. At any given -point in a program, you should know whether you want the read-only flag -on or off; so you can set @code{buffer-read-only} explicitly to the -proper value, @code{t} or @code{nil}. +intended for interactive use; do not use it in programs (it may have +side-effects, such as enabling View mode, and does not affect +read-only text properties). To change the read-only state of a buffer in +a program, explicitly set @code{buffer-read-only} to the proper value. +To temporarily ignore a read-only state, bind @code{inhibit-read-only}. If @var{arg} is non-@code{nil}, it should be a raw prefix argument. @code{toggle-read-only} sets @code{buffer-read-only} to @code{t} if === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-11-09 16:18:33 +0000 +++ lisp/ChangeLog 2011-11-10 02:17:45 +0000 @@ -1,3 +1,10 @@ +2011-11-10 Glenn Morris + + * emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions): + Add toggle-read-only. (Bug#7292) + * files.el (toggle-read-only): Mention that it should only + be used interactively. (Bug#10006) + 2011-11-09 Stefan Monnier * progmodes/compile.el (compilation-error-regexp-alist-alist): === modified file 'lisp/emacs-lisp/bytecomp.el' --- lisp/emacs-lisp/bytecomp.el 2011-09-17 09:29:01 +0000 +++ lisp/emacs-lisp/bytecomp.el 2011-11-10 02:17:45 +0000 @@ -355,7 +355,7 @@ (defvar byte-compile-interactive-only-functions '(beginning-of-buffer end-of-buffer replace-string replace-regexp insert-file insert-buffer insert-file-literally previous-line next-line - goto-line comint-run delete-backward-char) + goto-line comint-run delete-backward-char toggle-read-only) "List of commands that are not meant to be called from Lisp.") (defvar byte-compile-not-obsolete-vars nil === modified file 'lisp/files.el' --- lisp/files.el 2011-11-07 14:34:02 +0000 +++ lisp/files.el 2011-11-10 02:17:45 +0000 @@ -4686,7 +4686,15 @@ "Change whether this buffer is read-only. With prefix argument ARG, make the buffer read-only if ARG is positive, otherwise make it writable. If buffer is read-only -and `view-read-only' is non-nil, enter view mode." +and `view-read-only' is non-nil, enter view mode. + +This function is usually the wrong thing to use in a Lisp program. +It can have side-effects beyond changing the read-only status of a buffer +\(e.g., enabling view mode), and does not affect read-only regions that +are caused by text properties. To make a buffer read-only in Lisp code, +set `buffer-read-only'. To ignore read-only status (whether due to text +properties or buffer state) and make changes, temporarily bind +`inhibit-read-only'." (interactive "P") (if (and arg (if (> (prefix-numeric-value arg) 0) buffer-read-only ------------------------------------------------------------ revno: 106341 committer: Juanma Barranquero branch nick: trunk timestamp: Wed 2011-11-09 17:18:33 +0100 message: Fix typos. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-11-09 14:37:25 +0000 +++ doc/lispref/ChangeLog 2011-11-09 16:18:33 +0000 @@ -1,7 +1,7 @@ 2011-11-09 Chong Yidong * windows.texi (Window Sizes): Document window-pixel-edges, - window-inside-pixel-edges. window-absolute-pixel-edges, and + window-inside-pixel-edges, window-absolute-pixel-edges, and window-inside-absolute-pixel-edges. (Resizing Windows): shrink-window-if-larger-than-buffer works on non-full-width windows. @@ -1102,9 +1102,9 @@ * commands.texi (Misc Events): Add cross-references to where POSITION of a mouse event is described in detail. -2010-08-08 Christoph +2010-08-08 Christoph Scholtes - * control.texi (Handling Errors) : Fix arg name. + * control.texi (Handling Errors) : Fix arg name. 2010-08-08 Juanma Barranquero === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-11-09 15:39:32 +0000 +++ lisp/ChangeLog 2011-11-09 16:18:33 +0000 @@ -14,6 +14,12 @@ (compilation-next-error-function): Obey the target buffer's compilation-error-screen-columns. +2011-11-09 Juanma Barranquero + + * progmodes/meta-mode.el: Remove obsolete comments. + (meta-right-comment-regexp, meta-ignore-comment-regexp): + Fix typos in docstrings. + 2011-11-09 Martin Rudalics * window.el (window-size-fixed-p): Rewrite doc-string. === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-11-03 23:28:52 +0000 +++ lisp/gnus/ChangeLog 2011-11-09 16:18:33 +0000 @@ -18491,7 +18491,7 @@ 2004-10-05 Jesper Harder * nnsoup.el (nnsoup-read-active-file): Use dolist, mapc or last - where approriate. + where appropriate. * nnml.el (nnml-generate-active-info): do. === modified file 'lisp/progmodes/gud.el' --- lisp/progmodes/gud.el 2011-10-20 00:26:14 +0000 +++ lisp/progmodes/gud.el 2011-11-09 16:18:33 +0000 @@ -2155,7 +2155,7 @@ string (concat "[ \t\n\r,\"" path-separator "]+"))))) -;; See comentary for other debugger's marker filters - there you will find +;; See commentary for other debugger's marker filters - there you will find ;; important notes about STRING. (defun gud-jdb-marker-filter (string) === modified file 'lisp/progmodes/meta-mode.el' --- lisp/progmodes/meta-mode.el 2011-06-20 16:02:31 +0000 +++ lisp/progmodes/meta-mode.el 2011-11-09 16:18:33 +0000 @@ -27,53 +27,17 @@ ;; ;; This Emacs Lisp package provides a major mode for editing Metafont ;; or MetaPost sources. It includes all the necessary code to set up -;; a major mode including an approriate syntax table, keymap, and a +;; a major mode including an appropriate syntax table, keymap, and a ;; mode-specific pull-down menu. It also provides a sophisticated set ;; of font-lock patterns, a fancy indentation function adapted from ;; AUCTeX's latex.el, and some basic mode-specific editing functions ;; such as functions to move to the beginning or end of the enclosing ;; environment, or to mark, re-indent, or comment-out environments. ;; On the other hand, it doesn't yet provide any functionality for -;; running Metafont or MetaPost in a shell buffer form within Emacs, +;; running Metafont or MetaPost in a shell buffer from within Emacs, ;; but such functionality might be added later, either as part of this ;; package or as a separate Emacs Lisp package. -;; Installation: -;; -;; An interface to running Metafont or MetaPost as a shell process -;; from within Emacs is currently under development as a separate -;; Emacs Lisp package (meta-buf.el). In order to have that package -;; loaded automatically when first entering Metafont or MetaPost mode, -;; you might use the load-hook provided in this package by adding -;; these lines to your startup file: -;; -;; (add-hook 'meta-mode-load-hook -;; (lambda () (require 'meta-buf))) -;; -;; The add-on package loaded this way may in turn make use of the -;; mode-hooks provided in this package to activate additional features -;; when entering Metafont or MetaPost mode. - -;; Font Lock Support: -;; -;; If you are using global-font-lock-mode (introduced in Emacs 19.31), -;; fontification in Metafont and/or MetaPost mode will be activated -;; automatically. To speed up fontification for the rather complex -;; patterns used in these modes, it may be a good idea to activate -;; lazy-lock as a font-lock-support-mode (introduced in Emacs 19.32) -;; by adding these lines to your startup file: -;; -;; (global-font-lock-mode t) -;; (setq font-lock-support-mode 'lazy-lock-mode) -;; -;; If you are using an older version of Emacs, which doesn't provide -;; global-font-lock-mode or font-lock-support-mode, you can also -;; activate fontification in Metafont and/or MetaPost mode by adding -;; the following lines to your startup file: -;; -;; (add-hook 'meta-common-mode-hook 'turn-on-font-lock) -;; (add-hook 'meta-common-mode-hook 'turn-on-lazy-lock) - ;; Customization: ;; ;; Following the usual Emacs Lisp coding conventions, the major modes @@ -88,10 +52,6 @@ ;; Availability: ;; -;; This package is currently available via my "TeX Software" WWW page: -;; -;; http://www.thphy.uni-duesseldorf.de/~vieth/subjects/tex/software.html -;; ;; As of this version 1.0, this package will be uploaded to CTAN ;; archives, where it shall find a permanent home, presumably in ;; tex-archive/support/emacs-modes. It will also be submitted for @@ -104,7 +64,7 @@ ;; v 0.2 -- 1997/02/03 UV Improved and debugged font-lock patterns. ;; Added indent-line-function for TAB. ;; v 0.3 -- 1997/02/17 UV Improved font-lock patterns and syntax table. -;; Improved and debbuged indentation function. +;; Improved and debugged indentation function. ;; v 0.4 -- 1997/02/18 UV Added functions to indent regions for M-C-q, ;; also added a preliminary mode-specific menu. ;; v 0.5 -- 1997/02/19 UV Added functions to skip to next or previous @@ -513,13 +473,13 @@ :group 'meta-font) (defcustom meta-right-comment-regexp nil - "Regexp matching comments that should be placed to the right margin." + "Regexp matching comments that should be placed on the right margin." :type '(choice regexp (const :tag "None" nil)) :group 'meta-font) (defcustom meta-ignore-comment-regexp "%[^%]" - "Regexp matching comments that whose indentation should not be touched." + "Regexp matching comments whose indentation should not be touched." :type 'regexp :group 'meta-font) ------------------------------------------------------------ revno: 106340 fixes bug(s): http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9749 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2011-11-09 10:39:32 -0500 message: * lisp/progmodes/compile.el: Adjust regexp for OCaml warnings. (compilation-error-regexp-alist-alist): OCaml warnings (can?) have a number. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-11-09 15:10:25 +0000 +++ lisp/ChangeLog 2011-11-09 15:39:32 +0000 @@ -1,5 +1,8 @@ 2011-11-09 Stefan Monnier + * progmodes/compile.el (compilation-error-regexp-alist-alist): + Adjust regexp for OCaml warnings. + * electric.el (electric-pair-post-self-insert-function): Let user turn it off buffer-locally (bug#9932). === modified file 'lisp/progmodes/compile.el' --- lisp/progmodes/compile.el 2011-11-09 14:04:13 +0000 +++ lisp/progmodes/compile.el 2011-11-09 15:39:32 +0000 @@ -157,7 +157,7 @@ (python-tracebacks-and-caml "^[ \t]*File \\(\"?\\)\\([^,\" \n\t<>]+\\)\\1, lines? \\([0-9]+\\)-?\\([0-9]+\\)?\\(?:$\\|,\ -\\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:\\)?\\([ \n]Warning:\\)?\\)" +\\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:\\)?\\([ \n]Warning\\(?: [0-9]+\\)?:\\)?\\)" 2 (3 . 4) (5 . 6) (7)) (comma === modified file 'test/automated/compile-tests.el' --- test/automated/compile-tests.el 2011-05-09 01:22:05 +0000 +++ test/automated/compile-tests.el 2011-11-09 15:39:32 +0000 @@ -71,7 +71,7 @@ ;; caml ("File \"foobar.ml\", lines 5-8, characters 20-155: blah blah" 1 (19 . 155) (5 . 8) "foobar.ml") - ("File \"F:\\ocaml\\sorting.ml\", line 65, characters 2-145:" + ("File \"F:\\ocaml\\sorting.ml\", line 65, characters 2-145:\nWarning 26: unused variable equ." 1 (1 . 145) 65 "F:\\ocaml\\sorting.ml") ("File \"/usr/share/gdesklets/display/TargetGauge.py\", line 41, in add_children" 1 nil 41 "/usr/share/gdesklets/display/TargetGauge.py") ------------------------------------------------------------ revno: 106339 fixes bug(s): http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9932 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2011-11-09 10:10:25 -0500 message: * lisp/electric.el (electric-pair-post-self-insert-function): Let user turn it off buffer-locally. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-11-09 15:00:32 +0000 +++ lisp/ChangeLog 2011-11-09 15:10:25 +0000 @@ -1,5 +1,8 @@ 2011-11-09 Stefan Monnier + * electric.el (electric-pair-post-self-insert-function): Let user + turn it off buffer-locally (bug#9932). + * progmodes/python.el (python-beginning-of-statement): Rewrite (bug#2703). === modified file 'lisp/electric.el' --- lisp/electric.el 2011-10-19 12:54:24 +0000 +++ lisp/electric.el 2011-11-09 15:10:25 +0000 @@ -284,6 +284,7 @@ (defun electric-pair-post-self-insert-function () (let* ((syntax (and (eq (char-before) last-command-event) ; Sanity check. + electric-pair-mode (let ((x (assq last-command-event electric-pair-pairs))) (cond (x (if (eq (car x) (cdr x)) ?\" ?\()) ------------------------------------------------------------ revno: 106338 fixes bug(s): http://debbugs.gnu.org/cgi/bugreport.cgi?bug=2703 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2011-11-09 10:00:32 -0500 message: * lisp/progmodes/python.el (python-beginning-of-statement): Rewrite. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-11-09 14:04:13 +0000 +++ lisp/ChangeLog 2011-11-09 15:00:32 +0000 @@ -1,5 +1,8 @@ 2011-11-09 Stefan Monnier + * progmodes/python.el (python-beginning-of-statement): + Rewrite (bug#2703). + * progmodes/compile.el: Better handle TABs (bug#9749). (compilation-internal-error-properties) (compilation-next-error-function): Obey the target buffer's === modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2011-09-10 21:15:28 +0000 +++ lisp/progmodes/python.el 2011-11-09 15:00:32 +0000 @@ -948,22 +948,12 @@ "Go to start of current statement. Accounts for continuation lines, multi-line strings, and multi-line bracketed expressions." - (beginning-of-line) - (python-beginning-of-string) - (let (point) - (while (and (python-continuation-line-p) - (if point - (< (point) point) - t)) - (beginning-of-line) + (while (if (python-backslash-continuation-line-p) - (progn - (forward-line -1) - (while (python-backslash-continuation-line-p) - (forward-line -1))) - (python-beginning-of-string) - (python-skip-out)) - (setq point (point)))) + (progn (forward-line -1) t) + (beginning-of-line) + (or (python-beginning-of-string) + (python-skip-out)))) (back-to-indentation)) (defun python-skip-out (&optional forward syntax) @@ -971,6 +961,7 @@ Skip forward if FORWARD is non-nil, else backward. If SYNTAX is non-nil it is the state returned by `syntax-ppss' at point. Return non-nil if and only if skipping was done." + ;; FIXME: Use syntax-ppss-toplevel-pos. (let ((depth (syntax-ppss-depth (or syntax (syntax-ppss)))) (forward (if forward -1 1))) (unless (zerop depth) ------------------------------------------------------------ revno: 106337 committer: Chong Yidong branch nick: trunk timestamp: Wed 2011-11-09 22:37:25 +0800 message: Document window-pixel-edges etc in Lisp manual. * doc/lispref/windows.texi (Window Sizes): Document window-pixel-edges, window-inside-pixel-edges. window-absolute-pixel-edges, and window-inside-absolute-pixel-edges. (Resizing Windows): shrink-window-if-larger-than-buffer works on non-full-width windows. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-11-09 09:36:05 +0000 +++ doc/lispref/ChangeLog 2011-11-09 14:37:25 +0000 @@ -1,3 +1,11 @@ +2011-11-09 Chong Yidong + + * windows.texi (Window Sizes): Document window-pixel-edges, + window-inside-pixel-edges. window-absolute-pixel-edges, and + window-inside-absolute-pixel-edges. + (Resizing Windows): shrink-window-if-larger-than-buffer works on + non-full-width windows. + 2011-11-09 Martin Rudalics * windows.texi (Resizing Windows): Rewrite documentation of === modified file 'doc/lispref/windows.texi' --- doc/lispref/windows.texi 2011-11-09 09:36:05 +0000 +++ doc/lispref/windows.texi 2011-11-09 14:37:25 +0000 @@ -375,13 +375,13 @@ line (@pxref{Mode Line Format}). Emacs provides several functions for finding the height and width of -a window. Most of these functions report the values as integer -multiples of the default character height and width. On a graphical -display, the actual screen size of this default height and width are -those specified by the frame's default font. Hence, if the buffer -contains text that is displayed in a different size, the reported -height and width of the window may differ from the actual number of -text lines or columns displayed in it. +a window. Except where noted, these heights and widths are reported +as integer numbers of lines and columns respectively. On a graphical +display, each ``line'' and ``column'' actually corresponds to the +height and width of a ``default'' character specified by the frame's +default font. Thus, if a window is displaying text with a different +font or size, the reported height and width for that window may differ +from the actual number of text lines or columns displayed within it. @cindex window height @cindex height of a window @@ -534,6 +534,45 @@ function @code{window-resizable}. @xref{Resizing Windows}. @end defun + The following functions can be used to find a window's size and +position in pixels. Though mostly useful on graphical displays, they +can also be called on text-only terminals, where the screen area of +each text character is taken to be ``one pixel''. + +@defun window-pixel-edges &optional window +This function return a list of pixel coordinates for the edges of +@var{window}. If @var{window} is omitted or @code{nil}, it defaults +to the selected window. + +The return value has the form @code{(@var{left} @var{top} @var{right} +@var{bottom})}. The list elements are, respectively, the X coordinate +of the left window edge, the Y coordinate of the top edge, one more +than the X coordinate of the right edge, and one more than the Y +coordinate of the bottom edge. The origin coordinate @samp{(0,0)} is +taken to be the top left corner of the frame's window area. + +These edge values include the space used by the window's scroll bar, +margins, fringes, header line, and mode line, if any. +@end defun + +@defun window-inside-pixel-edges &optional window +This function is like @code{window-pixel-edges}, except that it +returns the edge coordinates for the window's text area, rather than +the edge coordinates for the window itself. @var{window} must specify +a live window. +@end defun + +@defun window-absolute-pixel-edges &optional window +This function is like @code{window-pixel-edges}, except that it +returns the edge coordinates relative to the top left corner of the +display screen. +@end defun + +@defun window-inside-absolute-pixel-edges &optional window +This function is like @code{window-inside-pixel-edges}, except that it +returns the edge coordinates relative to the top left corner of the +display screen. @var{window} must specify a live window. +@end defun @node Resizing Windows @section Resizing Windows @@ -604,104 +643,85 @@ @c shrink-window, and shrink-window-horizontally are documented in the @c Emacs manual. They are not preferred for calling from Lisp. - The following function is useful for moving the line dividing two -windows. - @defun adjust-window-trailing-edge window delta &optional horizontal This function moves @var{window}'s bottom edge by @var{delta} lines. -Optional argument @var{horizontal} non-@code{nil} means to move -@var{window}'s right edge by @var{delta} columns. The argument -@var{window} defaults to the selected window. +If optional argument @var{horizontal} is non-@code{nil}, it instead +moves the right edge by @var{delta} columns. If @var{window} is +@code{nil}, it defaults to the selected window. -If @var{delta} is greater zero, this moves the edge downwards or to the -right. If @var{delta} is less than zero, this moves the edge upwards or -to the left. If the edge can't be moved by @var{delta} lines or columns, -it is moved as far as possible in the desired direction but no error is -signaled. +A positive @var{delta} moves the edge downwards or to the right; a +negative @var{delta} moves it upwards or to the left. If the edge +cannot be moved as far as specified by @var{delta}, this function +moves it as far as possible but does not signal a error. This function tries to resize windows adjacent to the edge that is -moved. Only if this is insufficient, it will also resize windows not -adjacent to that edge. As a consequence, if you move an edge in one -direction and back in the other direction by the same amount, the -resulting window configuration will not be necessarily identical to the -one before the first move. So if your intend to just resize -@var{window}, you should not use this function but call -@code{window-resize} (see above) instead. +moved. If this is not possible for some reason (e.g. if that adjacent +window is fixed-size), it may resize other windows. @end defun + The following commands resize windows in more specific ways. When +called interactively, they act on the selected window. + @deffn Command fit-window-to-buffer &optional window max-height min-height override -This command makes @var{window} the right height to display its -contents exactly. The default for @var{window} is the selected window. - -The optional argument @var{max-height} specifies the maximum total -height the window is allowed to be; @code{nil} means use the maximum -permissible height of a window on @var{window}'s frame. The optional -argument @var{min-height} specifies the minimum total height for the -window; @code{nil} means use @code{window-min-height}. All these height -values include the mode line and/or header line. - -If the optional argument @var{override} is non-@code{nil}, this means to -ignore any restrictions imposed by @code{window-min-height} and -@code{window-min-width} on the size of @var{window}. - -This function returns non-@code{nil} if it orderly resized @var{window}, -and @code{nil} otherwise. +This command adjusts the height of @var{window} to fit the text in it. +It returns non-@code{nil} if it was able to resize @var{window}, and +@code{nil} otherwise. If @var{window} is omitted or @code{nil}, it +defaults to the selected window. Otherwise, it should be a live +window. + +The optional argument @var{max-height}, if non-@code{nil}, specifies +the maximum total height that this function can give @var{window}. +The optional argument @var{min-height}, if no-@code{nil}, specifies +the minimum total height that it can give, which overrides the +variable @code{window-min-height}. + +If the optional argument @var{override} is non-@code{nil}, this +function ignores any size restrictions imposed by +@code{window-min-height} and @code{window-min-width}. @end deffn @deffn Command shrink-window-if-larger-than-buffer &optional window -This command shrinks @var{window} vertically to be as small as possible -while still showing the full contents of its buffer---but not less than -@code{window-min-height} lines. The argument @var{window} must denote -a live window and defaults to the selected one. - -However, this command does nothing if the window is already too small to -display the whole text of the buffer, or if part of the contents are -currently scrolled off screen, or if the window is not the full width of -its frame, or if the window is the only window in its frame. - -This command returns non-@code{nil} if it actually shrank the window -and @code{nil} otherwise. +This command attempts to reduce @var{window}'s height as much as +possible while still showing its full buffer, but no less than +@code{window-min-height} lines. The return value is non-@code{nil} if +the window was resized, and @code{nil} otherwise. If @var{window} is +omitted or @code{nil}, it defaults to the selected window. Otherwise, +it should be a live window. + +This command does nothing if the window is already too short to +display all of its buffer, or if any of the buffer is scrolled +off-screen, or if the window is the only live window in its frame. @end deffn @cindex balancing window sizes -Emacs provides two functions to balance windows, that is, to even out -the sizes of all windows on the same frame. The minibuffer window and -fixed-size windows are not resized by these functions. - @deffn Command balance-windows &optional window-or-frame This function balances windows in a way that gives more space to full-width and/or full-height windows. If @var{window-or-frame} specifies a frame, it balances all windows on that frame. If -@var{window-or-frame} specifies a window, it balances that window and -its siblings (@pxref{Windows and Frames}) only. +@var{window-or-frame} specifies a window, it balances only that window +and its siblings (@pxref{Windows and Frames}). @end deffn @deffn Command balance-windows-area This function attempts to give all windows on the selected frame -approximately the same share of the screen area. This means that -full-width or full-height windows are not given more space than other -windows. +approximately the same share of the screen area. Full-width or +full-height windows are not given more space than other windows. @end deffn @cindex maximizing windows -The following function can be used to give a window the maximum possible -size without deleting other ones. - @deffn Command maximize-window &optional window -This function maximizes @var{window}. More precisely, this makes -@var{window} as large as possible without resizing its frame or deleting -other windows. @var{window} can be any window and defaults to the -selected one. +This function attempts to make @var{window} as large as possible, in +both dimensions, without resizing its frame or deleting other windows. +If @var{window} is omitted or @code{nil}, it defaults to the selected +window. @end deffn @cindex minimizing windows -To make a window as small as possible without deleting it the -following function can be used. - @deffn Command minimize-window &optional window -This function minimizes @var{window}. More precisely, this makes -@var{window} as small as possible without deleting it or resizing its -frame. @var{window} can be any window and defaults to the selected one. +This function attempts to make @var{window} as small as possible, in +both dimensions, without deleting it or resizing its frame. If +@var{window} is omitted or @code{nil}, it defaults to the selected +window. @end deffn @@ -719,7 +739,7 @@ to the selected window. That window is ``split'', and reduced in size. The space is taken up by the new window, which is returned. -The optional second argument @var{size} determines the sizes of the +The optional second argument @var{size} determines the sizes of @var{window} and/or the new window. If it is omitted or @code{nil}, both windows are given equal sizes; if there is an odd line, it is allocated to the new window. If @var{size} is a positive number, @@ -765,10 +785,10 @@ As an example, we show a combination of @code{split-window} calls that yields the window configuration discussed in @ref{Windows and -Frames}. This example demonstrates splitting live windows as well as -splitting internal windows. We begin with a frame containing a single -window (a live root window), which we denote by @var{W4}. Calling -@code{(split-window W3)} yields this window configuration: +Frames}. This example demonstrates splitting a live window as well as +splitting an internal window. We begin with a frame containing a +single window (a live root window), which we denote by @var{W4}. +Calling @code{(split-window W3)} yields this window configuration: @smallexample @group @@ -816,10 +836,9 @@ @end smallexample @noindent -A new live window, @var{W2}, is created to the left of @var{W3} (which -encompasses the vertical window combination of @var{W4} and @var{W5}). -A new internal window @var{W1} is also created, and becomes the new -root window. +A new live window @var{W2} is created, to the left of the internal +window @var{W3}. A new internal window @var{W1} is created, becoming +the new root window. The following two options can be used to modify the operation of @code{split-window}. ------------------------------------------------------------ revno: 106336 committer: Chong Yidong branch nick: trunk timestamp: Wed 2011-11-09 22:29:23 +0800 message: Disallow calling window-inside-edges and related functions on internal windows. * src/window.c (Fwindow_inside_edges, Fwindow_inside_pixel_edges) (Fwindow_inside_absolute_pixel_edges): Only allow live windows. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-11-08 20:15:17 +0000 +++ src/ChangeLog 2011-11-09 14:29:23 +0000 @@ -1,3 +1,8 @@ +2011-11-09 Chong Yidong + + * window.c (Fwindow_inside_edges, Fwindow_inside_pixel_edges) + (Fwindow_inside_absolute_pixel_edges): Only allow live windows. + 2011-11-08 Paul Eggert * s/gnu.h (GC_MARK_STACK): Define to GC_MAKE_GCPROS_NOOPS (Bug#9926). === modified file 'src/window.c' --- src/window.c 2011-11-08 07:25:56 +0000 +++ src/window.c 2011-11-09 14:29:23 +0000 @@ -859,7 +859,7 @@ bar, display margins, fringes, header line, and/or mode line. */) (Lisp_Object window) { - register struct window *w = decode_any_window (window); + register struct window *w = decode_window (window); return list4 (make_number (WINDOW_BOX_LEFT_EDGE_COL (w) + WINDOW_LEFT_MARGIN_COLS (w) @@ -874,9 +874,9 @@ } DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0, - doc: /* Return a list of the edge pixel coordinates of WINDOW. -The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at -the top left corner of the frame. + doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. +The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0) +at the top left corner of the frame's window area. RIGHT is one more than the rightmost x position of WINDOW's text area. BOTTOM is one more than the bottommost y position of WINDOW's text area. @@ -884,7 +884,7 @@ display margins, fringes, header line, and/or mode line. */) (Lisp_Object window) { - register struct window *w = decode_any_window (window); + register struct window *w = decode_window (window); return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w) + WINDOW_LEFT_MARGIN_WIDTH (w) @@ -901,9 +901,9 @@ DEFUN ("window-inside-absolute-pixel-edges", Fwindow_inside_absolute_pixel_edges, Swindow_inside_absolute_pixel_edges, 0, 1, 0, - doc: /* Return a list of the edge pixel coordinates of WINDOW. -The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at -the top left corner of the display. + doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. +The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0) +at the top left corner of the frame's window area. RIGHT is one more than the rightmost x position of WINDOW's text area. BOTTOM is one more than the bottommost y position of WINDOW's text area. @@ -911,7 +911,7 @@ display margins, fringes, header line, and/or mode line. */) (Lisp_Object window) { - register struct window *w = decode_any_window (window); + register struct window *w = decode_window (window); int add_x, add_y; calc_absolute_offset (w, &add_x, &add_y); ------------------------------------------------------------ revno: 106335 fixes bug(s): http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9749 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2011-11-09 09:04:13 -0500 message: * lisp/progmodes/compile.el: Better handle TABs. (compilation-internal-error-properties) (compilation-next-error-function): Obey the target buffer's compilation-error-screen-columns. diff: === modified file 'etc/NEWS' --- etc/NEWS 2011-11-06 06:14:01 +0000 +++ etc/NEWS 2011-11-09 14:04:13 +0000 @@ -621,6 +621,10 @@ inserted by the compilation filter function, when calling compilation-filter-hook. +*** `compilation-error-screen-columns' is obeyed in the editing buffer. +So programming language modes can set it, whereas previously only the value +in the *compilation* buffer was used. + ** Customize *** Customize buffers now contain a search field. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-11-09 09:36:05 +0000 +++ lisp/ChangeLog 2011-11-09 14:04:13 +0000 @@ -1,8 +1,14 @@ +2011-11-09 Stefan Monnier + + * progmodes/compile.el: Better handle TABs (bug#9749). + (compilation-internal-error-properties) + (compilation-next-error-function): Obey the target buffer's + compilation-error-screen-columns. + 2011-11-09 Martin Rudalics * window.el (window-size-fixed-p): Rewrite doc-string. - (window-resizable-p): Rename to window--resizable-p. Update - callers. + (window-resizable-p): Rename to window--resizable-p. Update callers. (window--resizable): New function. Make all callers of window-resizable call window--resizable instead. (window-resizable): Rewrite in terms of window--resizable. @@ -90,7 +96,7 @@ (window-size-ignore, window-state-get): Callers changed. (window-normalize-window): Rename from window-normalize-any-window. New arg LIVE-ONLY, replacing window-normalize-live-window. - (window-normalize-live-window): Deleted. + (window-normalize-live-window): Delete. (window-combination-p, window-combined-p, window-combinations) (walk-window-subtree, window-atom-root, window-min-size) (window-sizable, window-sizable-p, window-size-fixed-p) === modified file 'lisp/progmodes/compile.el' --- lisp/progmodes/compile.el 2011-10-20 00:26:14 +0000 +++ lisp/progmodes/compile.el 2011-11-09 14:04:13 +0000 @@ -1056,7 +1056,7 @@ (cadr (compilation--file-struct->loc-tree file-struct))) (marker (if marker-line (compilation--loc->marker (cadr marker-line)))) - (compilation-error-screen-columns compilation-error-screen-columns) + (screen-columns compilation-error-screen-columns) end-marker loc end-loc) (if (not (and marker (marker-buffer marker))) (setq marker nil) ; no valid marker for this file @@ -1064,16 +1064,21 @@ (catch 'marker ; find nearest loc, at least one exists (dolist (x (cddr (compilation--file-struct->loc-tree file-struct))) ; Loop over remaining lines. - (if (> (car x) loc) ; still bigger + (if (> (car x) loc) ; Still bigger. (setq marker-line x) (if (> (- (or (car marker-line) 1) loc) - (- loc (car x))) ; current line is nearer + (- loc (car x))) ; Current line is nearer. (setq marker-line x)) (throw 'marker t)))) (setq marker (compilation--loc->marker (cadr marker-line)) marker-line (or (car marker-line) 1)) (with-current-buffer (marker-buffer marker) - (save-excursion + (let ((screen-columns + ;; Obey the compilation-error-screen-columns of the target + ;; buffer if its major mode set it buffer-locally. + (if (local-variable-p 'compilation-error-screen-columns) + compilation-error-screen-columns screen-columns))) + (save-excursion (save-restriction (widen) (goto-char (marker-position marker)) @@ -1081,17 +1086,15 @@ (beginning-of-line (- (or end-line line) marker-line -1)) (if (or (null end-col) (< end-col 0)) (end-of-line) - (compilation-move-to-column - end-col compilation-error-screen-columns)) + (compilation-move-to-column end-col screen-columns)) (setq end-marker (point-marker))) (beginning-of-line (if end-line (- line end-line -1) (- loc marker-line -1))) (if col - (compilation-move-to-column - col compilation-error-screen-columns) + (compilation-move-to-column col screen-columns) (forward-to-indentation 0)) - (setq marker (point-marker)))))) + (setq marker (point-marker))))))) (setq loc (compilation-assq line (compilation--file-struct->loc-tree file-struct))) @@ -2266,7 +2269,7 @@ (interactive "p") (when reset (setq compilation-current-error nil)) - (let* ((columns compilation-error-screen-columns) ; buffer's local value + (let* ((screen-columns compilation-error-screen-columns) (last 1) (msg (compilation-next-error (or n 1) nil (or compilation-current-error @@ -2301,29 +2304,34 @@ marker (caar (compilation--loc->file-struct loc)) (cadr (car (compilation--loc->file-struct loc)))) - (save-restriction - (widen) - (goto-char (point-min)) - ;; Treat file's found lines in forward order, 1 by 1. - (dolist (line (reverse (cddr (compilation--loc->file-struct loc)))) - (when (car line) ; else this is a filename w/o a line# - (beginning-of-line (- (car line) last -1)) - (setq last (car line))) - ;; Treat line's found columns and store/update a marker for each. - (dolist (col (cdr line)) - (if (compilation--loc->col col) - (if (eq (compilation--loc->col col) -1) - ;; Special case for range end. - (end-of-line) - (compilation-move-to-column (compilation--loc->col col) - columns)) - (beginning-of-line) - (skip-chars-forward " \t")) - (if (compilation--loc->marker col) - (set-marker (compilation--loc->marker col) (point)) - (setf (compilation--loc->marker col) (point-marker))) - ;; (setf (compilation--loc->timestamp col) timestamp) - ))))) + (let ((screen-columns + ;; Obey the compilation-error-screen-columns of the target + ;; buffer if its major mode set it buffer-locally. + (if (local-variable-p 'compilation-error-screen-columns) + compilation-error-screen-columns screen-columns))) + (save-restriction + (widen) + (goto-char (point-min)) + ;; Treat file's found lines in forward order, 1 by 1. + (dolist (line (reverse (cddr (compilation--loc->file-struct loc)))) + (when (car line) ; else this is a filename w/o a line# + (beginning-of-line (- (car line) last -1)) + (setq last (car line))) + ;; Treat line's found columns and store/update a marker for each. + (dolist (col (cdr line)) + (if (compilation--loc->col col) + (if (eq (compilation--loc->col col) -1) + ;; Special case for range end. + (end-of-line) + (compilation-move-to-column (compilation--loc->col col) + screen-columns)) + (beginning-of-line) + (skip-chars-forward " \t")) + (if (compilation--loc->marker col) + (set-marker (compilation--loc->marker col) (point)) + (setf (compilation--loc->marker col) (point-marker))) + ;; (setf (compilation--loc->timestamp col) timestamp) + )))))) (compilation-goto-locus marker (compilation--loc->marker loc) (compilation--loc->marker end-loc)) (setf (compilation--loc->visited loc) t))) ------------------------------------------------------------ revno: 106334 committer: martin rudalics branch nick: trunk timestamp: Wed 2011-11-09 10:36:05 +0100 message: Rewrite window-resizable. * window.el (window-size-fixed-p): Rewrite doc-string. (window-resizable-p): Rename to window--resizable-p. Update callers. (window--resizable): New function. Make all callers of window-resizable call window--resizable instead. (window-resizable): Rewrite in terms of window--resizable. * windows.texi (Resizing Windows): Rewrite documentation of window-resizable. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-11-09 07:56:50 +0000 +++ doc/lispref/ChangeLog 2011-11-09 09:36:05 +0000 @@ -1,3 +1,8 @@ +2011-11-09 Martin Rudalics + + * windows.texi (Resizing Windows): Rewrite documentation of + window-resizable. + 2011-11-09 Chong Yidong * windows.texi (Splitting Windows): Simplify example. === modified file 'doc/lispref/windows.texi' --- doc/lispref/windows.texi 2011-11-09 07:56:50 +0000 +++ doc/lispref/windows.texi 2011-11-09 09:36:05 +0000 @@ -553,7 +553,7 @@ arguments. Resizing an internal window causes its child windows to be resized to fit the same space. -@defun window-resizable window delta &optional horizontal ignore side noup nodown +@defun window-resizable window delta &optional horizontal ignore This function returns @var{delta} if the size of @var{window} can be changed vertically by @var{delta} lines. If the optional argument @var{horizontal} is non-@code{nil}, it instead returns @var{delta} if @@ -562,10 +562,11 @@ If @var{window} is @code{nil}, it defaults to the selected window. -A positive value of @var{delta} enlarges the window by that number of -lines or columns; a negative value of @var{delta} shrinks it. If -@var{delta} is non-zero, a return value of 0 means that the window -cannot be resized. +A positive value of @var{delta} means to check whether the window can be +enlarged by that number of lines or columns; a negative value of +@var{delta} means to check whether the window can be shrunk by that many +lines or columns. If @var{delta} is non-zero, a return value of 0 means +that the window cannot be resized. Normally, the variables @code{window-min-height} and @code{window-min-width} specify the smallest allowable window size. @@ -577,12 +578,6 @@ of a header (if any), a mode line, plus a text area one line tall; and a minimum-width window as one consisting of fringes, margins, and scroll bar (if any), plus a text area two columns wide. - -If the optional argument @var{noup} is non-@code{nil}, this function -considers a resize operation that does not alter the window parent of -@var{window}, only its siblings. If the optional argument -@var{nodown} is non-@code{nil}, it does not attempt to check whether -@var{window} itself and its child windows can be resized. @end defun @defun window-resize window delta &optional horizontal ignore === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-11-08 19:19:36 +0000 +++ lisp/ChangeLog 2011-11-09 09:36:05 +0000 @@ -1,3 +1,12 @@ +2011-11-09 Martin Rudalics + + * window.el (window-size-fixed-p): Rewrite doc-string. + (window-resizable-p): Rename to window--resizable-p. Update + callers. + (window--resizable): New function. Make all callers of + window-resizable call window--resizable instead. + (window-resizable): Rewrite in terms of window--resizable. + 2011-11-08 Glenn Morris * progmodes/delphi.el (delphi-mode-syntax-table): === modified file 'lisp/window.el' --- lisp/window.el 2011-11-08 19:06:29 +0000 +++ lisp/window.el 2011-11-09 09:36:05 +0000 @@ -704,8 +704,8 @@ non-nil if WINDOW's width is fixed. If this function returns nil, this does not necessarily mean that -WINDOW can be resized in the desired direction. The functions -`window-resizable' and `window-resizable-p' will tell that." +WINDOW can be resized in the desired direction. The function +`window-resizable' can tell that." (window-size-fixed-1 (window-normalize-window window) horizontal)) @@ -865,14 +865,14 @@ (window-max-delta-1 window 0 horizontal ignore trail noup))) ;; Make NOUP also inhibit the min-size check. -(defun window-resizable (window delta &optional horizontal ignore trail noup nodown) +(defun window--resizable (window delta &optional horizontal ignore trail noup nodown) "Return DELTA if WINDOW can be resized vertically by DELTA lines. Optional argument HORIZONTAL non-nil means return DELTA if WINDOW can be resized horizontally by DELTA columns. A return value of zero means that WINDOW is not resizable. DELTA positive means WINDOW shall be enlarged by DELTA lines or -columns. If WINDOW cannot be enlarged by DELTA lines or columns +columns. If WINDOW cannot be enlarged by DELTA lines or columns, return the maximum value in the range 0..DELTA by which WINDOW can be enlarged. @@ -894,11 +894,12 @@ shrunk. Optional argument NOUP non-nil means don't go up in the window -tree but try to distribute the space among the other windows -within WINDOW's combination. +tree but check only whether space can be obtained from (or given +to) WINDOW's siblings. -Optional argument NODOWN non-nil means don't check whether WINDOW -and its child windows can be resized." +Optional argument NODOWN non-nil means don't go down in the +window tree. This means do not check whether resizing would +violate size restrictions of WINDOW or its child windows." (setq window (window-normalize-window window)) (cond ((< delta 0) @@ -909,17 +910,42 @@ delta)) (t 0))) -(defun window-resizable-p (window delta &optional horizontal ignore trail noup nodown) +(defun window--resizable-p (window delta &optional horizontal ignore trail noup nodown) "Return t if WINDOW can be resized vertically by DELTA lines. For the meaning of the arguments of this function see the -doc-string of `window-resizable'." +doc-string of `window--resizable'." (setq window (window-normalize-window window)) (if (> delta 0) - (>= (window-resizable window delta horizontal ignore trail noup nodown) + (>= (window--resizable window delta horizontal ignore trail noup nodown) delta) - (<= (window-resizable window delta horizontal ignore trail noup nodown) + (<= (window--resizable window delta horizontal ignore trail noup nodown) delta))) +(defun window-resizable (window delta &optional horizontal ignore) + "Return DELTA if WINDOW can be resized vertically by DELTA lines. +Optional argument HORIZONTAL non-nil means return DELTA if WINDOW +can be resized horizontally by DELTA columns. A return value of +zero means that WINDOW is not resizable. + +DELTA positive means WINDOW shall be enlarged by DELTA lines or +columns. If WINDOW cannot be enlarged by DELTA lines or columns +return the maximum value in the range 0..DELTA by which WINDOW +can be enlarged. + +DELTA negative means WINDOW shall be shrunk by -DELTA lines or +columns. If WINDOW cannot be shrunk by -DELTA lines or columns, +return the minimum value in the range DELTA..0 that can be used +for shrinking WINDOW. + +Optional argument IGNORE non-nil means ignore any restrictions +imposed by fixed size windows, `window-min-height' or +`window-min-width' settings. IGNORE a window means ignore +restrictions for that window only. IGNORE equal `safe' means +live windows may get as small as `window-safe-min-height' lines +and `window-safe-min-width' columns." + (setq window (window-normalize-window window)) + (window--resizable window delta horizontal ignore)) + (defun window-total-size (&optional window horizontal) "Return the total height or width of window WINDOW. If WINDOW is omitted or nil, it defaults to the selected window. @@ -1475,7 +1501,7 @@ (error "Cannot resize the root window of a frame")) ((window-minibuffer-p window) (window--resize-mini-window window delta)) - ((window-resizable-p window delta horizontal ignore) + ((window--resizable-p window delta horizontal ignore) (window--resize-reset frame horizontal) (window--resize-this-window window delta horizontal ignore t) (if (and (not (window-splits window)) @@ -1829,7 +1855,7 @@ ;; Set this-delta to what we can get from WINDOW's siblings. (if (= (- delta) (window-total-size window horizontal)) ;; A deletion, presumably. We must handle this case - ;; specially since `window-resizable' can't be used. + ;; specially since `window--resizable' can't be used. (if this-delta ;; There's at least one resizable sibling we can ;; give WINDOW's size to. @@ -1838,7 +1864,7 @@ (setq this-delta 0)) ;; Any other form of resizing. (setq this-delta - (window-resizable window delta horizontal ignore trail t))) + (window--resizable window delta horizontal ignore trail t))) ;; Set other-delta to what we still have to get from ;; ancestor windows of parent. @@ -1904,7 +1930,7 @@ preferably only resize windows adjacent to EDGE. This function recursively resizes WINDOW's child windows to fit the -new size. Make sure that WINDOW is `window-resizable' before +new size. Make sure that WINDOW is `window--resizable' before calling this function. Note that this function does not resize siblings of WINDOW or WINDOW's parent window. You have to eventually call `window-resize-apply' in order to make resizing @@ -2044,7 +2070,7 @@ ;; Start resizing. (window--resize-reset frame horizontal) ;; Try to enlarge LEFT first. - (setq this-delta (window-resizable left delta horizontal)) + (setq this-delta (window--resizable left delta horizontal)) (unless (zerop this-delta) (window--resize-this-window left this-delta horizontal nil t 'before @@ -2067,7 +2093,7 @@ ;; Start resizing. (window--resize-reset frame horizontal) ;; Try to enlarge RIGHT. - (setq this-delta (window-resizable right (- delta) horizontal)) + (setq this-delta (window--resizable right (- delta) horizontal)) (unless (zerop this-delta) (window--resize-this-window right this-delta horizontal nil t 'after @@ -2098,7 +2124,7 @@ ((zerop delta)) ((window-size-fixed-p nil horizontal) (error "Selected window has fixed size")) - ((window-resizable-p nil delta horizontal) + ((window--resizable-p nil delta horizontal) (window-resize nil delta horizontal)) (t (window-resize @@ -2119,7 +2145,7 @@ ((zerop delta)) ((window-size-fixed-p nil horizontal) (error "Selected window has fixed size")) - ((window-resizable-p nil (- delta) horizontal) + ((window--resizable-p nil (- delta) horizontal) (window-resize nil (- delta) horizontal)) (t (window-resize @@ -2392,7 +2418,7 @@ (set-window-new-normal sibling (+ (window-normal-size sibling horizontal) (window-normal-size window horizontal)))) - ((window-resizable-p window (- size) horizontal nil nil nil t) + ((window--resizable-p window (- size) horizontal nil nil nil t) ;; Can do without resizing fixed-size windows. (window--resize-siblings window (- size) horizontal)) (t @@ -3763,13 +3789,13 @@ (let ((delta (- (cdr (assq 'total-height item)) (window-total-height window))) window-size-fixed) - (when (window-resizable-p window delta) + (when (window--resizable-p window delta) (window-resize window delta))) ;; Else check whether the window is not high enough. (let* ((min-size (window-min-size window nil ignore)) (delta (- min-size (window-total-size window)))) (when (and (> delta 0) - (window-resizable-p window delta nil ignore)) + (window--resizable-p window delta nil ignore)) (window-resize window delta nil ignore)))) ;; Adjust horizontally. (if (memq window-size-fixed '(t width)) @@ -3777,13 +3803,13 @@ (let ((delta (- (cdr (assq 'total-width item)) (window-total-width window))) window-size-fixed) - (when (window-resizable-p window delta) + (when (window--resizable-p window delta) (window-resize window delta))) ;; Else check whether the window is not wide enough. (let* ((min-size (window-min-size window t ignore)) (delta (- min-size (window-total-size window t)))) (when (and (> delta 0) - (window-resizable-p window delta t ignore)) + (window--resizable-p window delta t ignore)) (window-resize window delta t ignore)))) ;; Set dedicated status. (set-window-dedicated-p window (cdr (assq 'dedicated state))) ------------------------------------------------------------ revno: 106333 committer: Chong Yidong branch nick: trunk timestamp: Wed 2011-11-09 15:56:50 +0800 message: * doc/lispref/windows.texi (Splitting Windows): Simplify example. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-11-08 15:34:21 +0000 +++ doc/lispref/ChangeLog 2011-11-09 07:56:50 +0000 @@ -1,3 +1,7 @@ +2011-11-09 Chong Yidong + + * windows.texi (Splitting Windows): Simplify example. + 2011-11-08 Chong Yidong * windows.texi (Window Sizes): Copyedits. Document === modified file 'doc/lispref/windows.texi' --- doc/lispref/windows.texi 2011-11-08 15:34:21 +0000 +++ doc/lispref/windows.texi 2011-11-09 07:56:50 +0000 @@ -715,337 +715,131 @@ @cindex splitting windows @cindex window splitting -The functions described below are the primitives needed for creating a -new window. They do not accept a buffer as an argument. Rather, they -``split'' an existing window into two halves, both displaying the buffer -previously visible in the window that was split. +This section describes functions for creating a new window by +@dfn{splitting} an existing one. @deffn Command split-window &optional window size side -This function creates a new window adjacent to @var{window}. It returns -the new window which is always a live window. The argument @var{window} -can denote any window and defaults to the selected one. This function -does not change the selected window. - -Optional second argument @var{size} a positive number means make -@var{window} @var{size} lines (or columns) tall. If @var{size} is -negative, make the new window @minus{}@var{size} lines (or columns) -tall. If @var{size} is omitted or @code{nil}, then @var{window} is -divided evenly into two parts. (If there is an odd line, it is -allocated to the new window.) - -Normally, the customizable variables @code{window-min-height} and -@code{window-min-width} specify the smallest allowable size of a -window. @xref{Change Window,,Deleting and Rearranging Windows, emacs, -The GNU Emacs Manual}. If splitting would result in making a window -smaller than this, this function usually signals an error. However, -if @var{size} is non-@code{nil} and valid, a new window of the -requested size is created, provided it has enough space for a text -area one line tall and/or two columns wide. - -Optional third argument @var{side} @code{nil} (or @code{below}) -specifies that the new window shall be located below @var{window}. The -value @code{above} means the new window will be located above -@var{window}. In both cases @var{size} specifies the new number of -lines for @var{window} (or the new window if @var{size} is negative) -including space reserved for the mode and/or header line. - -If @var{side} is @code{t} or @code{right} the new window will be -positioned on the right side of @var{window}. The value @code{left} -means the new window will be located on the left side of @var{window}. -In both cases @var{size} specifies the new number of columns for -@var{window} (or the new window provided @var{size} is negative) -including space reserved for margins, fringes and the scroll bar or a -divider column. - -Any other non-@code{nil} value for @var{side} is currently handled like -@code{t} (or @code{right}). Since this might change in the future, -application programs should refrain from using other values. - -If @var{window} is live, properties of the new window like margins and -scroll bars are inherited from @var{window}. If @var{window} is an -internal window, these properties, as well as the buffer shown in the -new window, are inherited from the window selected on @var{window}'s -frame. - -If @code{ignore-window-parameters} is non-@code{nil}, this function -ignores window parameters (@pxref{Window Parameters}). Otherwise, if -the @code{split-window} parameter of @var{window} is @code{t}, it splits -the window disregarding any other window parameters. If the -@code{split-window} parameter specifies a function, that function is -called with the arguments @var{window}, @var{size}, and @var{side} to -split @var{window}. If that function is @code{ignore}, nothing is done. +This function creates a new live window next to the window +@var{window}. If @var{window} is omitted or @code{nil}, it defaults +to the selected window. That window is ``split'', and reduced in +size. The space is taken up by the new window, which is returned. + +The optional second argument @var{size} determines the sizes of the +@var{window} and/or the new window. If it is omitted or @code{nil}, +both windows are given equal sizes; if there is an odd line, it is +allocated to the new window. If @var{size} is a positive number, +@var{window} is given @var{size} lines (or columns, depending on the +value of @var{side}). If @var{size} is a negative number, the new +window is given @minus{}@var{size} lines (or columns). + +If @var{size} is @code{nil}, this function obeys the variables +@code{window-min-height} and @code{window-min-width}. @xref{Change +Window,,Deleting and Rearranging Windows, emacs, The GNU Emacs +Manual}. Thus, it signals an error if splitting would result in +making a window smaller than those variables specify. However, a +non-@code{nil} value for @var{size} causes those variables to be +ignored; in that case, the smallest allowable window is considered to +be one that has space for a text area one line tall and/or two columns +wide. + +The optional third argument @var{side} determines the position of the +new window relative to @var{window}. If it is @code{nil} or +@code{below}, the new window is placed below @var{window}. If it is +@code{above}, the new window is placed above @var{window}. In both +these cases, @var{size} specifies a total window height, in lines. + +If @var{side} is @code{t} or @code{right}, the new window is placed on +the right of @var{window}. If @var{side} is @code{left}, the new +window is placed on the left of @var{window}. In both these cases, +@var{size} specifies a total window width, in columns. + +If @var{window} is a live window, the new window inherits various +properties from it, including margins and scroll bars. If +@var{window} is an internal window, the new window inherits the +properties of the window selected within @var{window}'s frame. + +If the variable @code{ignore-window-parameters} is non-@code{nil} +(@pxref{Window Parameters}), this function ignores window parameters. +Otherwise, it consults the @code{split-window} parameter of +@var{window}; if this is @code{t}, it splits the window disregarding +any other window parameters. If the @code{split-window} parameter +specifies a function, that function is called with the arguments +@var{window}, @var{size}, and @var{side} to split @var{window}, in +lieu of the usual action of @code{split-window}. @end deffn -The following example starts with one window on a screen that is 50 -lines high by 80 columns wide; then it splits the window. - -@smallexample -@group -(setq W1 (selected-window)) - @result{} # -(setq W2 (split-window W1 15)) - @result{} # -@end group -@group -(window-top-line W1) - @result{} 0 -(window-total-size W1) - @result{} 15 -(window-top-line W2) - @result{} 15 -@end group -@end smallexample - -The screen looks like this: - -@smallexample -@group - __________ - | | line 0 - | W1 | - |__________| - | | line 15 - | W2 | - |__________| - line 50 - column 0 column 80 -@end group -@end smallexample - -Next, split the top window into two side-by-side windows: - -@smallexample -@group -(setq W3 (split-window W1 35 t)) - @result{} # -@end group -@group -(window-left-column W1) - @result{} 0 -(window-total-size W1 t) - @result{} 35 -(window-left-column W3) - @result{} 35 -@end group -@end smallexample - -@need 3000 -Now the screen looks like this: - -@smallexample -@group - column 35 - __________ - | | | line 0 - | W1 | W3 | - |____|_____| - | | line 15 - | W2 | - |__________| - line 50 - column 0 column 80 -@end group -@end smallexample - -Normally, Emacs indicates the border between two side-by-side windows -with a scroll bar (@pxref{Scroll Bars}), or with @samp{|} characters. The -display table can specify alternative border characters; see @ref{Display -Tables}. - -Below we describe how @code{split-window} can be used to create the -window configuration from our earlier example (@pxref{Windows and -Frames}) and how internal windows are created for this purpose. We -start with a frame containing one live window @code{W2} (in the -following scenarios window names are assigned in an arbitrary manner in -order to match the names of the example). Evaluating the form -@code{(split-window W2 8 t)} creates a new internal window @code{W1} -with two children---@code{W2} (the window we've split) and a new leaf -window @code{W6}: -@smallexample -@group - ______________________________________ - | ______ ____________________________ | - || || || - || || || - || || || - || || || - || || || - || || || - || || || - || || || - || || || - || || || - ||__W2__||_____________W6_____________ | - |__________________W1__________________| - -@end group -@end smallexample - -Evaluating now @code{(split-window W6 -3)} creates another internal -window @code{W3} with two children---@code{W6} and a new live window -@code{W5}. This leaves us with a vertically combined window @code{W3} -embedded in the horizontally combined window @code{W1}: -@smallexample -@group - ______________________________________ - | ______ ____________________________ | - || || __________________________ || - || ||| ||| - || ||| ||| - || ||| ||| - || ||| ||| - || ||| ||| - || |||____________W6____________||| - || || __________________________ || - || ||| ||| - || |||____________W5____________||| - ||__W2__||_____________W3_____________ | - |__________________W1__________________| - -@end group -@end smallexample - -Finally, evaluating @code{(split-window W6 nil t)} should get us the -desired configuration as depicted below. -@smallexample -@group - ______________________________________ - | ______ ____________________________ | - || || __________________________ || - || ||| ___________ ___________ ||| - || |||| || |||| - || |||| || |||| - || ||||_____W6____||_____W7____|||| + As an example, we show a combination of @code{split-window} calls +that yields the window configuration discussed in @ref{Windows and +Frames}. This example demonstrates splitting live windows as well as +splitting internal windows. We begin with a frame containing a single +window (a live root window), which we denote by @var{W4}. Calling +@code{(split-window W3)} yields this window configuration: + +@smallexample +@group + ______________________________________ + | ____________________________________ | + || || + || || + || || + ||_________________W4_________________|| + | ____________________________________ | + || || + || || + || || + ||_________________W5_________________|| + |__________________W3__________________| + +@end group +@end smallexample + +@noindent +The @code{split-window} call has created a new live window, denoted by +@var{W5}. It has also created a new internal window, denoted by +@var{W3}, which becomes the root window and the parent of both +@var{W4} and @var{W5}. + + Next, we call @code{(split-window W3 nil 'left)}, passing the +internal window @var{W3} as the argument. The result: + +@smallexample +@group + ______________________________________ + | ______ ____________________________ | + || || __________________________ || + || ||| ||| + || ||| ||| + || ||| ||| || |||____________W4____________||| || || __________________________ || || ||| ||| + || ||| ||| || |||____________W5____________||| ||__W2__||_____________W3_____________ | |__________________W1__________________| - -@end group -@end smallexample - -The scenario sketched above is the standard way to obtain the desired -configuration. In Emacs 23 it was also the only way to do that since -Emacs 23 didn't allow splitting internal windows. - -With Emacs 24 you can also proceed as follows: Split an initial window -@code{W6} by evaluating @code{(split-window W6 -3)} to produce the -following vertical combination: -@smallexample -@group - ______________________________________ - | ____________________________________ | - || || - || || - || || - || || - || || - || || - || || - ||_________________W6_________________|| - | ____________________________________ | - || || - ||_________________W5_________________|| - |__________________W3__________________| - -@end group -@end smallexample - -Evaluating now @code{(split-window (window-parent W6) -8 'left)} or, -equivalently, @code{(split-window W3 -8 'left)} should now produce the -penultimate configuration from the previous scenario from where we can -continue as described before. - - Another strategy starts with splitting an initial window @code{W6} by -evaluating @code{(split-window W6 nil nil t)} with the following result: -@smallexample -@group - ______________________________________ - | _________________ _________________ | - || || || - || || || - || || || - || || || - || || || - || || || - || || || - || || || - || || || - || || || - ||________W6_______||________W7_______|| - |__________________W4__________________| - -@end group -@end smallexample - -Evaluating now @code{(split-window W4 -3)} or @code{(split-window -(window-parent W6) -3)} should get us a configuration as shown next. -@smallexample -@group - ______________________________________ - | ____________________________________ | - || ________________ ________________ || - ||| || ||| - ||| || ||| - ||| || ||| - ||| || ||| - ||| || ||| - |||_______W6_______||________W7______||| - ||_________________W4_________________|| - | ____________________________________ | - || || - ||_________________W5_________________|| - |__________________W3__________________| - -@end group -@end smallexample - -The desired configuration can be now obtained by evaluating -@code{(split-window W3 -8 'left)} or, equivalently, @code{(split-window -(window-parent W5) -8 'left)}. - - For a final approach let's start with the configuration of two live -windows @code{W6} and @code{W7} shown above. If we now evaluate -@code{(split-window W4 -8 'left)} or @code{(split-window (window-parent -W6) -8 'left)} we get the following configuration. -@smallexample -@group - ______________________________________ - | ______ ____________________________ | - || || ____________ ____________ || - || ||| || ||| - || ||| || ||| - || ||| || ||| - || ||| || ||| - || ||| || ||| - || ||| || ||| - || ||| || ||| - || |||______W6____||______W7____||| - ||__W2__||_____________W4_____________|| - |__________________W1__________________| - -@end group -@end smallexample - -Evaluating now @code{(split-window W4 -3)} or, for example, -@code{(split-window (window-parent W6) -3)} should produce the desired -configuration. - - The two options described next can be used to tune the operation of +@end group +@end smallexample + +@noindent +A new live window, @var{W2}, is created to the left of @var{W3} (which +encompasses the vertical window combination of @var{W4} and @var{W5}). +A new internal window @var{W1} is also created, and becomes the new +root window. + + The following two options can be used to modify the operation of @code{split-window}. @defopt window-splits -If this variable is @code{nil}, the function @code{split-window} can -split a window if and only if that window's screen estate is -sufficiently large to accommodate both--itself and the new window. +If this variable is @code{nil}, @code{split-window} can only split a +window (denoted by @var{window}) if @var{window}'s screen area is +large enough to accommodate both itself and the new window. This is +the default. -If this variable is non-@code{nil}, @code{split-window} tries to resize -all windows that are part of the same combination as the old window to -accommodate the new window. Hence, the new window can be also created if -the old window is of fixed size or too small to split (@pxref{Window -Sizes}). +If this variable is non-@code{nil}, @code{split-window} tries to +resize all windows that are part of the same combination as +@var{window}, in order to accommodate the new window. In particular, +this may allow @code{split-window} to succeed even if @var{window} is +a fixed-size window or too small to ordinarily split. In any case, the value of this variable is assigned to the splits status of the new window and, provided old and new window form a new