* Small enhancement for add-log.el
@ 2004-10-07 22:06 Kim F. Storm
2004-10-07 22:21 ` David Kastrup
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Kim F. Storm @ 2004-10-07 22:06 UTC (permalink / raw)
When I look through ChangeLog files, I often type `q' to quit --
but instead a q is inserted into the buffer.
What about the following change [I know it's a hack] which kills the
buffer if you type `q' in an unmodified ChangeLog buffer.
It should be pretty safe, as the buffer is modified after C-x 4 a
and similar commands.
Index: lisp/add-log.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/add-log.el,v
retrieving revision 1.151
diff -u -r1.151 add-log.el
--- lisp/add-log.el 25 Jun 2004 14:45:00 -0000 1.151
+++ lisp/add-log.el 7 Oct 2004 22:01:34 -0000
@@ -256,6 +256,7 @@
(let ((map (make-sparse-keymap)))
(define-key map [?\C-c ?\C-p] 'add-log-edit-prev-comment)
(define-key map [?\C-c ?\C-n] 'add-log-edit-next-comment)
+ (define-key map "q" 'add-log-edit-quit-if-unmod)
map)
"Keymap for Change Log major mode.")
@@ -322,6 +323,13 @@
(interactive "*p")
(add-log-edit-prev-comment (- arg)))
+(defun add-log-edit-quit-if-unmod (&optional arg)
+ "Quit change log buffer if never modified."
+ (interactive "p")
+ (if (buffer-modified-p)
+ (insert-char (aref (this-single-command-keys) 0) arg)
+ (kill-buffer nil)))
+
;;;###autoload
(defun prompt-for-change-log-name ()
"Prompt for a change log name."
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-07 22:06 Small enhancement for add-log.el Kim F. Storm
@ 2004-10-07 22:21 ` David Kastrup
2004-10-07 23:00 ` Kim F. Storm
2004-10-07 23:07 ` Luc Teirlinck
2004-10-09 15:44 ` Richard Stallman
2 siblings, 1 reply; 15+ messages in thread
From: David Kastrup @ 2004-10-07 22:21 UTC (permalink / raw)
Cc: emacs-devel
storm@cua.dk (Kim F. Storm) writes:
> When I look through ChangeLog files, I often type `q' to quit --
> but instead a q is inserted into the buffer.
>
> What about the following change [I know it's a hack] which kills the
> buffer if you type `q' in an unmodified ChangeLog buffer.
I vote no. Far too inconsistent with normal editing to be thrown at
an unsuspecting user. If you want to do anything useful, invent a
keybinding that will visit the corresponding ChangeLog in view mode:
then q will do the right thing, anyway, and you can leaf faster
through the ChangeLog with Space and Backspace, too.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-07 22:21 ` David Kastrup
@ 2004-10-07 23:00 ` Kim F. Storm
2004-10-08 12:25 ` Kai Grossjohann
0 siblings, 1 reply; 15+ messages in thread
From: Kim F. Storm @ 2004-10-07 23:00 UTC (permalink / raw)
Cc: emacs-devel
David Kastrup <dak@gnu.org> writes:
> storm@cua.dk (Kim F. Storm) writes:
>
>> When I look through ChangeLog files, I often type `q' to quit --
>> but instead a q is inserted into the buffer.
>>
>> What about the following change [I know it's a hack] which kills the
>> buffer if you type `q' in an unmodified ChangeLog buffer.
>
> I vote no. Far too inconsistent with normal editing to be thrown at
> an unsuspecting user. If you want to do anything useful, invent a
> keybinding that will visit the corresponding ChangeLog in view mode:
> then q will do the right thing, anyway, and you can leaf faster
> through the ChangeLog with Space and Backspace, too.
I usually browse the ChangeLogs from a pcl-cvs buffer; there SPC (or
mouse-2) opens the ChangeLog in "ChangeLog mode", not view mode.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-07 22:06 Small enhancement for add-log.el Kim F. Storm
2004-10-07 22:21 ` David Kastrup
@ 2004-10-07 23:07 ` Luc Teirlinck
2004-10-08 8:54 ` Kim F. Storm
2004-10-09 15:44 ` Richard Stallman
2 siblings, 1 reply; 15+ messages in thread
From: Luc Teirlinck @ 2004-10-07 23:07 UTC (permalink / raw)
Cc: emacs-devel
Kim Storm wrote:
When I look through ChangeLog files, I often type `q' to quit --
but instead a q is inserted into the buffer.
What about the following change [I know it's a hack] which kills the
buffer if you type `q' in an unmodified ChangeLog buffer.
I do not have this tendency myself and I believe that this is just a
personal idiosyncrasy. I believe the probability of doing that would
be a lot bigger when editing etc/NEWS, because there everything looks
exactly like if you had done `C-h n'. Even for etc/NEWS, I would not
recommend your solution.
I have other idiosyncrasies myself. In a buffer visiting a file, I
often type `^', expecting to visit the file's directory in Dired
(because I think of `^' as going up in the directory tree). I just
erase the `^' and do `C-x d'. I am not going to suggest to rebind `^'
in file visiting buffers, to fit that habit of mine.
It should be pretty safe, as the buffer is modified after C-x 4 a
and similar commands.
But it is no longer modified after you save your changes without being
completely through editing. (I often do that.) Having to erase the
`q' and having to type `C-x k' is by no means as inconvenient as
having to revisit the file and losing all your undo history.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-07 23:07 ` Luc Teirlinck
@ 2004-10-08 8:54 ` Kim F. Storm
2004-10-08 13:01 ` Luc Teirlinck
2004-10-08 13:19 ` Stefan
0 siblings, 2 replies; 15+ messages in thread
From: Kim F. Storm @ 2004-10-08 8:54 UTC (permalink / raw)
Cc: emacs-devel
Luc Teirlinck <teirllm@dms.auburn.edu> writes:
> Kim Storm wrote:
>
> When I look through ChangeLog files, I often type `q' to quit --
> but instead a q is inserted into the buffer.
>
> What about the following change [I know it's a hack] which kills the
> buffer if you type `q' in an unmodified ChangeLog buffer.
>
> I do not have this tendency myself and I believe that this is just a
> personal idiosyncrasy. I believe the probability of doing that would
> be a lot bigger when editing etc/NEWS, because there everything looks
> exactly like if you had done `C-h n'. Even for etc/NEWS, I would not
> recommend your solution.
I originally tried to use first-change-hook to disable the 'q' command,
but it turns out that if you have font-lock in a buffer, first-change-hook
is useless, as the fontification adds text properties, and that is
seen as a modification of the buffer (even when the buffer modification
flag is restored).
I then tried to use buffer-modified-tick, but that has the same problem.
Is there some way to implement a first-user-change-hook ?
>
> I have other idiosyncrasies myself. In a buffer visiting a file, I
> often type `^', expecting to visit the file's directory in Dired
> (because I think of `^' as going up in the directory tree). I just
> erase the `^' and do `C-x d'. I am not going to suggest to rebind `^'
> in file visiting buffers, to fit that habit of mine.
Still, it should be possible to have a sort of "pseudo-view-minor-mode"
which works like view mode until you make some "real change" to a file.
>
> It should be pretty safe, as the buffer is modified after C-x 4 a
> and similar commands.
>
> But it is no longer modified after you save your changes without being
> completely through editing. (I often do that.)
I don't like that either -- but (buffer-modified-p) was the only
method I could find since first-change-hook doesn't work.
But maybe I could use an after-save-hook to inhibit the feature once
a modified buffer has been saved once.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-08 8:54 ` Kim F. Storm
@ 2004-10-08 13:01 ` Luc Teirlinck
2004-10-08 13:44 ` Kim F. Storm
2004-10-11 22:23 ` Kim F. Storm
2004-10-08 13:19 ` Stefan
1 sibling, 2 replies; 15+ messages in thread
From: Luc Teirlinck @ 2004-10-08 13:01 UTC (permalink / raw)
Cc: emacs-devel
I still do not understand why you expect q in a Changelog buffer to do
anything else but insert itself, as it does in any other editable
buffer.
I usually browse the ChangeLogs from a pcl-cvs buffer; there SPC (or
mouse-2) opens the ChangeLog in "ChangeLog mode", not view mode.
I use VC myself, so I am not familiar with pcl-cvs, but apparently
you seem to _expect_ SPC to open the ChangeLog in View mode. This
would appear to be strictly a pcl-cvs issue, as Kai suggested.
Still, it should be possible to have a sort of "pseudo-view-minor-mode"
which works like view mode until you make some "real change" to a file.
I believe it would be _way_ too confusing to the user to enable
anything like that by default. It could be argued that no feature
does any harm if completely optional, but I can not see why it would
be worth the trouble. If you want to visit a buffer in View mode,
just visit it in View mode. Again, I believe that the only problem is
that there is something in the pcl-cvs interface that you do not like.
Apart from that there does not seem to be a big problem. accidentally
inserting a character is no big deal. You either hit `undo' or
Backspace. End of problem. Happens all the time for various reasons.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-08 13:01 ` Luc Teirlinck
@ 2004-10-08 13:44 ` Kim F. Storm
2004-10-08 22:45 ` Luc Teirlinck
2004-10-11 22:23 ` Kim F. Storm
1 sibling, 1 reply; 15+ messages in thread
From: Kim F. Storm @ 2004-10-08 13:44 UTC (permalink / raw)
Cc: emacs-devel
Luc Teirlinck <teirllm@dms.auburn.edu> writes:
> I still do not understand why you expect q in a Changelog buffer to do
> anything else but insert itself, as it does in any other editable
> buffer.
Personally I would find it "consistent" if 'q' could be used to quit
out of any buffer that I have just "looked at" and never intended to
change--whether I opened it (or some other command opened it) in
view-mode or not (as is the case for pcl-cvs).
Whether I can 'expect that' is another issue -- for me, the
convenience of being able to do so would IMHO greatly exceed the
rare(?) inconvenience of having to do something special if I
really need to insert a 'q' as the first character in a buffer after
opening it.
Of course, if I also want SPC and DEL to behave like view-mode, things
may get more confusing.
> Still, it should be possible to have a sort of "pseudo-view-minor-mode"
> which works like view mode until you make some "real change" to a file.
>
> I believe it would be _way_ too confusing to the
(unprepared)
> user to enable
> anything like that by default.
I agree it should not be the default (although my patch suggested that).
> It could be argued that no feature
> does any harm if completely optional, but I can not see why it would
> be worth the trouble.
YMMV.
I could make a pseudo-view-minor-mode that does what I want and then
hook it into various modes as I see fit. At least I wouldn't
> Apart from that there does not seem to be a big problem. accidentally
> inserting a character is no big deal. You either hit `undo' or
> Backspace. End of problem. Happens all the time for various reasons.
If it was just the 'accident' -- but I really like to be able to use
'q' to quit.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-08 13:44 ` Kim F. Storm
@ 2004-10-08 22:45 ` Luc Teirlinck
0 siblings, 0 replies; 15+ messages in thread
From: Luc Teirlinck @ 2004-10-08 22:45 UTC (permalink / raw)
Cc: emacs-devel
Kim Storm wrote:
Personally I would find it "consistent" if 'q' could be used to quit
out of any buffer that I have just "looked at" and never intended to
change--whether I opened it (or some other command opened it) in
view-mode or not (as is the case for pcl-cvs).
Whether I can 'expect that' is another issue -- for me, the
convenience of being able to do so would IMHO greatly exceed the
rare(?) inconvenience of having to do something special if I
really need to insert a 'q' as the first character in a buffer after
opening it.
Of course, if I also want SPC and DEL to behave like view-mode, things
may get more confusing.
The fact that if I type `q' in a writable buffer then `q' gets
inserted, is consistent with the fact that if I type any other
self-inserting character, it is going to self-insert.
Actually, even in read-only buffers, `q' has no real standard meaning,
although it usually _buries_ the buffer. View mode's treatment of `q'
is somewhat unusual, in that it usually kills the buffer.
`C-x k RET' is not exactly super-inconvenient.
You seem to consider View mode as _the_ standard behavior of Emacs.
If that is how you feel, why do you not enable View mode by default in
all buffers, or at least in all buffers in which you want the
behavior? (In your own Emacs, not in CVS.) You can always press `e'
if you actually want to do some editing. That would seem to be a
_much_ simpler way to achieve what you want to achieve.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-08 13:01 ` Luc Teirlinck
2004-10-08 13:44 ` Kim F. Storm
@ 2004-10-11 22:23 ` Kim F. Storm
2004-10-12 14:28 ` Juri Linkov
2004-10-12 14:40 ` Stefan Monnier
1 sibling, 2 replies; 15+ messages in thread
From: Kim F. Storm @ 2004-10-11 22:23 UTC (permalink / raw)
Cc: emacs-devel
Luc Teirlinck <teirllm@dms.auburn.edu> writes:
> If you want to visit a buffer in View mode,
> just visit it in View mode. Again, I believe that the only problem is
> that there is something in the pcl-cvs interface that you do not like.
Ok, I agree that my proposal is not desireable.
What about the following patch to pcl-cvs that adds a "v" command in cvs-mode
(for cvs-mode-view-file):
Index: lisp/pcvs-defs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/pcvs-defs.el,v
retrieving revision 1.28
diff -u -r1.28 pcvs-defs.el
--- lisp/pcvs-defs.el 11 Oct 2004 14:58:54 -0000 1.28
+++ lisp/pcvs-defs.el 11 Oct 2004 22:15:32 -0000
@@ -374,7 +374,7 @@
("r" . cvs-mode-remove)
("s" . cvs-mode-status)
("t" . cvs-mode-tag)
- ;;("v" . cvs-mode-diff-vendor)
+ ("v" . cvs-mode-view-file)
("x" . cvs-mode-remove-handled)
;; cvstree bindings
("+" . cvs-mode-tree)
Index: lisp/pcvs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/pcvs.el,v
retrieving revision 1.71
diff -u -r1.71 pcvs.el
--- lisp/pcvs.el 2 Jul 2004 04:32:54 -0000 1.71
+++ lisp/pcvs.el 11 Oct 2004 22:21:34 -0000
@@ -1925,6 +1925,18 @@
(cvs-mode-find-file e 'dont-select))
+(defun cvs-mode-view-file (e)
+ "View the file."
+ (interactive (list last-input-event))
+ (cvs-mode-find-file e nil t))
+
+
+(defun cvs-mode-view-file-other-window (e)
+ "View the file."
+ (interactive (list last-input-event))
+ (cvs-mode-find-file e t t))
+
+
(defun cvs-find-modif (fi)
(with-temp-buffer
(call-process cvs-program nil (current-buffer) nil
@@ -1935,7 +1947,7 @@
1)))
-(defun cvs-mode-find-file (e &optional other)
+(defun cvs-mode-find-file (e &optional other view)
"Select a buffer containing the file.
With a prefix, opens the buffer in an OTHER window."
(interactive (list last-input-event current-prefix-arg))
@@ -1968,6 +1980,8 @@
buf)
(when (and cvs-find-file-and-jump (cvs-applicable-p fi 'diff-base))
(goto-line (cvs-find-modif fi)))
+ (when view
+ (view-mode 1))
buf))))))
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-08 8:54 ` Kim F. Storm
2004-10-08 13:01 ` Luc Teirlinck
@ 2004-10-08 13:19 ` Stefan
2004-10-08 13:54 ` Kim F. Storm
1 sibling, 1 reply; 15+ messages in thread
From: Stefan @ 2004-10-08 13:19 UTC (permalink / raw)
Cc: Luc Teirlinck, emacs-devel
> Is there some way to implement a first-user-change-hook ?
I used (null buffer-undo-list) the only time I needed something like that.
But that was in the minibuffer, so I don't how well it'll work in your case,
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-08 13:19 ` Stefan
@ 2004-10-08 13:54 ` Kim F. Storm
0 siblings, 0 replies; 15+ messages in thread
From: Kim F. Storm @ 2004-10-08 13:54 UTC (permalink / raw)
Cc: Luc Teirlinck, emacs-devel
Stefan <monnier@iro.umontreal.ca> writes:
>> Is there some way to implement a first-user-change-hook ?
>
> I used (null buffer-undo-list) the only time I needed something like that.
> But that was in the minibuffer, so I don't how well it'll work in your case,
Nice trick! Thanks.
But does first-change-hook really what we expect if font-lock is on?
Would it make sense to have something like
(let ((inhibit-buffer-modif-change t))
(add-text-properties ...))
that font-lock could use instead of using restore-buffer-modified-p.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Small enhancement for add-log.el
2004-10-07 22:06 Small enhancement for add-log.el Kim F. Storm
2004-10-07 22:21 ` David Kastrup
2004-10-07 23:07 ` Luc Teirlinck
@ 2004-10-09 15:44 ` Richard Stallman
2 siblings, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2004-10-09 15:44 UTC (permalink / raw)
Cc: emacs-devel
When I look through ChangeLog files, I often type `q' to quit --
but instead a q is inserted into the buffer.
What about the following change [I know it's a hack] which kills the
buffer if you type `q' in an unmodified ChangeLog buffer.
This is not acceptable. Since this buffer allows self-insertion, it
is normal to type various printing characters. No printing character
should have any drastic special effect.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2004-10-12 14:40 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-07 22:06 Small enhancement for add-log.el Kim F. Storm
2004-10-07 22:21 ` David Kastrup
2004-10-07 23:00 ` Kim F. Storm
2004-10-08 12:25 ` Kai Grossjohann
2004-10-07 23:07 ` Luc Teirlinck
2004-10-08 8:54 ` Kim F. Storm
2004-10-08 13:01 ` Luc Teirlinck
2004-10-08 13:44 ` Kim F. Storm
2004-10-08 22:45 ` Luc Teirlinck
2004-10-11 22:23 ` Kim F. Storm
2004-10-12 14:28 ` Juri Linkov
2004-10-12 14:40 ` Stefan Monnier
2004-10-08 13:19 ` Stefan
2004-10-08 13:54 ` Kim F. Storm
2004-10-09 15:44 ` Richard Stallman
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.