* Re: hexl: doesn't play nicely with dynamic-completion-mode
[not found] <m2r6tcu25g.fsf@gmail.com>
@ 2007-09-08 14:47 ` Chris Moore
[not found] ` <E1IUCIj-0000B4-Rz@fencepost.gnu.org>
0 siblings, 1 reply; 8+ messages in thread
From: Chris Moore @ 2007-09-08 14:47 UTC (permalink / raw)
To: emacs-pretest-bug
[-- Attachment #1.1: Type: text/plain, Size: 758 bytes --]
On 1/30/07, Chris Moore <dooglus@gmail.com> wrote:
>
> In GNU Emacs 22.0.93.2 (i686-pc-linux-gnu, GTK+ Version 2.8.20)
> of 2007-01-23 on trpaslik
> configured using `configure '--with-gtk' '--prefix' '/usr/local'
> '--with-xpm' '--with-jpeg' '--with-png' '--with-gif''
>
> make a file with some content:
>
> $ date > /tmp/date.txt
>
> start emacs:
>
> $ emacs -Q
>
> enable dynamic completion mode:
>
> M-x dynamic-completion-mode RET
>
> visit the file:
>
> C-x C-f /tmp/date.txt
>
> enable hexl-mode:
>
> M-x hexl-mode RET
>
> type some text containing full stops:
>
> hello.world.
>
> notice that the letters insert themselves properly into the hexl
> buffer, but the full stops corrupt the buffer.
>
This bug is still alive and well in the CVS trunk.
[-- Attachment #1.2: Type: text/html, Size: 1154 bytes --]
[-- Attachment #2: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: hexl: doesn't play nicely with dynamic-completion-mode
[not found] ` <E1IUCIj-0000B4-Rz@fencepost.gnu.org>
@ 2007-09-09 18:01 ` Chris Moore
2007-09-10 1:13 ` Richard Stallman
0 siblings, 1 reply; 8+ messages in thread
From: Chris Moore @ 2007-09-09 18:01 UTC (permalink / raw)
To: rms; +Cc: emacs-pretest-bug
[-- Attachment #1.1: Type: text/plain, Size: 1101 bytes --]
On 9/9/07, Richard Stallman <rms@gnu.org> wrote:
> This is an inelegant way of doing it;
> does it fix your problem?
No, it doesn't. It ends up calling self-insert-command, which inserts the
'.' character, rather than calling hexl-self-insert-command, which inserts
the hex code for the '.' character.
This is an inelegant way of doing it which does work:
*** Backup/completion.el.~1~ Sun Sep 9 19:44:37 2007
--- completion.el Sun Sep 9 19:58:42 2007
***************
*** 2231,2238 ****
(defun completion-separator-self-insert-command (arg)
(interactive "p")
! (use-completion-before-separator)
! (self-insert-command arg))
(defun completion-separator-self-insert-autofilling (arg)
(interactive "p")
--- 2231,2241 ----
(defun completion-separator-self-insert-command (arg)
(interactive "p")
! (message "major is '%s'" major-mode)
! (if (eq major-mode 'hexl-mode)
! (hexl-self-insert-command arg)
! (use-completion-before-separator)
! (self-insert-command arg)))
(defun completion-separator-self-insert-autofilling (arg)
(interactive "p")
[-- Attachment #1.2: Type: text/html, Size: 1830 bytes --]
[-- Attachment #2: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: hexl: doesn't play nicely with dynamic-completion-mode
2007-09-09 18:01 ` Chris Moore
@ 2007-09-10 1:13 ` Richard Stallman
2007-09-10 11:35 ` Chris Moore
0 siblings, 1 reply; 8+ messages in thread
From: Richard Stallman @ 2007-09-10 1:13 UTC (permalink / raw)
To: Chris Moore; +Cc: emacs-pretest-bug
Here's a more elegant and general version of the fix.
Does it work in your test case?
*** completion.el 19 Aug 2007 16:31:48 -0400 1.63
--- completion.el 09 Sep 2007 16:31:50 -0400
***************
*** 2231,2238 ****
(defun completion-separator-self-insert-command (arg)
(interactive "p")
! (use-completion-before-separator)
! (self-insert-command arg))
(defun completion-separator-self-insert-autofilling (arg)
(interactive "p")
--- 2231,2240 ----
(defun completion-separator-self-insert-command (arg)
(interactive "p")
! (if (command-remapping 'self-insert-command)
! (funcall (command-remapping 'self-insert-command) arg)
! (use-completion-before-separator)
! (self-insert-command arg)))
(defun completion-separator-self-insert-autofilling (arg)
(interactive "p")
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: hexl: doesn't play nicely with dynamic-completion-mode
2007-09-10 1:13 ` Richard Stallman
@ 2007-09-10 11:35 ` Chris Moore
2007-09-10 14:14 ` Stefan Monnier
0 siblings, 1 reply; 8+ messages in thread
From: Chris Moore @ 2007-09-10 11:35 UTC (permalink / raw)
To: rms; +Cc: emacs-pretest-bug
On 9/10/07, Richard Stallman <rms@gnu.org> wrote:
> Here's a more elegant and general version of the fix.
> Does it work in your test case?
Yes, but we need to do the same in
completion-separator-self-insert-autofilling as well, or pressing SPC
corrupts the hexl buffer.
---
begin 644 completion-hexl-patch.txt.gz
M'XL("*HKY48``V-O;7!L971I;VXM:&5X;"UP871C:"YT>'0`U5--;X,P##V7
M7^'U,JB:ED"W:E0[3#OML,MZV#D+IHJ4ABA`M9^_))1^J=U:;3W,0D!LOV=C
M/UY4CI\9\'*I)=:B5".4P>/O+7A[GD,A)&8PKLK&<*S&N&2\NTM1Z?%>U>$J
M,%@;@2NA%F#LH[(!H*/[-,A%40#A0(P['G0[&`SV/3TZA:=F`4D<3R&>9BG-
M)A,@L;6>IR.$'")BF*-N$91F:9K1AQ;AZ'?-ETN2E`Z39'('W@5@KS#'HE$[
MO*1"S0RK2V/?9$&$JM#4Q"8LF<HA9&8169Q%"E6C8;P6*X2^[D?!C?,V%9(=
MM@\L2H-;TG76,6K''%W6%6OJTJY+NME?N;,VZD^V*'%5B>V1.RX?\Q8Z%Y/R
M2%+4?=QL1BXSCX%WP[1V'_K*N"F]&KJ%VJ6W:==8J"@@7"<38W^#MHG;(US1
H9@Z;,9R+W([XW$5])Z)KJNC_C:.+G]1N[P?9_JENOP!_@=?0NP4`````
`
end
---
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: hexl: doesn't play nicely with dynamic-completion-mode
2007-09-10 11:35 ` Chris Moore
@ 2007-09-10 14:14 ` Stefan Monnier
2007-09-10 18:43 ` Chris Moore
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2007-09-10 14:14 UTC (permalink / raw)
To: Chris Moore; +Cc: emacs-pretest-bug, rms
>> Here's a more elegant and general version of the fix.
>> Does it work in your test case?
> Yes, but we need to do the same in
> completion-separator-self-insert-autofilling as well, or pressing SPC
> corrupts the hexl buffer.
hexl-mode should probably install a before-change-function that checks that
this-command is among the supported ones. This won't fix those problems,
but will at least catch them before they corrupt the buffer.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: hexl: doesn't play nicely with dynamic-completion-mode
2007-09-10 14:14 ` Stefan Monnier
@ 2007-09-10 18:43 ` Chris Moore
2007-09-10 20:20 ` Stefan Monnier
0 siblings, 1 reply; 8+ messages in thread
From: Chris Moore @ 2007-09-10 18:43 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-pretest-bug, rms
On 9/10/07, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> hexl-mode should probably install a before-change-function that checks that
> this-command is among the supported ones. This won't fix those problems,
> but will at least catch them before they corrupt the buffer.
Is there some way for a before-change-function to prevent a change?
It can call 'error to prevent the change once, but this clears the
before-change-function handler, so the 'bad' key won't be caught a 2nd
time. Also, I notice that 'this-command is
'completion-separator-self-insert-command rather than
'self-insert-command in the hexl-mode before-change-function (after
applying Richard's fix), so hexl-mode would need to know about all the
modes which remap self-insert-command.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: hexl: doesn't play nicely with dynamic-completion-mode
2007-09-10 18:43 ` Chris Moore
@ 2007-09-10 20:20 ` Stefan Monnier
2007-09-13 8:26 ` Johan Bockgård
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2007-09-10 20:20 UTC (permalink / raw)
To: Chris Moore; +Cc: emacs-pretest-bug, rms
>> hexl-mode should probably install a before-change-function that checks that
>> this-command is among the supported ones. This won't fix those problems,
>> but will at least catch them before they corrupt the buffer.
> Is there some way for a before-change-function to prevent a change?
> It can call 'error to prevent the change once, but this clears the
> before-change-function handler, so the 'bad' key won't be caught
> a 2nd time.
Good point. Not only it clears this function but any other
before-change-functions as well, so it's clearly undesirable. Hmm....
Of course, we could use a big ugly hack which saves the
before-change-functions value somewhere before signalling the error and
restores it from post-command-hook or run-with-timer. Yuck!
> Also, I notice that 'this-command is
> 'completion-separator-self-insert-command rather than
> 'self-insert-command in the hexl-mode before-change-function (after
> applying Richard's fix), so hexl-mode would need to know about all the
> modes which remap self-insert-command.
Indeed checking this-command is probably a bad idea. Maybe better check
a `hexl-aware-text-modification' variable which defaults to nil and is bound
to t in functions that know about hexl.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: hexl: doesn't play nicely with dynamic-completion-mode
2007-09-10 20:20 ` Stefan Monnier
@ 2007-09-13 8:26 ` Johan Bockgård
0 siblings, 0 replies; 8+ messages in thread
From: Johan Bockgård @ 2007-09-13 8:26 UTC (permalink / raw)
To: emacs-devel; +Cc: emacs-pretest-bug
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> hexl-mode should probably install a before-change-function that checks that
>>> this-command is among the supported ones. This won't fix those problems,
>>> but will at least catch them before they corrupt the buffer.
>
>> Is there some way for a before-change-function to prevent a change?
>> It can call 'error to prevent the change once, but this clears the
>> before-change-function handler, so the 'bad' key won't be caught
>> a 2nd time.
>
> Good point. Not only it clears this function but any other
> before-change-functions as well, so it's clearly undesirable. Hmm....
pre-command-hook can be used to divert commands on the fly. I don't know
if this solves your problem.
;; Example
(defun foo ()
(when (eq this-command 'self-insert-command)
(setq this-command 'ignore)))
(add-hook 'pre-command-hook 'foo nil t)
--
Johan Bockgård
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-09-13 8:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <m2r6tcu25g.fsf@gmail.com>
2007-09-08 14:47 ` hexl: doesn't play nicely with dynamic-completion-mode Chris Moore
[not found] ` <E1IUCIj-0000B4-Rz@fencepost.gnu.org>
2007-09-09 18:01 ` Chris Moore
2007-09-10 1:13 ` Richard Stallman
2007-09-10 11:35 ` Chris Moore
2007-09-10 14:14 ` Stefan Monnier
2007-09-10 18:43 ` Chris Moore
2007-09-10 20:20 ` Stefan Monnier
2007-09-13 8:26 ` Johan Bockgård
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).