Now on revision 108658. ------------------------------------------------------------ revno: 108658 fixes bug(s): http://debbugs.gnu.org/4702 committer: Chong Yidong branch nick: trunk timestamp: Tue 2012-06-19 14:49:50 +0800 message: Preserve tty top-frames under various window-changing operations. * subr.el (with-selected-window): Preserve the selected window's terminal's top-frame. * window.el (save-selected-window): Likewise. * frame.c (delete_frame): When selecting a frame on a different text terminal, do not alter the terminal's top-frame. * term.c (Ftty_top_frame): New function. * xdisp.c (format_mode_line_unwind_data): Record the target frame's selected window and its terminal's top-frame. (unwind_format_mode_line): Restore them. (x_consider_frame_title, display_mode_line, Fformat_mode_line): Callers changed. (x_consider_frame_title): Do not condition on HAVE_WINDOW_SYSTEM, since tty frames can be explicitly named. (prepare_menu_bars): Likewise. diff: === modified file 'etc/NEWS' --- etc/NEWS 2012-06-18 15:57:41 +0000 +++ etc/NEWS 2012-06-19 06:49:50 +0000 @@ -473,6 +473,8 @@ Emacs now supports mouse highlight, help-echo (in the echo area), and mouse-autoselect-window. +** New function `tty-top-frame' returns the topmost frame of a text terminal. + * Installation Changes in Emacs 24.1 === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-06-18 20:41:23 +0000 +++ lisp/ChangeLog 2012-06-19 06:49:50 +0000 @@ -1,3 +1,10 @@ +2012-06-19 Chong Yidong + + * subr.el (with-selected-window): Preserve the selected window's + terminal's top-frame (Bug#4702). + + * window.el (save-selected-window): Likewise. + 2012-06-18 Stefan Monnier * progmodes/python.el (python-rx-constituents): Move backquote. === modified file 'lisp/subr.el' --- lisp/subr.el 2012-06-07 16:20:28 +0000 +++ lisp/subr.el 2012-06-19 06:49:50 +0000 @@ -3011,24 +3011,29 @@ (declare (indent 1) (debug t)) ;; Most of this code is a copy of save-selected-window. `(let* ((save-selected-window-destination ,window) + (save-selected-window-frame + (window-frame save-selected-window-destination)) (save-selected-window-window (selected-window)) - ;; Selecting a window on another frame changes not only the - ;; selected-window but also the frame-selected-window of the - ;; destination frame. So we need to save&restore it. + ;; Selecting a window on another frame also changes that + ;; frame's frame-selected-window. We must save&restore it. (save-selected-window-other-frame - (unless (eq (selected-frame) - (window-frame save-selected-window-destination)) - (frame-selected-window - (window-frame save-selected-window-destination))))) + (unless (eq (selected-frame) save-selected-window-frame) + (frame-selected-window save-selected-window-frame))) + (save-selected-window-top-frame + (unless (eq (selected-frame) save-selected-window-frame) + (tty-top-frame save-selected-window-frame)))) (save-current-buffer (unwind-protect (progn (select-window save-selected-window-destination 'norecord) ,@body) ;; First reset frame-selected-window. - (if (window-live-p save-selected-window-other-frame) - ;; We don't use set-frame-selected-window because it does not - ;; pass the `norecord' argument to Fselect_window. - (select-window save-selected-window-other-frame 'norecord)) + (when (window-live-p save-selected-window-other-frame) + ;; We don't use set-frame-selected-window because it does not + ;; pass the `norecord' argument to Fselect_window. + (select-window save-selected-window-other-frame 'norecord) + (and (frame-live-p save-selected-window-top-frame) + (not (eq (tty-top-frame) save-selected-window-top-frame)) + (select-frame save-selected-window-top-frame 'norecord))) ;; Then reset the actual selected-window. (when (window-live-p save-selected-window-window) (select-window save-selected-window-window 'norecord)))))) === modified file 'lisp/window.el' --- lisp/window.el 2012-06-18 06:22:22 +0000 +++ lisp/window.el 2012-06-19 06:49:50 +0000 @@ -47,12 +47,24 @@ are not altered by this macro (unless they are altered in BODY)." (declare (indent 0) (debug t)) `(let ((save-selected-window-window (selected-window)) - ;; It is necessary to save all of these, because calling - ;; select-window changes frame-selected-window for whatever - ;; frame that window is in. + ;; We save and restore all frames' selected windows, because + ;; `select-window' can change the frame-selected-window of + ;; whatever frame that window is in. Each text terminal's + ;; top-frame is preserved by putting it last in the list. (save-selected-window-alist - (mapcar (lambda (frame) (cons frame (frame-selected-window frame))) - (frame-list)))) + (apply 'append + (mapcar (lambda (terminal) + (let ((frames (frames-on-display-list terminal)) + (top-frame (tty-top-frame terminal)) + alist) + (if top-frame + (setq frames + (cons top-frame + (delq top-frame frames)))) + (dolist (f frames) + (push (cons f (frame-selected-window f)) + alist)))) + (terminal-list))))) (save-current-buffer (unwind-protect (progn ,@body) === modified file 'src/ChangeLog' --- src/ChangeLog 2012-06-18 22:53:53 +0000 +++ src/ChangeLog 2012-06-19 06:49:50 +0000 @@ -1,3 +1,19 @@ +2012-06-19 Chong Yidong + + * frame.c (delete_frame): When selecting a frame on a different + text terminal, do not alter the terminal's top-frame. + + * xdisp.c (format_mode_line_unwind_data): Record the target + frame's selected window and its terminal's top-frame. + (unwind_format_mode_line): Restore them. + (x_consider_frame_title, display_mode_line, Fformat_mode_line): + Callers changed. + (x_consider_frame_title): Do not condition on HAVE_WINDOW_SYSTEM, + since tty frames can be explicitly named. + (prepare_menu_bars): Likewise. + + * term.c (Ftty_top_frame): New function. + 2012-06-18 Paul Eggert Port byte-code-meter to modern targets. === modified file 'src/frame.c' --- src/frame.c 2012-06-13 13:40:48 +0000 +++ src/frame.c 2012-06-19 06:49:50 +0000 @@ -630,8 +630,8 @@ doc: /* Create an additional terminal frame, possibly on another terminal. This function takes one argument, an alist specifying frame parameters. -You can create multiple frames on a single text-only terminal, but -only one of them (the selected terminal frame) is actually displayed. +You can create multiple frames on a single text terminal, but only one +of them (the selected terminal frame) is actually displayed. In practice, generally you don't need to specify any parameters, except when you want to create a new frame on another terminal. @@ -865,8 +865,8 @@ this function is called. If you are using a window system, the previously selected frame may be restored as the selected frame when returning to the command loop, because it still may have -the window system's input focus. On a text-only terminal, the -next redisplay will display FRAME. +the window system's input focus. On a text terminal, the next +redisplay will display FRAME. This function returns FRAME, or nil if FRAME has been deleted. */) (Lisp_Object frame, Lisp_Object norecord) @@ -1254,7 +1254,17 @@ FOR_EACH_FRAME (tail, frame1) { if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1))) - break; + { + /* Do not change a text terminal's top-frame. */ + struct frame *f1 = XFRAME (frame1); + if (FRAME_TERMCAP_P (f1) || FRAME_MSDOS_P (f1)) + { + Lisp_Object top_frame = FRAME_TTY (f1)->top_frame; + if (!EQ (top_frame, frame)) + frame1 = top_frame; + } + break; + } } } #ifdef NS_IMPL_COCOA @@ -1730,8 +1740,8 @@ Normally you may not make FRAME invisible if all other frames are invisible, but if the second optional argument FORCE is non-nil, you may do so. -This function has no effect on text-only terminal frames. Such frames -are always considered visible, whether or not they are currently being +This function has no effect on text terminal frames. Such frames are +always considered visible, whether or not they are currently being displayed in the terminal. */) (Lisp_Object frame, Lisp_Object force) { @@ -1743,12 +1753,6 @@ if (NILP (force) && !other_visible_frames (XFRAME (frame))) error ("Attempt to make invisible the sole visible or iconified frame"); -#if 0 /* This isn't logically necessary, and it can do GC. */ - /* Don't let the frame remain selected. */ - if (EQ (frame, selected_frame)) - do_switch_frame (next_frame (frame, Qt), 0, 0, Qnil) -#endif - /* Don't allow minibuf_window to remain on a deleted frame. */ if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) { @@ -1816,7 +1820,7 @@ On graphical displays, invisible frames are not updated and are usually not displayed at all, even in a window system's \"taskbar\". -If FRAME is a text-only terminal frame, this always returns t. +If FRAME is a text terminal frame, this always returns t. Such frames are always considered visible, whether or not they are currently being displayed on the terminal. */) (Lisp_Object frame) @@ -1872,7 +1876,7 @@ f = XFRAME (frame); if (FRAME_TERMCAP_P (f)) - /* On a text-only terminal select FRAME. */ + /* On a text terminal select FRAME. */ Fselect_frame (frame, Qnil); else /* Do like the documentation says. */ @@ -2493,7 +2497,7 @@ In a graphical version with no toolkit, it includes both the tool bar and menu bar. -For a text-only terminal, it includes the menu bar. In this case, the +For a text terminal, it includes the menu bar. In this case, the result is really in characters rather than pixels (i.e., is identical to `frame-height'). */) (Lisp_Object frame) === modified file 'src/term.c' --- src/term.c 2012-06-16 12:24:15 +0000 +++ src/term.c 2012-06-19 06:49:50 +0000 @@ -2132,7 +2132,7 @@ TERMINAL can be a terminal object, a frame, or nil (meaning the selected frame's terminal). This function always returns nil if -TERMINAL does not refer to a text-only terminal. */) +TERMINAL does not refer to a text terminal. */) (Lisp_Object terminal) { struct terminal *t = get_tty_terminal (terminal, 0); @@ -2149,7 +2149,7 @@ TERMINAL can be a terminal object, a frame, or nil (meaning the selected frame's terminal). This function always returns 0 if -TERMINAL does not refer to a text-only terminal. */) +TERMINAL does not refer to a text terminal. */) (Lisp_Object terminal) { struct terminal *t = get_tty_terminal (terminal, 0); @@ -2371,7 +2371,7 @@ TERMINAL can be a terminal object, a frame or nil (meaning the selected frame's terminal). This function always returns nil if -TERMINAL does not refer to a text-only terminal. */) +TERMINAL does not refer to a text terminal. */) (Lisp_Object terminal) { struct terminal *t = get_terminal (terminal, 1); @@ -2381,6 +2381,21 @@ return Qnil; } +DEFUN ("tty-top-frame", Ftty_top_frame, Stty_top_frame, 0, 1, 0, + doc: /* Return the topmost terminal frame on TERMINAL. +TERMINAL can be a terminal object, a frame or nil (meaning the +selected frame's terminal). This function returns nil if TERMINAL +does not refer to a text terminal. Otherwise, it returns the +top-most frame on the text terminal. */) + (Lisp_Object terminal) +{ + struct terminal *t = get_terminal (terminal, 1); + + if (t->type == output_termcap) + return t->display_info.tty->top_frame; + return Qnil; +} + DEFUN ("suspend-tty", Fsuspend_tty, Ssuspend_tty, 0, 1, 0, @@ -3638,6 +3653,7 @@ defsubr (&Stty_no_underline); defsubr (&Stty_type); defsubr (&Scontrolling_tty_p); + defsubr (&Stty_top_frame); defsubr (&Ssuspend_tty); defsubr (&Sresume_tty); #ifdef HAVE_GPM === modified file 'src/xdisp.c' --- src/xdisp.c 2012-06-17 10:11:39 +0000 +++ src/xdisp.c 2012-06-19 06:49:50 +0000 @@ -8356,9 +8356,9 @@ /* On graphical terminals, newlines may "overflow" into the fringe if overflow-newline-into-fringe is non-nil. - On text-only terminals, newlines may - overflow into the last glyph on the - display line.*/ + On text terminals, newlines may overflow + into the last glyph on the display + line.*/ if (!FRAME_WINDOW_P (it->f) || IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) { @@ -10821,7 +10821,8 @@ static Lisp_Object Vmode_line_unwind_vector; static Lisp_Object -format_mode_line_unwind_data (struct buffer *obuf, +format_mode_line_unwind_data (struct frame *target_frame, + struct buffer *obuf, Lisp_Object owin, int save_proptrans) { @@ -10833,7 +10834,7 @@ Vmode_line_unwind_vector = Qnil; if (NILP (vector)) - vector = Fmake_vector (make_number (8), Qnil); + vector = Fmake_vector (make_number (10), Qnil); ASET (vector, 0, make_number (mode_line_target)); ASET (vector, 1, make_number (MODE_LINE_NOPROP_LEN (0))); @@ -10848,6 +10849,15 @@ tmp = Qnil; ASET (vector, 6, tmp); ASET (vector, 7, owin); + if (target_frame) + { + /* Similarly to `with-selected-window', if the operation selects + a window on another frame, we must restore that frame's + selected window, and (for a tty) the top-frame. */ + ASET (vector, 8, target_frame->selected_window); + if (FRAME_TERMCAP_P (target_frame)) + ASET (vector, 9, FRAME_TTY (target_frame)->top_frame); + } return vector; } @@ -10855,6 +10865,10 @@ static Lisp_Object unwind_format_mode_line (Lisp_Object vector) { + Lisp_Object old_window = AREF (vector, 7); + Lisp_Object target_frame_window = AREF (vector, 8); + Lisp_Object old_top_frame = AREF (vector, 9); + mode_line_target = XINT (AREF (vector, 0)); mode_line_noprop_ptr = mode_line_noprop_buf + XINT (AREF (vector, 1)); mode_line_string_list = AREF (vector, 2); @@ -10863,9 +10877,26 @@ mode_line_string_face = AREF (vector, 4); mode_line_string_face_prop = AREF (vector, 5); - if (!NILP (AREF (vector, 7))) - /* Select window before buffer, since it may change the buffer. */ - Fselect_window (AREF (vector, 7), Qt); + /* Select window before buffer, since it may change the buffer. */ + if (!NILP (old_window)) + { + /* If the operation that we are unwinding had selected a window + on a different frame, reset its frame-selected-window. For a + text terminal, reset its top-frame if necessary. */ + if (!NILP (target_frame_window)) + { + Lisp_Object frame + = WINDOW_FRAME (XWINDOW (target_frame_window)); + + if (!EQ (frame, WINDOW_FRAME (XWINDOW (old_window)))) + Fselect_window (target_frame_window, Qt); + + if (!NILP (old_top_frame) && !EQ (old_top_frame, frame)) + Fselect_frame (old_top_frame, Qt); + } + + Fselect_window (old_window, Qt); + } if (!NILP (AREF (vector, 6))) { @@ -10936,8 +10967,6 @@ Frame Titles ***********************************************************************/ -#ifdef HAVE_WINDOW_SYSTEM - /* Set the title of FRAME, if it has changed. The title format is Vicon_title_format if FRAME is iconified, otherwise it is frame_title_format. */ @@ -10981,7 +11010,7 @@ mode_line_noprop_buf; then display the title. */ record_unwind_protect (unwind_format_mode_line, format_mode_line_unwind_data - (current_buffer, selected_window, 0)); + (f, current_buffer, selected_window, 0)); Fselect_window (f->selected_window, Qt); set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer)); @@ -11008,10 +11037,6 @@ } } -#endif /* not HAVE_WINDOW_SYSTEM */ - - - /*********************************************************************** Menu Bars @@ -11038,7 +11063,6 @@ /* Update all frame titles based on their buffer names, etc. We do this before the menu bars so that the buffer-menu will show the up-to-date frame titles. */ -#ifdef HAVE_WINDOW_SYSTEM if (windows_or_buffers_changed || update_mode_lines) { Lisp_Object tail, frame; @@ -11051,7 +11075,6 @@ x_consider_frame_title (frame); } } -#endif /* HAVE_WINDOW_SYSTEM */ /* Update the menu bar item lists, if appropriate. This has to be done before any actual redisplay or generation of display lines. */ @@ -20125,7 +20148,7 @@ it.paragraph_embedding = L2R; record_unwind_protect (unwind_format_mode_line, - format_mode_line_unwind_data (NULL, Qnil, 0)); + format_mode_line_unwind_data (NULL, NULL, Qnil, 0)); mode_line_target = MODE_LINE_DISPLAY; @@ -20826,7 +20849,8 @@ and set that to nil so that we don't alter the outer value. */ record_unwind_protect (unwind_format_mode_line, format_mode_line_unwind_data - (old_buffer, selected_window, 1)); + (XFRAME (WINDOW_FRAME (XWINDOW (window))), + old_buffer, selected_window, 1)); mode_line_proptrans_alist = Qnil; Fselect_window (window, Qt); ------------------------------------------------------------ revno: 108657 author: Nelson Ferreira committer: Katsumi Yamaoka branch nick: trunk timestamp: Mon 2012-06-18 23:12:10 +0000 message: gnus-win.el (gnus-configure-frame): Pass an arg to window-dedicated-p diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2012-06-17 18:52:31 +0000 +++ lisp/gnus/ChangeLog 2012-06-18 23:12:10 +0000 @@ -1,3 +1,7 @@ +2012-06-18 Nelson Ferreira (tiny change) + + * gnus-win.el (gnus-configure-frame): Pass an arg to window-dedicated-p. + 2012-06-17 Toke Høiland-Jørgensen (tiny change) * nnmaildir.el (nnmaildir-request-expire-articles): Ensure that `time' === modified file 'lisp/gnus/gnus-win.el' --- lisp/gnus/gnus-win.el 2012-05-29 06:16:49 +0000 +++ lisp/gnus/gnus-win.el 2012-06-18 23:12:10 +0000 @@ -273,7 +273,9 @@ (cond ((eq buf (window-buffer (selected-window))) (set-buffer buf)) - ((eq t (window-dedicated-p)) + ((eq t (window-dedicated-p + ;; XEmacs version of `window-dedicated-p' requires it. + (selected-window))) ;; If the window is hard-dedicated, we have a problem because ;; we just can't do what we're asked. But signaling an error, ;; like `switch-to-buffer' would do, is not an option because ------------------------------------------------------------ revno: 108656 committer: Paul Eggert branch nick: trunk timestamp: Mon 2012-06-18 15:53:53 -0700 message: Port byte-code-meter to modern targets. * bytecode.c (METER_CODE) [BYTE_CODE_METER]: Don't assume !CHECK_LISP_OBJECT_TYPE && !USE_LSB_TAG. Problem with CHECK_LISP_OBJECT_TYPE reported by Dmitry Andropov in . (METER_1, METER_2): Simplify. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-06-18 15:57:41 +0000 +++ src/ChangeLog 2012-06-18 22:53:53 +0000 @@ -1,3 +1,12 @@ +2012-06-18 Paul Eggert + + Port byte-code-meter to modern targets. + * bytecode.c (METER_CODE) [BYTE_CODE_METER]: Don't assume + !CHECK_LISP_OBJECT_TYPE && !USE_LSB_TAG. Problem with + CHECK_LISP_OBJECT_TYPE reported by Dmitry Andropov in + . + (METER_1, METER_2): Simplify. + 2012-06-18 Stefan Monnier * data.c (Fdefalias): Return `symbol' (bug#11686). === modified file 'src/bytecode.c' --- src/bytecode.c 2012-06-16 12:24:15 +0000 +++ src/bytecode.c 2012-06-18 22:53:53 +0000 @@ -58,21 +58,21 @@ #ifdef BYTE_CODE_METER Lisp_Object Qbyte_code_meter; -#define METER_2(code1, code2) \ - XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \ - ->contents[(code2)]) - -#define METER_1(code) METER_2 (0, (code)) +#define METER_2(code1, code2) AREF (AREF (Vbyte_code_meter, code1), code2) +#define METER_1(code) METER_2 (0, code) #define METER_CODE(last_code, this_code) \ { \ if (byte_metering_on) \ { \ - if (METER_1 (this_code) < MOST_POSITIVE_FIXNUM) \ - METER_1 (this_code)++; \ + if (XFASTINT (METER_1 (this_code)) < MOST_POSITIVE_FIXNUM) \ + XSETFASTINT (METER_1 (this_code), \ + XFASTINT (METER_1 (this_code)) + 1); \ if (last_code \ - && METER_2 (last_code, this_code) < MOST_POSITIVE_FIXNUM) \ - METER_2 (last_code, this_code)++; \ + && (XFASTINT (METER_2 (last_code, this_code)) \ + < MOST_POSITIVE_FIXNUM)) \ + XSETFASTINT (METER_2 (last_code, this_code), \ + XFASTINT (METER_2 (last_code, this_code)) + 1); \ } \ } ------------------------------------------------------------ revno: 108655 committer: Stefan Monnier branch nick: trunk timestamp: Mon 2012-06-18 16:41:23 -0400 message: * lisp/progmodes/python.el (python-rx-constituents): Move backquote. (python-skeleton-define, python-define-auxiliary-skeleton): Use `declare'. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-06-18 20:39:52 +0000 +++ lisp/ChangeLog 2012-06-18 20:41:23 +0000 @@ -1,3 +1,9 @@ +2012-06-18 Stefan Monnier + + * progmodes/python.el (python-rx-constituents): Move backquote. + (python-skeleton-define, python-define-auxiliary-skeleton): + Use `declare'. + 2012-06-18 Michael Albinus * minibuffer.el (read-file-name-default): Revert the patch from === modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2012-06-18 18:23:59 +0000 +++ lisp/progmodes/python.el 2012-06-18 20:41:23 +0000 @@ -308,29 +308,31 @@ (eval-when-compile (defconst python-rx-constituents - (list - `(block-start . ,(rx symbol-start + `((block-start . ,(rx symbol-start (or "def" "class" "if" "elif" "else" "try" "except" "finally" "for" "while" "with") symbol-end)) - `(decorator . ,(rx line-start (* space) ?@ (any letter ?_) + (decorator . ,(rx line-start (* space) ?@ (any letter ?_) (* (any word ?_)))) - `(defun . ,(rx symbol-start (or "def" "class") symbol-end)) - `(if-name-main . ,(rx line-start "if" (+ space) "__name__" + (defun . ,(rx symbol-start (or "def" "class") symbol-end)) + (if-name-main . ,(rx line-start "if" (+ space) "__name__" (+ space) "==" (+ space) (any ?' ?\") "__main__" (any ?' ?\") (* space) ?:)) - `(symbol-name . ,(rx (any letter ?_) (* (any word ?_)))) - `(open-paren . ,(rx (or "{" "[" "("))) - `(close-paren . ,(rx (or "}" "]" ")"))) - `(simple-operator . ,(rx (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%))) - `(not-simple-operator . ,(rx + (symbol-name . ,(rx (any letter ?_) (* (any word ?_)))) + (open-paren . ,(rx (or "{" "[" "("))) + (close-paren . ,(rx (or "}" "]" ")"))) + (simple-operator . ,(rx (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%))) + ;; FIXME: rx should support (not simple-operator). + (not-simple-operator . ,(rx (not (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%)))) - `(operator . ,(rx (or "+" "-" "/" "&" "^" "~" "|" "*" "<" ">" + ;; FIXME: Use regexp-opt. + (operator . ,(rx (or "+" "-" "/" "&" "^" "~" "|" "*" "<" ">" "=" "%" "**" "//" "<<" ">>" "<=" "!=" "==" ">=" "is" "not"))) - `(assignment-operator . ,(rx (or "=" "+=" "-=" "*=" "/=" "//=" "%=" "**=" + ;; FIXME: Use regexp-opt. + (assignment-operator . ,(rx (or "=" "+=" "-=" "*=" "/=" "//=" "%=" "**=" ">>=" "<<=" "&=" "^=" "|=")))) "Additional Python specific sexps for `python-rx'")) @@ -2146,6 +2148,7 @@ "Define a `python-mode' skeleton using NAME DOC and SKEL. The skeleton will be bound to python-skeleton-NAME and will be added to `python-mode-abbrev-table'." + (declare (indent 2)) (let* ((name (symbol-name name)) (function-name (intern (concat "python-skeleton-" name)))) `(progn @@ -2156,11 +2159,11 @@ ,(or doc (format "Insert %s statement." name)) ,@skel)))) -(put 'python-skeleton-define 'lisp-indent-function 2) (defmacro python-define-auxiliary-skeleton (name doc &optional &rest skel) "Define a `python-mode' auxiliary skeleton using NAME DOC and SKEL. The skeleton will be bound to python-skeleton-NAME." + (declare (indent 2)) (let* ((name (symbol-name name)) (function-name (intern (concat "python-skeleton--" name))) (msg (format @@ -2176,7 +2179,6 @@ (unless (y-or-n-p ,msg) (signal 'quit t)) ,@skel))) -(put 'python-define-auxiliary-skeleton 'lisp-indent-function 2) (python-define-auxiliary-skeleton else nil) ------------------------------------------------------------ revno: 108654 committer: Michael Albinus branch nick: trunk timestamp: Mon 2012-06-18 22:39:52 +0200 message: * minibuffer.el (read-file-name-default): Revert the patch from 2012-06-17. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-06-18 19:23:35 +0000 +++ lisp/ChangeLog 2012-06-18 20:39:52 +0000 @@ -1,3 +1,8 @@ +2012-06-18 Michael Albinus + + * minibuffer.el (read-file-name-default): Revert the patch from + 2012-06-17. + 2012-06-18 Stefan Monnier * emacs-lisp/pcase.el (pcase--expand): Warn for unused pattern. === modified file 'lisp/minibuffer.el' --- lisp/minibuffer.el 2012-06-17 18:54:39 +0000 +++ lisp/minibuffer.el 2012-06-18 20:39:52 +0000 @@ -461,7 +461,7 @@ (last (last completions))) (when (consp last) (setcdr last nil)) completions)) - + ((eq action 'completion--unquote) (let ((ustring (funcall unquote string)) (uprefix (funcall unquote (substring string 0 pred)))) @@ -2335,8 +2335,7 @@ (if (consp default-filename) (mapcar 'abbreviate-file-name default-filename) (abbreviate-file-name default-filename)))) - (let ((non-essential t) - (insdef (cond + (let ((insdef (cond ((and insert-default-directory (stringp dir)) (if initial (cons (minibuffer--double-dollars (concat dir initial)) ------------------------------------------------------------ revno: 108653 committer: Stefan Monnier branch nick: trunk timestamp: Mon 2012-06-18 15:23:35 -0400 message: * lisp/emacs-lisp/pcase.el (pcase--expand): Warn for unused pattern. (pcase--u1, pcase--q1): Don't use apply-partially. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-06-18 18:23:59 +0000 +++ lisp/ChangeLog 2012-06-18 19:23:35 +0000 @@ -1,3 +1,8 @@ +2012-06-18 Stefan Monnier + + * emacs-lisp/pcase.el (pcase--expand): Warn for unused pattern. + (pcase--u1, pcase--q1): Don't use apply-partially. + 2012-06-18 Glenn Morris * progmodes/python.el (python-proc, python-buffer) === modified file 'lisp/emacs-lisp/pcase.el' --- lisp/emacs-lisp/pcase.el 2012-06-11 00:46:21 +0000 +++ lisp/emacs-lisp/pcase.el 2012-06-18 19:23:35 +0000 @@ -237,7 +237,8 @@ ;; the branch to a separate function. (let ((bsym (make-symbol (format "pcase-%d" (length defs))))) - (push `(,bsym (lambda ,(mapcar #'car prevvars) ,@code)) defs) + (push `(,bsym (lambda ,(mapcar #'car prevvars) ,@code)) + defs) (setcar res 'funcall) (setcdr res (cons bsym (mapcar #'cdr prevvars))) (setcar (cddr prev) bsym) @@ -255,17 +256,26 @@ ;; FIXME: But if some of `prevvars' are not in `vars' we ;; should remove them from `prevvars'! `(funcall ,res ,@args))))))) + (used-cases ()) (main (pcase--u (mapcar (lambda (case) `((match ,val . ,(car case)) - ,(apply-partially - (if (pcase--small-branch-p (cdr case)) - ;; Don't bother sharing multiple - ;; occurrences of this leaf since it's small. - #'pcase-codegen codegen) - (cdr case)))) + ,(lambda (vars) + (unless (memq case used-cases) + ;; Keep track of the cases that are used. + (push case used-cases)) + (funcall + (if (pcase--small-branch-p (cdr case)) + ;; Don't bother sharing multiple + ;; occurrences of this leaf since it's small. + #'pcase-codegen codegen) + (cdr case) + vars)))) cases)))) + (dolist (case cases) + (unless (or (memq case used-cases) (eq (car case) 'dontcare)) + (message "Redundant pcase pattern: %S" (car case)))) (macroexp-let* defs main)))) (defun pcase-codegen (code vars) @@ -566,7 +576,7 @@ (if (eq (car upat) 'pred) (put sym 'pcase-used t)) (let* ((splitrest (pcase--split-rest - sym (apply-partially #'pcase--split-pred upat) rest)) + sym (lambda (pat) (pcase--split-pred upat pat)) rest)) (then-rest (car splitrest)) (else-rest (cdr splitrest))) (pcase--if (if (and (eq (car upat) 'pred) (symbolp (cadr upat))) @@ -636,7 +646,7 @@ (let* ((elems (mapcar 'cadr (cdr upat))) (splitrest (pcase--split-rest - sym (apply-partially #'pcase--split-member elems) rest)) + sym (lambda (pat) (pcase--split-member elems pat)) rest)) (then-rest (car splitrest)) (else-rest (cdr splitrest))) (put sym 'pcase-used t) @@ -693,7 +703,7 @@ (symd (make-symbol "xcdr")) (splitrest (pcase--split-rest sym - (apply-partially #'pcase--split-consp syma symd) + (lambda (pat) (pcase--split-consp syma symd pat)) rest)) (then-rest (car splitrest)) (else-rest (cdr splitrest)) @@ -716,7 +726,7 @@ (pcase--u else-rest)))) ((or (integerp qpat) (symbolp qpat) (stringp qpat)) (let* ((splitrest (pcase--split-rest - sym (apply-partially 'pcase--split-equal qpat) rest)) + sym (lambda (pat) (pcase--split-equal qpat pat)) rest)) (then-rest (car splitrest)) (else-rest (cdr splitrest))) (pcase--if (cond ------------------------------------------------------------ revno: 108652 committer: Glenn Morris branch nick: trunk timestamp: Mon 2012-06-18 14:23:59 -0400 message: Fix python.el obsolescence versions * lisp/progmodes/python.el (python-proc, python-buffer) (python-send-receive, python-send-string): Fix obsolete versions. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-06-18 06:22:22 +0000 +++ lisp/ChangeLog 2012-06-18 18:23:59 +0000 @@ -1,3 +1,8 @@ +2012-06-18 Glenn Morris + + * progmodes/python.el (python-proc, python-buffer) + (python-send-receive, python-send-string): Fix obsolete versions. + 2012-06-18 Martin Rudalics * window.el (special-display-p): Completely remove stringp === modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2012-06-18 18:04:21 +0000 +++ lisp/progmodes/python.el 2012-06-18 18:23:59 +0000 @@ -1569,10 +1569,10 @@ (get-buffer-process proc-buffer-name))) (define-obsolete-function-alias - 'python-proc 'python-shell-internal-get-or-create-process "23.3") + 'python-proc 'python-shell-internal-get-or-create-process "24.2") (define-obsolete-variable-alias - 'python-buffer 'python-shell-internal-buffer "23.3") + 'python-buffer 'python-shell-internal-buffer "24.2") (defun python-shell-send-string (string &optional process msg) "Send STRING to inferior Python PROCESS. @@ -1627,10 +1627,10 @@ (python-shell-internal-get-or-create-process) nil)) (define-obsolete-function-alias - 'python-send-receive 'python-shell-internal-send-string "23.3") + 'python-send-receive 'python-shell-internal-send-string "24.2") (define-obsolete-function-alias - 'python-send-string 'python-shell-internal-send-string "23.3") + 'python-send-string 'python-shell-internal-send-string "24.2") (defun python-shell-send-region (start end) "Send the region delimited by START and END to inferior Python process." ------------------------------------------------------------ revno: 108651 committer: Glenn Morris branch nick: trunk timestamp: Mon 2012-06-18 14:04:21 -0400 message: Add coding cookie diff: === modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2012-06-17 08:53:31 +0000 +++ lisp/progmodes/python.el 2012-06-18 18:04:21 +0000 @@ -1,4 +1,4 @@ -;;; python.el --- Python's flying circus support for Emacs +;;; python.el --- Python's flying circus support for Emacs -*- coding: utf-8 -*- ;; Copyright (C) 2003-2012 Free Software Foundation, Inc. ------------------------------------------------------------ revno: 108650 fixes bug(s): http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11686 committer: Stefan Monnier branch nick: trunk timestamp: Mon 2012-06-18 11:57:41 -0400 message: Fix return value of `defun' and un-define it. * src/data.c (Fdefalias): Return `symbol'. * doc/lispref/functions.texi (Defining Functions): * doc/lispref/macros.texi (Defining Macros): Un-define the return value of `defun', `defmacro' and `defalias'. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2012-06-17 05:13:40 +0000 +++ doc/lispref/ChangeLog 2012-06-18 15:57:41 +0000 @@ -1,3 +1,9 @@ +2012-06-18 Stefan Monnier + + * functions.texi (Defining Functions): + * macros.texi (Defining Macros): Un-define the return value of `defun', + `defmacro' and `defalias'. + 2012-06-17 Chong Yidong * elisp.texi: Remove urlcolor setting. === modified file 'doc/lispref/functions.texi' --- doc/lispref/functions.texi 2012-06-17 05:13:40 +0000 +++ doc/lispref/functions.texi 2012-06-18 15:57:41 +0000 @@ -530,8 +530,7 @@ @end example @code{defun} stores this lambda expression in the function cell of -@var{name}. It returns the value @var{name}, but usually we ignore this -value. +@var{name}. Its return value is @emph{undefined}. As described previously, @var{argument-list} is a list of argument names and may include the keywords @code{&optional} and @code{&rest}. @@ -543,9 +542,6 @@ @example @group (defun foo () 5) - @result{} foo -@end group -@group (foo) @result{} 5 @end group @@ -553,9 +549,6 @@ @group (defun bar (a &optional b &rest c) (list a b c)) - @result{} bar -@end group -@group (bar 1 2 3 4 5) @result{} (1 2 (3 4 5)) @end group @@ -576,7 +569,6 @@ (forward-word 1) (backward-char 1) (capitalize-word 1)) - @result{} capitalize-backwards @end group @end example @@ -593,7 +585,7 @@ @anchor{Definition of defalias} This special form defines the symbol @var{name} as a function, with definition @var{definition} (which can be any valid Lisp function). -It returns @var{definition}. +Its return value is @emph{undefined}. If @var{docstring} is non-@code{nil}, it becomes the function documentation of @var{name}. Otherwise, any documentation provided by @@ -1015,9 +1007,6 @@ @example @group (defun bar (n) (+ n 2)) - @result{} bar -@end group -@group (symbol-function 'bar) @result{} (lambda (n) (+ n 2)) @end group @@ -1063,9 +1052,6 @@ @example @group (defun foo (x) x) - @result{} foo -@end group -@group (foo 1) @result{}1 @end group === modified file 'doc/lispref/macros.texi' --- doc/lispref/macros.texi 2012-06-17 05:13:40 +0000 +++ doc/lispref/macros.texi 2012-06-18 15:57:41 +0000 @@ -113,7 +113,6 @@ @group (defmacro inc (var) (list 'setq var (list '1+ var))) - @result{} inc @end group @group @@ -124,7 +123,6 @@ @group (defmacro inc2 (var1 var2) (list 'progn (list 'inc var1) (list 'inc var2))) - @result{} inc2 @end group @group @@ -207,9 +205,8 @@ @end example (Note that the @sc{cdr} of this list is a function---a lambda expression.) -This macro object is stored in the function cell of @var{name}. The -value returned by evaluating the @code{defmacro} form is @var{name}, but -usually we ignore this value. +This macro object is stored in the function cell of @var{name}. Its return +value is @emph{undefined}. The shape and meaning of @var{argument-list} is the same as in a function, and the keywords @code{&rest} and @code{&optional} may be used @@ -342,7 +339,6 @@ (cons (list '<= var final) (append body (list (list 'inc var))))))) @end group -@result{} for @group (for i from 1 to 3 do @@ -512,7 +508,6 @@ @group (defmacro foo (a) (list 'setq (eval a) t)) - @result{} foo @end group @group (setq x 'b) === modified file 'etc/NEWS' --- etc/NEWS 2012-06-17 08:53:31 +0000 +++ etc/NEWS 2012-06-18 15:57:41 +0000 @@ -429,6 +429,8 @@ * Lisp changes in Emacs 24.2 +** The return value of `defalias' has changed and is now undefined. + ** `defun' also accepts a (declare DECLS) form, like `defmacro'. The interpretation of the DECLS is determined by `defun-declarations-alist'. === modified file 'lisp/emacs-lisp/byte-run.el' --- lisp/emacs-lisp/byte-run.el 2012-06-09 02:26:47 +0000 +++ lisp/emacs-lisp/byte-run.el 2012-06-18 15:57:41 +0000 @@ -123,7 +123,8 @@ and the result should be a form to be evaluated instead of the original. DECL is a declaration, optional, of the form (declare DECLS...) where DECLS is a list of elements of the form (PROP . VALUES). These are -interpreted according to `macro-declarations-alist'." +interpreted according to `macro-declarations-alist'. +The return value is undefined." (if (stringp docstring) nil (if decl (setq body (cons decl body))) (setq decl docstring) @@ -158,6 +159,7 @@ DECL is a declaration, optional, of the form (declare DECLS...) where DECLS is a list of elements of the form (PROP . VALUES). These are interpreted according to `defun-declarations-alist'. +The return value is undefined. \(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)" ;; We can't just have `decl' as an &optional argument, because we need === modified file 'src/ChangeLog' --- src/ChangeLog 2012-06-18 07:20:19 +0000 +++ src/ChangeLog 2012-06-18 15:57:41 +0000 @@ -1,8 +1,12 @@ +2012-06-18 Stefan Monnier + + * data.c (Fdefalias): Return `symbol' (bug#11686). + 2012-06-18 Martin Rudalics * buffer.c (Fkill_buffer): Don't throw an error when the buffer - gets killed during executing of this function (Bug#11665). Try - to always return Qt when the buffer has been actually killed. + gets killed during executing of this function (Bug#11665). + Try to always return Qt when the buffer has been actually killed. (Vkill_buffer_query_functions): In doc-string say that functions run by this hook should not change the current buffer. @@ -56,8 +60,8 @@ (x_draw_glyph_string): Use them. * xfaces.c (Qline, Qwave): New Lisp objects. (check_lface_attrs, merge_face_ref) - (Finternal_set_lisp_face_attribute, realize_x_face): Handle - wave-style underline face attributes. + (Finternal_set_lisp_face_attribute, realize_x_face): + Handle wave-style underline face attributes. * xterm.c (x_draw_underwave): New function. (x_draw_glyph_string): Use it. @@ -130,8 +134,8 @@ 2012-06-16 Eli Zaretskii - * xdisp.c (set_cursor_from_row): Don't dereference glyphs_end. If - all the glyphs of the glyph row came from strings, and we have no + * xdisp.c (set_cursor_from_row): Don't dereference glyphs_end. + If all the glyphs of the glyph row came from strings, and we have no cursor positioning clues, put the cursor on the first glyph of the row. (handle_face_prop): Use chunk-relative overlay string index when @@ -164,8 +168,8 @@ Simplify under the assumption that USE_2_TAGS_FOR_INTS is defined. (INTTYPEBITS): New macro, for clarity. (INTMASK, MOST_POSITIVE_FIXNUM): Use it. - (LISP_INT1_TAG, LISP_STRING_TAG, LISP_INT_TAG_P): Simplify - now that USE_LSB_TAG is always defined. + (LISP_INT1_TAG, LISP_STRING_TAG, LISP_INT_TAG_P): + Simplify now that USE_LSB_TAG is always defined. (TYPEMASK, XINT) [USE_LSB_TAG]: Remove unnecessary cast. (make_number) [!USE_LSB_TAG]: Use INTMASK; that's simpler. @@ -183,11 +187,11 @@ * lisp.h (Lisp_Object) [CHECK_LISP_OBJECT_TYPE]: Define as struct instead of union. (XLI, XIL): Define. - (XHASH, XTYPE, XINT, XUINT, make_number, XSET, XPNTR, XUNTAG): Use - them. - * emacs.c (gdb_use_struct): Renamed from gdb_use_union. + (XHASH, XTYPE, XINT, XUINT, make_number, XSET, XPNTR, XUNTAG): + Use them. + * emacs.c (gdb_use_struct): Rename from gdb_use_union. * .gdbinit: Check gdb_use_struct instead of gdb_use_union. - * alloc.c (widen_to_Lisp_Object): Removed. + * alloc.c (widen_to_Lisp_Object): Remove. (mark_memory): Use XIL instead of widen_to_Lisp_Object. * frame.c (delete_frame): Remove outdated comment. * w32fns.c (Fw32_register_hot_key): Use XLI instead of checking === modified file 'src/data.c' --- src/data.c 2012-06-13 00:26:40 +0000 +++ src/data.c 2012-06-18 15:57:41 +0000 @@ -637,8 +637,9 @@ Fput (symbol, Qautoload, XCDR (function)); XSYMBOL (symbol)->function = definition; - /* Handle automatic advice activation */ - if (CONSP (XSYMBOL (symbol)->plist) && !NILP (Fget (symbol, Qad_advice_info))) + /* Handle automatic advice activation. */ + if (CONSP (XSYMBOL (symbol)->plist) + && !NILP (Fget (symbol, Qad_advice_info))) { call2 (Qad_activate_internal, symbol, Qnil); definition = XSYMBOL (symbol)->function; @@ -647,11 +648,12 @@ } DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0, - doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION. + doc: /* Set SYMBOL's function definition to DEFINITION. Associates the function with the current load file, if any. The optional third argument DOCSTRING specifies the documentation string for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string -determined by DEFINITION. */) +determined by DEFINITION. +The return value is undefined. */) (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring) { CHECK_SYMBOL (symbol); @@ -666,7 +668,10 @@ LOADHIST_ATTACH (Fcons (Qdefun, symbol)); if (!NILP (docstring)) Fput (symbol, Qfunction_documentation, docstring); - return definition; + /* We used to return `definition', but now that `defun' and `defmacro' expand + to a call to `defalias', we return `symbol' for backward compatibility + (bug#11686). */ + return symbol; } DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0, ------------------------------------------------------------ revno: 108649 committer: martin rudalics branch nick: trunk timestamp: Mon 2012-06-18 09:20:19 +0200 message: Handle cases where buffer gets killed while running Fkill_buffer (Bug#11665). * buffer.c (Fkill_buffer): Don't throw an error when the buffer gets killed during executing of this function (Bug#11665). Try to always return Qt when the buffer has been actually killed. (Vkill_buffer_query_functions): In doc-string say that functions run by this hook should not change the current buffer. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-06-18 06:58:00 +0000 +++ src/ChangeLog 2012-06-18 07:20:19 +0000 @@ -1,3 +1,11 @@ +2012-06-18 Martin Rudalics + + * buffer.c (Fkill_buffer): Don't throw an error when the buffer + gets killed during executing of this function (Bug#11665). Try + to always return Qt when the buffer has been actually killed. + (Vkill_buffer_query_functions): In doc-string say that functions + run by this hook should not change the current buffer. + 2012-06-18 Paul Eggert Fix recently-introduced process.c problems found by static checking. === modified file 'src/buffer.c' --- src/buffer.c 2012-06-16 12:24:15 +0000 +++ src/buffer.c 2012-06-18 07:20:19 +0000 @@ -1434,24 +1434,26 @@ DEFVAR_LISP ("kill-buffer-hook", ..., "\ Hook to be run (by `run-hooks', which see) when a buffer is killed.\n\ The buffer being killed will be current while the hook is running.\n\ -See `kill-buffer'." - */ + +Functions run by this hook are supposed to not change the current +buffer. See `kill-buffer'." +*/ DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", - doc: /* Kill buffer BUFFER-OR-NAME. + doc: /* Kill the buffer specified by BUFFER-OR-NAME. The argument may be a buffer or the name of an existing buffer. Argument nil or omitted means kill the current buffer. Return t if the buffer is actually killed, nil otherwise. -This function calls `replace-buffer-in-windows' for cleaning up all -windows currently displaying the buffer to be killed. The functions in -`kill-buffer-query-functions' are called with the buffer to be killed as -the current buffer. If any of them returns nil, the buffer is not -killed. The hook `kill-buffer-hook' is run before the buffer is -actually killed. The buffer being killed will be current while the hook -is running. +The functions in `kill-buffer-query-functions' are called with the +buffer to be killed as the current buffer. If any of them returns nil, +the buffer is not killed. The hook `kill-buffer-hook' is run before the +buffer is actually killed. The buffer being killed will be current +while the hook is running. Functions called by any of these hooks are +supposed to not change the current buffer. Any processes that have this buffer as the `process-buffer' are killed -with SIGHUP. */) +with SIGHUP. This function calls `replace-buffer-in-windows' for +cleaning up all windows currently displaying the buffer to be killed. */) (Lisp_Object buffer_or_name) { Lisp_Object buffer; @@ -1505,6 +1507,10 @@ unbind_to (count, Qnil); } + /* If the hooks have killed the buffer, exit now. */ + if (NILP (BVAR (b, name))) + return Qt; + /* We have no more questions to ask. Verify that it is valid to kill the buffer. This must be done after the questions since anything can happen within do_yes_or_no_p. */ @@ -1513,9 +1519,6 @@ if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) return Qnil; - if (NILP (BVAR (b, name))) - return Qnil; - /* When we kill a base buffer, kill all its indirect buffers. We do it at this stage so nothing terrible happens if they ask questions or their hooks get errors. */ @@ -1536,6 +1539,10 @@ } UNGCPRO; + + /* Exit if we now have killed the base buffer (Bug#11665). */ + if (NILP (BVAR (b, name))) + return Qt; } /* Run replace_buffer_in_windows before making another buffer current @@ -1544,9 +1551,12 @@ buffer. (Bug#10114) */ replace_buffer_in_windows (buffer); - /* Make this buffer not be current. - In the process, notice if this is the sole visible buffer - and give up if so. */ + /* Exit if replacing the buffer in windows has killed our buffer. */ + if (NILP (BVAR (b, name))) + return Qt; + + /* Make this buffer not be current. Exit if it is the sole visible + buffer. */ if (b == current_buffer) { tem = Fother_buffer (buffer, Qnil, Qnil); @@ -1555,15 +1565,12 @@ return Qnil; } - /* Notice if the buffer to kill is the sole visible buffer - when we're currently in the mini-buffer, and give up if so. */ + /* If the buffer now current is shown in the minibuffer and our buffer + is the sole other buffer give up. */ XSETBUFFER (tem, current_buffer); - if (EQ (tem, XWINDOW (minibuf_window)->buffer)) - { - tem = Fother_buffer (buffer, Qnil, Qnil); - if (EQ (buffer, tem)) - return Qnil; - } + if (EQ (tem, XWINDOW (minibuf_window)->buffer) + && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil))) + return Qnil; /* Now there is no question: we can kill the buffer. */ @@ -1576,11 +1583,10 @@ kill_buffer_processes (buffer); UNGCPRO; - /* Killing buffer processes may run sentinels which may - have called kill-buffer. */ - + /* Killing buffer processes may run sentinels which may have killed + our buffer. */ if (NILP (BVAR (b, name))) - return Qnil; + return Qt; /* These may run Lisp code and into infinite loops (if someone insisted on circular lists) so allow quitting here. */ @@ -1592,8 +1598,7 @@ Vinhibit_quit = Qt; /* Remove the buffer from the list of all buffers. */ Vbuffer_alist = Fdelq (Frassq (buffer, Vbuffer_alist), Vbuffer_alist); - /* If replace_buffer_in_windows didn't do its job correctly fix that - now. */ + /* If replace_buffer_in_windows didn't do its job fix that now. */ replace_buffer_in_windows_safely (buffer); Vinhibit_quit = tem; @@ -1611,6 +1616,10 @@ internal_delete_file (BVAR (b, auto_save_file_name)); } + /* Deleting an auto-save file could have killed our buffer. */ + if (NILP (BVAR (b, name))) + return Qt; + if (b->base_buffer) { /* Unchain all markers that belong to this indirect buffer. @@ -5991,7 +6000,9 @@ DEFVAR_LISP ("kill-buffer-query-functions", Vkill_buffer_query_functions, doc: /* List of functions called with no args to query before killing a buffer. The buffer being killed will be current while the functions are running. -If any of them returns nil, the buffer is not killed. */); + +If any of them returns nil, the buffer is not killed. Functions run by +this hook are supposed to not change the current buffer. */); Vkill_buffer_query_functions = Qnil; DEFVAR_LISP ("change-major-mode-hook", Vchange_major_mode_hook, ------------------------------------------------------------ revno: 108648 committer: Paul Eggert branch nick: trunk timestamp: Sun 2012-06-17 23:58:00 -0700 message: Fix recently-introduced process.c problems found by static checking. * process.c (write_queue_push, write_queue_pop, send_process): Use ptrdiff_t, not int or EMACS_INT, for buffer lengths and offsets. (write_queue_pop): Fix pointer signedness problem. (send_process): Remove unused local. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-06-17 10:11:39 +0000 +++ src/ChangeLog 2012-06-18 06:58:00 +0000 @@ -1,3 +1,11 @@ +2012-06-18 Paul Eggert + + Fix recently-introduced process.c problems found by static checking. + * process.c (write_queue_push, write_queue_pop, send_process): + Use ptrdiff_t, not int or EMACS_INT, for buffer lengths and offsets. + (write_queue_pop): Fix pointer signedness problem. + (send_process): Remove unused local. + 2012-06-17 Chong Yidong * xdisp.c (redisplay_internal): No need to redisplay terminal === modified file 'src/process.c' --- src/process.c 2012-06-17 09:00:37 +0000 +++ src/process.c 2012-06-18 06:58:00 +0000 @@ -5393,9 +5393,9 @@ static void write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj, - const char *buf, int len, int front) + const char *buf, ptrdiff_t len, int front) { - EMACS_INT offset; + ptrdiff_t offset; Lisp_Object entry, obj; if (STRINGP (input_obj)) @@ -5423,10 +5423,10 @@ static int write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj, - const char **buf, EMACS_INT *len) + const char **buf, ptrdiff_t *len) { Lisp_Object entry, offset_length; - EMACS_INT offset; + ptrdiff_t offset; if (NILP (p->write_queue)) return 0; @@ -5439,7 +5439,7 @@ *len = XINT (XCDR (offset_length)); offset = XINT (XCAR (offset_length)); - *buf = SDATA (*obj) + offset; + *buf = SSDATA (*obj) + offset; return 1; } @@ -5584,7 +5584,7 @@ do /* while !NILP (p->write_queue) */ { - EMACS_INT cur_len = -1; + ptrdiff_t cur_len = -1; const char *cur_buf; Lisp_Object cur_object; @@ -5653,8 +5653,6 @@ that may allow the program to finish doing output and read more. */ { - ptrdiff_t offset = 0; - #ifdef BROKEN_PTY_READ_AFTER_EAGAIN /* A gross hack to work around a bug in FreeBSD. In the following sequence, read(2) returns @@ -5680,15 +5678,14 @@ } #endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ - /* Put what we should have written in - wait_queue */ + /* Put what we should have written in wait_queue. */ write_queue_push (p, cur_object, cur_buf, cur_len, 1); #ifdef EMACS_HAS_USECS wait_reading_process_output (0, 20000, 0, 0, Qnil, NULL, 0); #else wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0); #endif - /* reread queue, to see what is left */ + /* Reread queue, to see what is left. */ break; } else