commit 792d44b3c31d2a682607ab8b79ae7d26b7402f41 (HEAD, refs/remotes/origin/master) Author: Wolfgang Jenkner Date: Fri Mar 27 02:54:39 2015 +0100 Preserve face text properties in comint prompt. Fixes: debbugs:20084 * lisp/font-lock.el (font-lock--remove-face-from-text-property): New function. Adapted from the previously commented out remove-single-text-property. Remove previously unused and commented out auxiliary function remove-text-property and obsolete comment. * lisp/comint.el (comint-output-filter): Use it to remove comint-highlight-prompt. (comint-snapshot-last-prompt, comint-output-filter): Use font-lock-prepend-text-property for comint-highlight-prompt. * test/automated/textprop-tests.el: New file. (textprop-tests-font-lock--remove-face-from-text-property): New test. Thus, the original face text property of a prompt "candidate" (the last line of an output chunk not ending with a newline) is preserved. This amends the fix for bug#14744. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0cc7bc6..b2d431c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,16 @@ +2015-03-27 Wolfgang Jenkner + + * font-lock.el (font-lock--remove-face-from-text-property): New + function. Adapted from the previously commented out + remove-single-text-property. + Remove previously unused and commented out auxiliary function + remove-text-property and obsolete comment. + * comint.el (comint-output-filter): Use it to remove + comint-highlight-prompt. + (comint-snapshot-last-prompt, comint-output-filter): Use + font-lock-prepend-text-property for comint-highlight-prompt. + (Bug#20084) + 2015-03-26 Daniel Colascione * progmodes/python.el (python-indent-guess-indent-offset-verbose): New defcustom. diff --git a/lisp/comint.el b/lisp/comint.el index b6944da..31649ff 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -1930,10 +1930,10 @@ the start, the cdr to the end of the last prompt recognized.") Freezes the `font-lock-face' text property in place." (when comint-last-prompt (with-silent-modifications - (add-text-properties + (font-lock-prepend-text-property (car comint-last-prompt) (cdr comint-last-prompt) - '(font-lock-face comint-highlight-prompt))) + 'font-lock-face 'comint-highlight-prompt)) ;; Reset comint-last-prompt so later on comint-output-filter does ;; not remove the font-lock-face text property of the previous ;; (this) prompt. @@ -2084,14 +2084,19 @@ Make backspaces delete the previous character." (add-text-properties prompt-start (point) '(read-only t front-sticky (read-only))))) (when comint-last-prompt - (remove-text-properties (car comint-last-prompt) - (cdr comint-last-prompt) - '(font-lock-face))) + (with-silent-modifications + (font-lock--remove-face-from-text-property + (car comint-last-prompt) + (cdr comint-last-prompt) + 'font-lock-face + 'comint-highlight-prompt))) (setq comint-last-prompt (cons (copy-marker prompt-start) (point-marker))) - (add-text-properties prompt-start (point) - '(rear-nonsticky t - font-lock-face comint-highlight-prompt))) + (with-silent-modifications + (font-lock-prepend-text-property prompt-start (point) + 'font-lock-face + 'comint-highlight-prompt) + (add-text-properties prompt-start (point) '(rear-nonsticky t)))) (goto-char saved-point))))))) (defun comint-preinput-scroll-to-bottom () diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 1838a0f..6c8392b 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1418,37 +1418,33 @@ Optional argument OBJECT is the string or buffer containing the text." (put-text-property start next prop value object) (setq start (text-property-any next end prop nil object))))) -;; For completeness: this is to `remove-text-properties' as `put-text-property' -;; is to `add-text-properties', etc. -;;(defun remove-text-property (start end property &optional object) -;; "Remove a property from text from START to END. -;;Argument PROPERTY is the property to remove. -;;Optional argument OBJECT is the string or buffer containing the text. -;;Return t if the property was actually removed, nil otherwise." -;; (remove-text-properties start end (list property) object)) - -;; For consistency: maybe this should be called `remove-single-property' like -;; `next-single-property-change' (not `next-single-text-property-change'), etc. -;;(defun remove-single-text-property (start end prop value &optional object) -;; "Remove a specific property value from text from START to END. -;;Arguments PROP and VALUE specify the property and value to remove. The -;;resulting property values are not equal to VALUE nor lists containing VALUE. -;;Optional argument OBJECT is the string or buffer containing the text." -;; (let ((start (text-property-not-all start end prop nil object)) next prev) -;; (while start -;; (setq next (next-single-property-change start prop object end) -;; prev (get-text-property start prop object)) -;; (cond ((and (symbolp prev) (eq value prev)) -;; (remove-text-property start next prop object)) -;; ((and (listp prev) (memq value prev)) -;; (let ((new (delq value prev))) -;; (cond ((null new) -;; (remove-text-property start next prop object)) -;; ((= (length new) 1) -;; (put-text-property start next prop (car new) object)) -;; (t -;; (put-text-property start next prop new object)))))) -;; (setq start (text-property-not-all next end prop nil object))))) +(defun font-lock--remove-face-from-text-property (start + end + prop value &optional object) + "Remove a specific property value from text from START to END. +Arguments PROP and VALUE specify the property and value to remove. The +resulting property values are not `eq' to VALUE nor lists containing VALUE. +Optional argument OBJECT is the string or buffer containing the text." + (let ((start (text-property-not-all start end prop nil object)) next prev) + (while start + (setq next (next-single-property-change start prop object end) + prev (get-text-property start prop object)) + (cond ((or (atom prev) + (keywordp (car prev)) + (eq (car prev) 'foreground-color) + (eq (car prev) 'background-color)) + (when (eq value prev) + (remove-list-of-text-properties start next (list prop) object))) + ((memq value prev) ;Assume prev is not dotted. + (let ((new (remq value prev))) + (cond ((null new) + (remove-list-of-text-properties start next (list prop) + object)) + ((= (length new) 1) + (put-text-property start next prop (car new) object)) + (t + (put-text-property start next prop new object)))))) + (setq start (text-property-not-all next end prop nil object))))) ;;; End of Additional text property functions. diff --git a/test/ChangeLog b/test/ChangeLog index a9cad31..30b8841 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2015-03-27 Wolfgang Jenkner + + * automated/textprop-tests.el: New file. + (textprop-tests-font-lock--remove-face-from-text-property): New test. + 2015-03-24 Michael Albinus * automated/tramp-tests.el (tramp-test18-file-attributes) diff --git a/test/automated/textprop-tests.el b/test/automated/textprop-tests.el new file mode 100644 index 0000000..310a7a0 --- /dev/null +++ b/test/automated/textprop-tests.el @@ -0,0 +1,57 @@ +;;; textprop-tests.el --- Test suite for text properties. + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Wolfgang Jenkner +;; Keywords: internal + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) + +(ert-deftest textprop-tests-font-lock--remove-face-from-text-property () + "Test `font-lock--remove-face-from-text-property'." + (let* ((string "foobar") + (stack (list string)) + (faces '(bold (:foreground "red") underline))) + ;; Build each string in `stack' by adding a face to the previous + ;; string. + (let ((faces (reverse faces))) + (push (copy-sequence (car stack)) stack) + (put-text-property 0 3 'font-lock-face (pop faces) (car stack)) + (push (copy-sequence (car stack)) stack) + (put-text-property 3 6 'font-lock-face (pop faces) (car stack)) + (push (copy-sequence (car stack)) stack) + (font-lock-prepend-text-property 2 5 + 'font-lock-face (pop faces) (car stack))) + ;; Check that removing the corresponding face from each string + ;; yields the previous string in `stack'. + (while faces + ;; (message "%S" (car stack)) + (should (equal-including-properties + (progn + (font-lock--remove-face-from-text-property 0 6 + 'font-lock-face + (pop faces) + (car stack)) + (pop stack)) + (car stack)))) + ;; Sanity check. + ;; (message "%S" (car stack)) + (should (and (equal-including-properties (pop stack) string) + (null stack))))) commit 1d02107dab6f844a7c537bb5e98aff4e5f061246 Author: Daniel Colascione Date: Thu Mar 26 13:44:45 2015 -0700 Shut up python-mode's indentation guesser * lisp/progmodes/python.el (python-indent-guess-indent-offset-verbose): New defcustom. (python-indent-guess-indent-offset): Use it. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 294bcfe..0cc7bc6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2015-03-26 Daniel Colascione + * progmodes/python.el + (python-indent-guess-indent-offset-verbose): New defcustom. + (python-indent-guess-indent-offset): Use it. + 2015-03-26 Stefan Monnier * emacs-lisp/eieio.el (defclass): Change internal name so as to make diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 42272a9..67b44aa 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -696,6 +696,12 @@ It makes underscores and dots word constituent chars.") :group 'python :safe 'booleanp) +(defcustom python-indent-guess-indent-offset-verbose t + "Non-nil means to emit a warning when indentation guessing fails." + :type 'boolean + :group 'python + :safe' booleanp) + (defcustom python-indent-trigger-commands '(indent-for-tab-command yas-expand yas/expand) "Commands that might trigger a `python-indent-line' call." @@ -766,8 +772,9 @@ work on `python-indent-calculate-indentation' instead." (current-indentation)))) (if (and indentation (not (zerop indentation))) (set (make-local-variable 'python-indent-offset) indentation) - (message "Can't guess python-indent-offset, using defaults: %s" - python-indent-offset))))))) + (when python-indent-guess-indent-offset-verbose + (message "Can't guess python-indent-offset, using defaults: %s" + python-indent-offset)))))))) (defun python-indent-context () "Get information about the current indentation context. commit 8fd527eb00a0ec1d8d7cf916204c3be3e79e27da Author: Stefan Monnier Date: Thu Mar 26 13:32:45 2015 -0400 * lisp/emacs-lisp/cl|eieio: Minor tweaks * lisp/emacs-lisp/cl-macs.el (cl-dolist, cl-dotimes): Silence byte-compiler. * lisp/emacs-lisp/eieio.el (defclass): Change internal name so as to make sure only EIEIO files should have "eieio--" prefixes in their .elc. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 37ac1c5..294bcfe 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2015-03-26 Stefan Monnier + + * emacs-lisp/eieio.el (defclass): Change internal name so as to make + sure only EIEIO files should have "eieio--" prefixes in their .elc. + + * emacs-lisp/cl-macs.el (cl-dolist, cl-dotimes): Silence byte-compiler. + 2015-03-26 Boruch Baum (tiny change) * bookmark.el (bookmark-show-all-annotations): Sort them (bug#20177). diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 5d55a1d..f8ddc00 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -1752,7 +1752,7 @@ An implicit nil block is established around the loop. (declare (debug ((symbolp form &optional form) cl-declarations body)) (indent 1)) (let ((loop `(dolist ,spec ,@body))) - (if (advice-member-p #'cl--wrap-in-nil-block 'dolist) + (if (advice-member-p 'cl--wrap-in-nil-block 'dolist) loop `(cl-block nil ,loop)))) ;;;###autoload @@ -1765,7 +1765,7 @@ nil. \(fn (VAR COUNT [RESULT]) BODY...)" (declare (debug cl-dolist) (indent 1)) (let ((loop `(dotimes ,spec ,@body))) - (if (advice-member-p #'cl--wrap-in-nil-block 'dotimes) + (if (advice-member-p 'cl--wrap-in-nil-block 'dotimes) loop `(cl-block nil ,loop)))) (defvar cl--tagbody-alist nil) diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 2772514..bca53c0 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -130,7 +130,7 @@ and reference them using the function `class-option'." (error "Method invocation order %s is not allowed" io))) (let ((testsym1 (intern (concat (symbol-name name) "-p"))) - (testsym2 (intern (format "eieio--childp--%s" name))) + (testsym2 (intern (format "%s--eieio-childp" name))) (accessors ())) ;; Collect the accessors we need to define.