unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
Cc: emacs-devel@gnu.org
Subject: Re: [wenbinye@gmail.com: hexl-max-address in hexl-mode is incorrect]
Date: Wed, 22 Nov 2006 11:02:22 -0500	[thread overview]
Message-ID: <87bqmzo4fl.fsf@cyd.mit.edu> (raw)
In-Reply-To: <E1Glhaj-0008Bt-Kt@fencepost.gnu.org> (Richard Stallman's message of "Sun\, 19 Nov 2006 02\:59\:53 -0500")

> The hexl-max-address usually set to buffer-size, but when the buffer
> contain a multiple byte character or the file associated to the buffer
> is  encoded by multibyte coding system such as utf-16, the
> hexl-max-address is  usually less the the real byte of buffer.
>
> You can test like this:
>
> Test case 2:
> Open a new file, such as /tmp/test.txt. Use C-x RET f to set the file
> coding system to utf-16. Input any letters such as "ab", and save the
> buffer. Then change mode to hexl-mode. C-h v hexl-max-address show the
> value is still 2 which is the buffer-size rather than the sizze of the
> file.
>
> Here is my solution to set hexl-max-address which might help:
> (setq hexl-max-address
>       (1- (if buffer-file-name
>               (nth 7 (file-attributes buffer-file-name))
>             (length
>              (decode-coding-string (buffer-string)
> buffer-file-coding-system)))))

The (nth 7 (file-attributes buffer-file-name)) method returns the
correct byte count.  However, the
(decode-coding-string (buffer-string) buffer-file-coding-system)
method doesn't seem to work for me; it returns erratic incorrect
results.  In the case of a utf-16 buffer containing just "ab" without
an associated file, it returns 1; if there is an associated buffer, it
returns 0.

  reply	other threads:[~2006-11-22 16:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-19  7:59 [wenbinye@gmail.com: hexl-max-address in hexl-mode is incorrect] Richard Stallman
2006-11-22 16:02 ` Chong Yidong [this message]
2006-11-22 16:59   ` Chong Yidong
2006-11-22 17:15   ` Kevin Rodgers
2006-11-22 22:02     ` Chong Yidong
2006-11-27 19:09       ` Stuart D. Herring
2006-11-28  0:48         ` Kenichi Handa

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bqmzo4fl.fsf@cyd.mit.edu \
    --to=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    /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 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).