From: Teddy Hogeborn <teddy@recompile.se>
To: 20704@debbugs.gnu.org
Subject: bug#20704: info.el bug fix; Interprets Info format wrongly
Date: Sun, 31 May 2015 16:54:05 +0200 [thread overview]
Message-ID: <87d21gpzle.fsf@tower.recompile.se> (raw)
[-- Attachment #1: Type: text/plain, Size: 2657 bytes --]
The Info file format (see (texinfo)Info Format Tag Table.) is
documented as having the reference position in bytes. However, the
info.el functions "Info-find-in-tag-table-1", "Info-read-subfile", and
"Info-search" reads the byte value and adds it to (point-min), which is
a character position, not a byte position. This causes the Emacs Info
reader to jump to the wrong position in Info files with a lot of
non-ascii characters. Solution: Convert the read value to position
using byte-to-position:
diff --git a/lisp/info.el b/lisp/info.el
index 80428e7..b179510 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1020,7 +1020,8 @@ which the match was found."
(beginning-of-line)
(when (re-search-forward regexp nil t)
(list (string-equal "Ref:" (match-string 1))
- (+ (point-min) (read (current-buffer)))
+ (+ (point-min) (byte-to-position
+ (read (current-buffer))))
major-mode)))))
(defun Info-find-in-tag-table (marker regexp &optional strict-case)
@@ -1523,7 +1524,9 @@ is non-nil)."
thisfilepos thisfilename)
(search-forward ": ")
(setq thisfilename (buffer-substring beg (- (point) 2)))
- (setq thisfilepos (+ (point-min) (read (current-buffer))))
+ (setq thisfilepos (+ (point-min)
+ (byte-to-position
+ (read (current-buffer)))))
;; read in version 19 stops at the end of number.
;; Advance to the next line.
(forward-line 1)
@@ -2013,9 +2016,11 @@ If DIRECTION is `backward', search in the reverse direction."
(re-search-backward "\\(^.*\\): [0-9]+$")
(re-search-forward "\\(^.*\\): [0-9]+$"))
(goto-char (+ (match-end 1) 2))
- (setq list (cons (cons (+ (point-min)
- (read (current-buffer)))
- (match-string-no-properties 1))
+ (setq list (cons (cons
+ (+ (point-min)
+ (byte-to-position
+ (read (current-buffer))))
+ (match-string-no-properties 1))
list))
(goto-char (if backward
(1- (match-beginning 0))
Suggested ChangeLog:
----
Convert reference byte positions from Info file to character position.
* lisp/info.el (Info-find-in-tag-table-1, Info-read-subfile)
(Info-search): Convert position read from Info file from bytes to
character position. Patch by Teddy Hogeborn <teddy@recompile.se>.
----
/Teddy Hogeborn
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
next reply other threads:[~2015-05-31 14:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-31 14:54 Teddy Hogeborn [this message]
2015-06-01 14:01 ` bug#20704: info.el bug fix; Interprets Info format wrongly Stefan Monnier
2015-06-01 15:12 ` Eli Zaretskii
2015-06-09 11:09 ` Teddy Hogeborn
2015-06-09 14:29 ` Eli Zaretskii
2015-06-09 16:01 ` Stefan Monnier
2015-06-10 17:50 ` Stefan Monnier
2015-06-10 18:21 ` Eli Zaretskii
2015-06-11 3:02 ` Stefan Monnier
2015-06-11 13:11 ` Eli Zaretskii
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d21gpzle.fsf@tower.recompile.se \
--to=teddy@recompile.se \
--cc=20704@debbugs.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 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.