Yidong, many thanks for the tweaks and fixes.
Let's keep this bug open for a bit longer. I am thinking of generalising
occur-edit-mode (probably rename it to match-line-edit) so that it
covers buffers from grep and the like.
Leo
Is there a way to _disable_ this feature? I'm quite often edit the
*Occur* and *grep* buffers for line-up results, etc, just for easier
understanding results, but I don't want these edits to be mirrored
into original lines or files from where they are come.
--
Andrew W. Nosenko <andrew.w...@gmail.com>
I am not surprised you want to disable it.
Maybe it should be disabled by default.
--
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org, www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
Use free telephony http://directory.fsf.org/category/tel/
> Is there a way to _disable_ this feature? I'm quite often edit the
> *Occur* and *grep* buffers for line-up results, etc, just for easier
> understanding results, but I don't want these edits to be mirrored
> into original lines or files from where they are come.
Me too.
I expect C-x C-q to toggle the read-only state of a buffer, not switch
me into some unusual mode. I suggest binding this new mode to some other
key.
Other issues with this:
1. After C-x C-q, I can no longer kill entire lines in the occur buffer.
Trying to do so reports "Text is read-only".
2. After C-x C-q, If I delete some text in the occur buffer, then use
"undo", when I reach the point at which there is no more to undo, I get:
"Wrong type argument: markerp, nil" rather than "No further undo information".
Debugger entered--Lisp error: (wrong-type-argument markerp nil)
marker-buffer(nil)
occur-after-change-function(1 40 39)
primitive-undo(1 ((nil font-lock-face underline 1 . 40) (t 0 . 0)))
undo-more(1)
undo(nil)
call-interactively(undo nil nil)
3. After C-x C-q, M-x revert-buffer in the occur buffer triggers an error:
apply: Wrong number of arguments: #[(regexp nlines bufs &optional buf-name)
occur-1("*Occur*")
apply(occur-1 "*Occur*")
occur-revert-function(t nil)
revert-buffer(t)
call-interactively(revert-buffer t nil)
execute-extended-command(nil)
call-interactively(execute-extended-command nil nil)
I guess the mode change clobbers occur-revert-arguments.
Thank you for this feedback. I will try to address these issues when I
am back from a trip on Tuesday.
Leo
I think it makes sense to bind the occur-edit feature to some other key
than C-x C-q.
While C-x C-q is a cute binding for it, it does hide a command that is
also useful.
Stefan
Unfortunately, C-x C-q is consistent with the command for switching to
wdired mode.
I don't think this argument is really valid. First of all, C-x C-q is
consistent with the command to switch read-only-ness of a buffer, and
that's apparently what at least some people still expect and are used to
in this case. It might have made sense to override it for Wdired, but
not necessarily here.
Štěpán
Right, but wdired and occur-edit are two different things.
Editing a dired buffer in wdired does not have any other side effect
(at least not until you "commit" those changes), so its behavior is
still pretty close to toggle-read-only. Occur-edit is somewhat
reminiscent of wdired, but does not match the behavior of
toggle-read-only quite as closely.
Stefan
This can be fixed with:
diff --git a/lisp/replace.el b/lisp/replace.el
index 0578ed09..fc2db2ec 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -882,11 +882,11 @@ (define-derived-mode occur-edit-mode occur-mode "Occur-Edit"
(defun occur-after-change-function (beg end length)
(save-excursion
- (goto-char beg)
(let* ((m (get-text-property (line-beginning-position) 'occur-target))
(buf (marker-buffer m))
(col (current-column)))
(when (= length 0)
+ (goto-char beg)
;; Apply occur-target property to inserted (e.g. yanked) text.
(put-text-property beg end 'occur-target m)
;; Did we insert a newline? Occur Edit mode can't create new
The cause:
When switching major-mode (in this case occur-edit-mode), an undo entry
containing text-property only change is added due to this line in
occur-mode:
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
That line seems useless due to change made in revid 22063400b. If no one
objects, I intend to also remove it.
Leo
> revid 22063400b.
Speaking for myself, I have no idea what that means.
1. After C-x C-q, I can no longer kill entire lines in the occur buffer.
Trying to do so reports "Text is read-only".
The text properties are now added when entering occur-edit-mode.
2. After C-x C-q, If I delete some text in the occur buffer, then use
"undo", when I reach the point at which there is no more to undo, I get:
"Wrong type argument: markerp, nil" rather than "No further undo information".
Debugger entered--Lisp error: (wrong-type-argument markerp nil)
marker-buffer(nil)
occur-after-change-function(1 40 39)
primitive-undo(1 ((nil font-lock-face underline 1 . 40) (t 0 . 0)))
undo-more(1)
undo(nil)
call-interactively(undo nil nil)
Fixed.
3. After C-x C-q, M-x revert-buffer in the occur buffer triggers an error
occur-revert-arguments is killed after any major-mode change. In the
patch this has been made permanent-local.
Comments welcome. Thanks.
That's what I saw on the annotation buffer (from C-x v g). I was able to
view the diff there with 'd'.
Leo
Git sha values are generally not useful for someone who uses bzr. It
would be nice if people who report problems could also mention the bzr
revision or revid.
My bad. I thought I was on the bzr repo.
Leo
> I think maybe we should assign C-c C-c to occur-edit-mode instead.
Or "e" (for edit; like in Rmail).
> 1. After C-x C-q, I can no longer kill entire lines in the occur buffer.
> Trying to do so reports "Text is read-only".
>
> The text properties are now added when entering occur-edit-mode.
I don't understand if that means it's fixed. Deleting whole or even
multiple lines is an operation I might want to do in occur-edit-mode.
I don't like that: C-c C-c means "done" usually so it'd be OK to leave
edit mode, but not to enter it.
> Or "e" (for edit; like in Rmail).
That sounds good.
>> 1. After C-x C-q, I can no longer kill entire lines in the occur buffer.
>> Trying to do so reports "Text is read-only".
>> The text properties are now added when entering occur-edit-mode.
> I don't understand if that means it's fixed. Deleting whole or even
> multiple lines is an operation I might want to do in occur-edit-mode.
But its meaning is unclear and we get to choose what is allowed and what
is not in edit mode since it's a new mode that the user
requested explicitly.
Stefan
>>> 1. After C-x C-q, I can no longer kill entire lines in the occur buffer.
>>> Trying to do so reports "Text is read-only".
>>> The text properties are now added when entering occur-edit-mode.
>> I don't understand if that means it's fixed. Deleting whole or even
>> multiple lines is an operation I might want to do in occur-edit-mode.
SM> But its meaning is unclear and we get to choose what is allowed and what
SM> is not in edit mode since it's a new mode that the user
SM> requested explicitly.
I'd suggest binding `d' to "delete entire line" outside the edit mode,
so the edit mode does not need to provide it and still it's available in
a convenient way.
Ted
But not for case, when user already switched the *Occur* buffer into
read/write mode for editing the buffer itself (not the underlying
files/buffers, where occurrences come from).
The same applied for Ted's proposal for 'd' key and any other keys
that used for regular text typing.
Then maybe `M-e' (like in isearch mode)?
> The same applied for Ted's proposal for 'd' key and any other keys
> that used for regular text typing.
There is already `C-k' to do this.
If separate apply-changes-to-underlying-buffers action to the own
function (may be even it already implemented in that way) then all
controversy will gone. -- Enter to read-write mode -- the same,
editing commands -- the same, all other behavior -- the same. Just
because there will work one and the same code in the one and the same
mode. Difference is only one between my usage model and usage model
of Leo (original author) -- after finishing I simple kill the occur
buffer, while Leo call the "apply-cachanges-to-underlying-buffers" for
"commit" the final results.
IMHO anyone can benefit from solving the problem in that way.
>>> Or "e" (for edit; like in Rmail).
>>
>> That sounds good.
>
> But not for case, when user already switched the *Occur* buffer into
> read/write mode for editing the buffer itself (not the underlying
> files/buffers, where occurrences come from).
That's already the case with "r" (occur-rename-buffer), "c"
(clone-buffer), and "o" (occur-mode-goto-occurrence-other-window).
Yes, but: (1) these actions aren't destructive in respect to the
original data, and (2) I would to prefer to see the number of such
bindings decreasing, not increasing.
* replace.el (occur-mode-map): Set occur-edit-mode binding to "e".
I guess it was supposed to bind "e" to `occur-edit-mode' in `occur-mode-map'?
Thanks, this is fine now except one little problem:
after finishing Occur-Edit, `g' (`revert-buffer') fails with
"Wrong number of arguments: #[(regexp nlines bufs &optional buf-name)..."
There is a fix in http://debbugs.gnu.org/8463#47
that makes `occur-revert-arguments' permanent-local.