From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Live System User <nyc4bos@aol.com>
Cc: 28700@debbugs.gnu.org
Subject: bug#28700: 25.2; Cannot kill Eshell buffer
Date: Sun, 15 Oct 2017 22:20:52 -0400 [thread overview]
Message-ID: <87376jj0jf.fsf@users.sourceforge.net> (raw)
In-Reply-To: <87d15ooyr5.fsf@aol.com> (Live System User's message of "Sun, 15 Oct 2017 18:02:54 -0400")
[-- Attachment #1: Type: text/plain, Size: 2358 bytes --]
tags 28700 = patch
quit
Live System User <nyc4bos@aol.com> writes:
>> Thanks, my guess is you have some string with a read-only property in
>> eshell history (probably introduced by copying from another buffer), and
>> this is tripping up eshell-write-history.
>>
>> Can you post the result of
>>
>> M-x pp-eval-expression RET eshell-history-ring RET
>>
>> If my guess is correct there should be some strings of the form
>>
>> #("some command" 0 11 (read-only t))
>
> Yes. So how do I deal wi'th?
> #("~/" 0 1
> (rear-nonsticky
> (arg-begin arg-end)
> read-only t arg-begin t)
> 1 2
> (rear-nonsticky
> (arg-end arg-begin)
> read-only t arg-end t))
Ah, there we are. I can't quite work out exactly how you managed to get
such a string, but stripping properties in eshell-write-history should
take care of it regardless. If you evaluate the following defun in your
emacs session, it should be able to exit:
(defun eshell-write-history (&optional filename append)
"Writes the buffer's `eshell-history-ring' to a history file.
The name of the file is given by the variable
`eshell-history-file-name'. The original contents of the file are
lost if `eshell-history-ring' is not empty. If
`eshell-history-file-name' is nil this function does nothing.
Useful within process sentinels.
See also `eshell-read-history'."
(let ((file (or filename eshell-history-file-name)))
(cond
((or (null file)
(equal file "")
(null eshell-history-ring)
(ring-empty-p eshell-history-ring))
nil)
((not (file-writable-p file))
(message "Cannot write history file %s" file))
(t
(let* ((ring eshell-history-ring)
(index (ring-length ring)))
;; Write it all out into a buffer first. Much faster, but
;; messier, than writing it one line at a time.
(with-temp-buffer
(while (> index 0)
(setq index (1- index))
(let ((start (point)))
;; Remove properties before inserting, to avoid trouble
;; with read-only strings (Bug#28700).
(insert (substring-no-properties (ring-ref ring index)) ?\n)
(subst-char-in-region start (1- (point)) ?\n ?\177)))
(eshell-with-private-file-modes
(write-region (point-min) (point-max) file append
'no-message))))))))
Here's the corresponding patch:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1466 bytes --]
From ffaeb09ca6ef9b3d97c8b378c1e5c2b2723dae6f Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 15 Oct 2017 16:41:17 -0400
Subject: [PATCH] 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.
---
lisp/eshell/em-hist.el | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index 1ab3c60b2c..8084c12653 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -444,7 +444,6 @@ eshell-read-history
(ignore-dups eshell-hist-ignoredups))
(with-temp-buffer
(insert-file-contents file)
- ;; Save restriction in case file is already visited...
;; Watch for those date stamps in history files!
(goto-char (point-max))
(while (and (< count size)
@@ -488,7 +487,9 @@ eshell-write-history
(while (> index 0)
(setq index (1- index))
(let ((start (point)))
- (insert (ring-ref ring index) ?\n)
+ ;; Remove properties before inserting, to avoid trouble
+ ;; with read-only strings (Bug#28700).
+ (insert (substring-no-properties (ring-ref ring index)) ?\n)
(subst-char-in-region start (1- (point)) ?\n ?\177)))
(eshell-with-private-file-modes
(write-region (point-min) (point-max) file append
--
2.11.0
next prev parent reply other threads:[~2017-10-16 2:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 9:57 bug#28700: 25.2; Cannot kill Eshell buffer Live System User
2017-10-04 11:56 ` Noam Postavsky
2017-10-04 14:13 ` Live System User
2017-10-04 14:19 ` Noam Postavsky
2017-10-04 15:21 ` Live System User
2017-10-04 16:42 ` Noam Postavsky
2017-10-04 18:27 ` Live System User
2017-10-04 18:32 ` Noam Postavsky
2017-10-04 19:50 ` Live System User
2017-10-04 19:56 ` Noam Postavsky
2017-10-04 22:12 ` Live System User
2017-10-04 23:48 ` Noam Postavsky
2017-10-15 19:09 ` Live System User
2017-10-15 19:48 ` Noam Postavsky
2017-10-15 22:02 ` Live System User
2017-10-16 2:20 ` Noam Postavsky [this message]
2017-10-21 19:51 ` Noam Postavsky
2017-10-15 19:29 ` Live System User
2017-10-05 8:09 ` martin rudalics
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87376jj0jf.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=28700@debbugs.gnu.org \
--cc=nyc4bos@aol.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.