[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: address@hidden: hexl-max-address in hexl-mode is incorrect]
From: |
Ye Wenbin |
Subject: |
Re: address@hidden: hexl-max-address in hexl-mode is incorrect] |
Date: |
Fri, 24 Nov 2006 09:19:08 +0800 |
User-agent: |
Opera Mail/9.01 (Linux) |
Your solution to set max address is very good. As you have mentioned, the
original-point can not be calculated. And the same preblem also exists when
exit hexl-mode. The orignal-point can be set use encode-coding-string.
but the orignal-point used in hexl-exit seem need to encode the whole
buffer
and substring the buffer-string, then decode back. The following is my
patch.
And the hexl-current-address may in the middle of a multibyte character,
and
this will lead the point shift 1-2. Is there a better way?
You used a function unibyte-string-p which is not defined in my emacs. Is
it
a function defined by yourself or an obsoleted function?
By the way, the hexl-mode set eldoc-document-function but don't save the
original value. And when exit hexl-mode, the eldoc mode still on. I think
it
is also a bug.
--- /home/ywb/proj/lisp/hexl.el 2006-10-30 14:47:26.000000000 +0800
+++ /home/ywb/proj/lisp/hexlm.el 2006-11-24 09:10:11.000000000 +0800
@@ -371,17 +371,18 @@
(if (or (eq arg 1) (not arg))
(let ((modified (buffer-modified-p))
(inhibit-read-only t)
- (original-point (1+ (hexl-current-address))))
+ (original-point (1+ (hexl-current-address)))
+ buf (current-buffer))
(dehexlify-buffer)
(remove-hook 'write-contents-functions 'hexl-save-buffer t)
(restore-buffer-modified-p modified)
- (goto-char original-point)
- ;; Maybe adjust point for the removed CR characters.
- (when (eq (coding-system-eol-type buffer-file-coding-system) 1)
- (setq original-point (- original-point
- (count-lines (point-min) (point))))
- (or (bobp) (setq original-point (1+ original-point))))
- (goto-char original-point)))
+ (goto-char
+ (with-temp-buffer
+ (insert-buffer-substring buf)
+ (encode-coding-region (point-min) (point-max)
+ buffer-file-coding-system)
+ (decode-coding-region (point-min) original-point
+ buffer-file-coding-system)))))
(remove-hook 'after-revert-hook 'hexl-after-revert-hook t)
(remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t)
On Fri, 24 Nov 2006 01:11:51 +0800, Stefan Monnier
<address@hidden> wrote:
This removes a special case which seems unused but not uninteresting.
More specifically it hints at a better solution to our problem.
See patch below.
Note that it doesn't address the similar problem with `original-point'.
This one may require the use of encode-coding-string.
Also it seems that hexl-mode doesn't like to be called in an empty buffer
and my patch doesn't fix that part.
Stefan
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/