From a1562258dcd1634303dae465232d87c6505d26d1 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 10 Jun 2008 16:08:48 +0000 Subject: [PATCH] * window.c (Vwindow_point_insertion_type): New var. (set_window_buffer): Use it. (syms_of_window): Init and export it to Lisp. * progmodes/compile.el (compilation-mode): Set window-point-insertion-type. (compilation-filter): Don't use insert-before-markers any more. * emacs-lisp/trace.el (trace-make-advice): Set window-point-insertion-type in the trace buffer. * startup.el (normal-top-level): Set window-point-insertion-type in *Messages*. * net/telnet.el (telnet-mode): Set window-point-insertion-type. (telnet-filter): Don't use insert-before-markers any more. * comint.el (comint-mode): Set window-point-insertion-type. (comint-output-filter): Don't use insert-before-markers any more. * button.el (make-text-button): Allow `start' to be a string. --- etc/NEWS | 3 +++ lisp/ChangeLog | 11 ++++++++++ lisp/comint.el | 46 ++++----------------------------------- lisp/emacs-lisp/trace.el | 3 ++- lisp/net/telnet.el | 6 ++--- lisp/progmodes/compile.el | 11 +++++++--- lisp/startup.el | 9 ++++---- src/ChangeLog | 40 +++++++++++++++++----------------- src/window.c | 18 ++++++++++++--- 9 files changed, 71 insertions(+), 76 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7b24a232f2d..18ef4d603b3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -826,6 +826,9 @@ functions and variables (formerly used for Tamil script). * Lisp Changes in Emacs 23.1 +** The variable window-point-insertion-type determines the insertion-type +of the marker used for window-point. + ** minibuffer-local-must-match-filename-map is now named minibuffer-local-filename-must-match-map. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a2a80e919fe..690be169092 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,16 @@ 2008-06-10 Stefan Monnier + * progmodes/compile.el (compilation-mode): + Set window-point-insertion-type. + (compilation-filter): Don't use insert-before-markers any more. + * emacs-lisp/trace.el (trace-make-advice): + Set window-point-insertion-type in the trace buffer. + * startup.el (normal-top-level): Set window-point-insertion-type in + *Messages*. + * net/telnet.el (telnet-mode): Set window-point-insertion-type. + (telnet-filter): Don't use insert-before-markers any more. + * comint.el (comint-mode): Set window-point-insertion-type. + (comint-output-filter): Don't use insert-before-markers any more. * button.el (make-text-button): Allow `start' to be a string. 2008-06-10 Juanma Barranquero diff --git a/lisp/comint.el b/lisp/comint.el index 68745dcb4af..4abb17ed17a 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -618,6 +618,7 @@ to continue it. Entry to this mode runs the hooks on `comint-mode-hook'." (setq mode-line-process '(":%s")) + (set (make-local-variable 'window-point-insertion-type) t) (set (make-local-variable 'comint-last-input-start) (point-min-marker)) (set (make-local-variable 'comint-last-input-end) (point-min-marker)) (set (make-local-variable 'comint-last-output-start) (make-marker)) @@ -1755,48 +1756,9 @@ Make backspaces delete the previous character." (set-marker comint-last-output-start (point)) ;; insert-before-markers is a bad thing. XXX - ;; - ;; It is used here to force window-point markers (used to - ;; store the value of point in non-selected windows) to - ;; advance, but it also screws up any other markers that we - ;; don't _want_ to advance, such as the start-marker of some - ;; of the overlays we create. - ;; - ;; We work around the problem with the overlays by - ;; explicitly adjusting them after we do the insertion, but - ;; in the future this problem should be solved correctly, by - ;; using `insert', and making the insertion-type of - ;; window-point markers settable (via a buffer-local - ;; variable). In comint buffers, this variable would be set - ;; to `t', to cause point in non-select windows to advance. - (insert-before-markers string) - ;; Fixup markers and overlays that got screwed up because we - ;; used `insert-before-markers'. - (let ((old-point (- (point) (length string)))) - ;; comint-last-output-start - (set-marker comint-last-output-start old-point) - ;; comint-last-input-end - (when (and comint-last-input-end - (equal (marker-position comint-last-input-end) - (point))) - (set-marker comint-last-input-end old-point)) - ;; No overlays we create are set to advance upon insertion - ;; (at the start/end), so we assume that any overlay which - ;; is at the current point was incorrectly advanced by - ;; insert-before-markers. First fixup overlays that might - ;; start at point: - (dolist (over (overlays-at (point))) - (when (= (overlay-start over) (point)) - (let ((end (overlay-end over))) - (move-overlay over - old-point - (if (= end (point)) old-point end))))) - ;; Then do overlays that might end at point: - (dolist (over (overlays-at (1- (point)))) - (when (= (overlay-end over) (point)) - (move-overlay over - (min (overlay-start over) old-point) - old-point)))) + ;; Luckily we don't have to use it any more, we use + ;; window-point-insertion-type instead. + (insert string) ;; Advance process-mark (set-marker (process-mark process) (point)) diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el index b583f8a1b04..f474e8c72d5 100644 --- a/lisp/emacs-lisp/trace.el +++ b/lisp/emacs-lisp/trace.el @@ -219,7 +219,8 @@ (trace-buffer (get-buffer-create ,buffer))) (unless inhibit-trace (with-current-buffer trace-buffer - ,(unless background '(display-buffer trace-buffer)) + (set (make-local-variable 'window-point-insertion-type) t) + ,(unless background '(display-buffer trace-buffer)) (goto-char (point-max)) ;; Insert a separator from previous trace output: (if (= trace-level 1) (insert trace-separator)) diff --git a/lisp/net/telnet.el b/lisp/net/telnet.el index 3a0405b9fb3..a4bd46bca4c 100644 --- a/lisp/net/telnet.el +++ b/lisp/net/telnet.el @@ -159,8 +159,7 @@ rejecting one login and prompting again for a username and password.") (comint-send-string proc telnet-new-line))) (defun telnet-filter (proc string) - (save-excursion - (set-buffer (process-buffer proc)) + (with-current-buffer (process-buffer proc) (let* ((last-insertion (marker-position (process-mark proc))) (delta (- (point) last-insertion)) (ie (and comint-last-input-end @@ -168,7 +167,7 @@ rejecting one login and prompting again for a username and password.") (w (get-buffer-window (current-buffer))) (ws (and w (window-start w)))) (goto-char last-insertion) - (insert-before-markers string) + (insert string) (set-marker comint-last-output-start last-insertion) (set-marker (process-mark proc) (point)) (if ws (set-window-start w ws t)) @@ -245,6 +244,7 @@ It has most of the same commands as comint-mode. There is a variable ``telnet-interrupt-string'' which is the character sent to try to stop execution of a job on the remote host. Data is sent to the remote host when RET is typed." + (set (make-local-variable 'window-point-insertion-type) t) (set (make-local-variable 'comint-prompt-regexp) telnet-prompt-pattern) (set (make-local-variable 'comint-use-prompt-regexp) t)) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index e8f879f2ffa..0c8bb8473be 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -1467,6 +1467,8 @@ Runs `compilation-mode-hook' with `run-mode-hooks' (which see). (interactive) (kill-all-local-variables) (use-local-map compilation-mode-map) + ;; Let windows scroll along with the output. + (set (make-local-variable 'window-point-insertion-type) t) (set (make-local-variable 'tool-bar-map) compilation-mode-tool-bar-map) (setq major-mode 'compilation-mode mode-name (or name-of-mode "Compilation")) @@ -1663,13 +1665,16 @@ Turning the mode on runs the normal hook `compilation-minor-mode-hook'." (defun compilation-filter (proc string) "Process filter for compilation buffers. -Just inserts the text, but uses `insert-before-markers'." - (if (buffer-name (process-buffer proc)) +Just inserts the text, and runs `compilation-filter-hook'." + (if (buffer-live-p (process-buffer proc)) (with-current-buffer (process-buffer proc) (let ((inhibit-read-only t)) (save-excursion (goto-char (process-mark proc)) - (insert-before-markers string) + ;; We used to use `insert-before-markers', so that windows with + ;; point at `process-mark' scroll along with the output, but we + ;; now use window-point-insertion-type instead. + (insert string) (run-hooks 'compilation-filter-hook)))))) ;;; test if a buffer is a compilation buffer, assuming we're in the buffer diff --git a/lisp/startup.el b/lisp/startup.el index eb8898551eb..83b44cacc40 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -396,10 +396,12 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'." (if command-line-processed (message "Back to top level.") (setq command-line-processed t) - ;; Give *Messages* the same default-directory as *scratch*, - ;; just to keep things predictable. (let ((dir default-directory)) (with-current-buffer "*Messages*" + ;; Make it easy to do like "tail -f". + (set (make-local-variable 'window-point-insertion-type) t) + ;; Give *Messages* the same default-directory as *scratch*, + ;; just to keep things predictable. (setq default-directory dir))) ;; `user-full-name' is now known; reset its standard-value here. (put 'user-full-name 'standard-value @@ -994,8 +996,7 @@ opening the first frame (e.g. open a connection to an X server).") (setq init-file-had-error nil)) (error (let ((message-log-max nil)) - (save-excursion - (set-buffer (get-buffer-create "*Messages*")) + (with-current-buffer (get-buffer-create "*Messages*") (insert "\n\n" (format "An error has occurred while loading `%s':\n\n" user-init-file) diff --git a/src/ChangeLog b/src/ChangeLog index a4481d2fab7..23189ad9cf9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,21 +1,21 @@ +2008-06-10 Stefan Monnier + + * window.c (Vwindow_point_insertion_type): New var. + (set_window_buffer): Use it. + (syms_of_window): Init and export it to Lisp. + 2008-06-10 Kenichi Handa * font.h (font_intern_prop): Prototype adjusted. * font.c (font_intern_prop): New arg force_symbol. - (font_parse_xlfd): Adjusted for the change of font_intern_prop. - (font_parse_fcname): Likewise. - (font_parse_family_registry): Likewise. - - * ftfont.c (ftfont_pattern_entity): Adjusted for the change of - font_intern_prop. - - * w32font.c (add_font_name_to_list): Adjusted for - the change of font_intern_prop. - (w32_enumfont_pattern_entity): Likewise. - (w32_registry): Likewise. + (font_parse_xlfd, font_parse_fcname, font_parse_family_registry): + Adjust for the change of font_intern_prop. - * w32uniscribe.c (add_opentype_font_name_to_list): Adjusted for + * ftfont.c (ftfont_pattern_entity): + * w32font.c (add_font_name_to_list, w32_enumfont_pattern_entity) + (w32_registry): + * w32uniscribe.c (add_opentype_font_name_to_list): Adjust for the change of font_intern_prop. 2008-06-09 Juanma Barranquero @@ -24,15 +24,15 @@ 2008-06-09 Jason Rumney - * w32term.c (x_make_frame_visible): Use alternate restore flags. + * w32term.c (x_make_frame_visible): Use alternate restore flags. - * w32menu.c (Fx_popup_menu): Unwind protect while building menu. - (parse_single_submenu): Remove. - (digest_single_submenu): Remove. - (syms_of_w32menu): Don't initialise variables that have moved - to menu.c. - (set_frame_menubar): Sync with version in xmenu.c. - (w32_menu_show): Sync with xmenu_show in xmenu.c. + * w32menu.c (Fx_popup_menu): Unwind protect while building menu. + (parse_single_submenu): Remove. + (digest_single_submenu): Remove. + (syms_of_w32menu): Don't initialise variables that have moved + to menu.c. + (set_frame_menubar): Sync with version in xmenu.c. + (w32_menu_show): Sync with xmenu_show in xmenu.c. * menu.c (single_keymap_panes, push_menu_pane, push_menu_item): Make static again. diff --git a/src/window.c b/src/window.c index 7af0c6db711..27db0296dcf 100644 --- a/src/window.c +++ b/src/window.c @@ -167,6 +167,10 @@ static Lisp_Object Vwindow_configuration_change_hook; Lisp_Object Vscroll_preserve_screen_position; +/* Non-nil means that text is inserted before window's markers. */ + +Lisp_Object Vwindow_point_insertion_type; + /* Incremented by 1 whenever a window is deleted. */ int window_deletion_count; @@ -3420,6 +3424,8 @@ set_window_buffer (window, buffer, run_hooks_p, keep_margins_p) Fset_buffer (buffer); } + XMARKER (w->pointm)->insertion_type = !NILP (Vwindow_point_insertion_type); + if (!keep_margins_p) { /* Set left and right marginal area width etc. from buffer. */ @@ -3486,9 +3492,11 @@ This function runs the hook `window-scroll-functions'. */) else if (! EQ (tem, Qt)) /* w->buffer is t when the window is first being set up. */ { - if (!NILP (w->dedicated) && !EQ (tem, buffer)) - error ("Window is dedicated to `%s'", - SDATA (XBUFFER (tem)->name)); + if (!EQ (tem, buffer)) + if (EQ (w->dedicated, Qt)) + error ("Window is dedicated to `%s'", SDATA (XBUFFER (tem)->name)); + else + w->dedicated = Qnil; unshow_buffer (w); } @@ -7151,6 +7159,10 @@ by full screens. Any other value means point always keeps its screen position. */); Vscroll_preserve_screen_position = Qnil; + DEFVAR_LISP ("window-point-insertion-type", &Vwindow_point_insertion_type, + doc: /* Type of marker to use for `window-point'. */); + Vwindow_point_insertion_type = Qnil; + DEFVAR_LISP ("window-configuration-change-hook", &Vwindow_configuration_change_hook, doc: /* Functions to call when window configuration changes. -- 2.39.2