diff options
| author | Noam Postavsky | 2017-10-15 16:41:17 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2017-10-21 15:19:14 -0400 |
| commit | 9e4265ef91bd659a5fac49fbe7dc34b91f89d4ed (patch) | |
| tree | d67e58b6f2682acfd271dd89bd01cc5d39b4cdeb | |
| parent | 0f286ca85a259575b67dba520ff72e59cc011426 (diff) | |
| download | emacs-9e4265ef91bd659a5fac49fbe7dc34b91f89d4ed.tar.gz emacs-9e4265ef91bd659a5fac49fbe7dc34b91f89d4ed.zip | |
Ignore string properties when saving eshell history (Bug#28700)
* lisp/eshell/em-hist.el (eshell-write-history): Remove properties
before inserting history strings.
(eshell-read-history): Remove obsolete comment.
* test/lisp/eshell/em-hist-tests.el (eshell-write-readonly-history):
New test.
| -rw-r--r-- | lisp/eshell/em-hist.el | 5 | ||||
| -rw-r--r-- | test/lisp/eshell/em-hist-tests.el | 39 | ||||
| -rw-r--r-- | test/lisp/eshell/eshell-tests.el | 2 |
3 files changed, 43 insertions, 3 deletions
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index 1ab3c60b2c7..8084c126530 100644 --- a/lisp/eshell/em-hist.el +++ b/lisp/eshell/em-hist.el | |||
| @@ -444,7 +444,6 @@ line, with the most recent command last. See also | |||
| 444 | (ignore-dups eshell-hist-ignoredups)) | 444 | (ignore-dups eshell-hist-ignoredups)) |
| 445 | (with-temp-buffer | 445 | (with-temp-buffer |
| 446 | (insert-file-contents file) | 446 | (insert-file-contents file) |
| 447 | ;; Save restriction in case file is already visited... | ||
| 448 | ;; Watch for those date stamps in history files! | 447 | ;; Watch for those date stamps in history files! |
| 449 | (goto-char (point-max)) | 448 | (goto-char (point-max)) |
| 450 | (while (and (< count size) | 449 | (while (and (< count size) |
| @@ -488,7 +487,9 @@ See also `eshell-read-history'." | |||
| 488 | (while (> index 0) | 487 | (while (> index 0) |
| 489 | (setq index (1- index)) | 488 | (setq index (1- index)) |
| 490 | (let ((start (point))) | 489 | (let ((start (point))) |
| 491 | (insert (ring-ref ring index) ?\n) | 490 | ;; Remove properties before inserting, to avoid trouble |
| 491 | ;; with read-only strings (Bug#28700). | ||
| 492 | (insert (substring-no-properties (ring-ref ring index)) ?\n) | ||
| 492 | (subst-char-in-region start (1- (point)) ?\n ?\177))) | 493 | (subst-char-in-region start (1- (point)) ?\n ?\177))) |
| 493 | (eshell-with-private-file-modes | 494 | (eshell-with-private-file-modes |
| 494 | (write-region (point-min) (point-max) file append | 495 | (write-region (point-min) (point-max) file append |
diff --git a/test/lisp/eshell/em-hist-tests.el b/test/lisp/eshell/em-hist-tests.el new file mode 100644 index 00000000000..7e0d6142812 --- /dev/null +++ b/test/lisp/eshell/em-hist-tests.el | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | ;;; tests/em-hist-tests.el --- em-hist test suite | ||
| 2 | |||
| 3 | ;; Copyright (C) 2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | (require 'em-hist) | ||
| 24 | |||
| 25 | (ert-deftest eshell-write-readonly-history () | ||
| 26 | "Test that having read-only strings in history is okay." | ||
| 27 | (let ((histfile (make-temp-file "eshell-history")) | ||
| 28 | (eshell-history-ring (make-ring 2))) | ||
| 29 | (ring-insert eshell-history-ring | ||
| 30 | (propertize "echo foo" 'read-only t)) | ||
| 31 | (ring-insert eshell-history-ring | ||
| 32 | (propertize "echo bar" 'read-only t)) | ||
| 33 | (unwind-protect | ||
| 34 | (eshell-write-history histfile) | ||
| 35 | (delete-file histfile)))) | ||
| 36 | |||
| 37 | (provide 'em-hist-test) | ||
| 38 | |||
| 39 | ;;; em-hist-tests.el ends here | ||
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index 4e0d6dc7621..58b8aa58bf1 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el | |||
| @@ -247,6 +247,6 @@ chars" | |||
| 247 | (goto-char eshell-last-input-start) | 247 | (goto-char eshell-last-input-start) |
| 248 | (string= (eshell-get-old-input) "echo alpha"))) | 248 | (string= (eshell-get-old-input) "echo alpha"))) |
| 249 | 249 | ||
| 250 | (provide 'esh-test) | 250 | (provide 'eshell-tests) |
| 251 | 251 | ||
| 252 | ;;; tests/eshell-tests.el ends here | 252 | ;;; tests/eshell-tests.el ends here |