GNU bug report logs -
#11640
24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
Previous Next
Reported by: Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>
Date: Wed, 6 Jun 2012 17:00:03 UTC
Severity: normal
Found in version 24.1.50
Done: Juanma Barranquero <lekktu <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11640 in the body.
You can then email your comments to 11640 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11640
; Package
emacs
.
(Wed, 06 Jun 2012 17:00:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 06 Jun 2012 17:00:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
When I format .texi files on Windows, Emacs fails to make indices.
Emacs calls external sort program to make indices, but Windows's sort
program does not behave as Emacs expected.
To avoid this problem, Emacs22 does not call sort program on Windows.
But this workaround seems to have been dropped when VMS support
have been removed (*1).
(*1) http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/89810
--
Kazuhiro Ito
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11640
; Package
emacs
.
(Thu, 07 Jun 2012 11:08:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 11640 <at> debbugs.gnu.org (full text, mbox):
On Wed, Jun 6, 2012 at 6:56 PM, Kazuhiro Ito <kzhr <at> d1.dion.ne.jp> wrote:
> To avoid this problem, Emacs22 does not call sort program on Windows.
> But this workaround seems to have been dropped when VMS support
> have been removed (*1).
>
> (*1) http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/89810
Does the following patch work for you?
Juanma
=== modified file 'lisp/textmodes/texinfmt.el'
--- lisp/textmodes/texinfmt.el 2012-04-09 13:05:48 +0000
+++ lisp/textmodes/texinfmt.el 2012-06-07 11:02:59 +0000
@@ -2958,6 +2958,29 @@
("ky" . texinfo-format-kindex)))
+;;; Sort and index (for MS-DOS and Windows)
+
+;; Sort an index which is in the current buffer between START and END.
+;; Used on Microsoft OSes, which have a non-POSIX `sort'.
+(defun texinfo-sort-region (start end)
+ (require 'sort)
+ (save-restriction
+ (narrow-to-region start end)
+ (goto-char (point-min))
+ (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun)))
+
+;; Subroutine for sorting an index.
+;; At start of a line, return a string to sort the line under.
+(defun texinfo-sort-startkeyfun ()
+ (let ((line (buffer-substring-no-properties (point) (line-end-position))))
+ ;; Canonicalize whitespace and eliminate funny chars.
+ (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line)
+ (setq line (concat (substring line 0 (match-beginning 0))
+ " "
+ (substring line (match-end 0)))))
+ line))
+
+
;;; @printindex
(put 'printindex 'texinfo-format 'texinfo-format-printindex)
@@ -2974,7 +2997,9 @@
(insert "\n* Menu:\n\n")
(setq opoint (point))
(texinfo-print-index nil indexelts)
- (shell-command-on-region opoint (point) "sort -fd" 1)))
+ (if (memq system-type '(windows-nt ms-dos))
+ (texinfo-sort-region opoint (point))
+ (shell-command-on-region opoint (point) "sort -fd" 1))))
(defun texinfo-print-index (file indexelts)
(while indexelts
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11640
; Package
emacs
.
(Thu, 07 Jun 2012 11:46:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 11640 <at> debbugs.gnu.org (full text, mbox):
Juanma Barranquero <lekktu <at> gmail.com> writes:
> +;; Sort an index which is in the current buffer between START and END.
> +;; Used on Microsoft OSes, which have a non-POSIX `sort'.
Wouldn't it make sense to use it everywhere?
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11640
; Package
emacs
.
(Thu, 07 Jun 2012 11:54:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 11640 <at> debbugs.gnu.org (full text, mbox):
On Thu, Jun 7, 2012 at 1:43 PM, Andreas Schwab <schwab <at> linux-m68k.org> wrote:
> Wouldn't it make sense to use it everywhere?
I don't know. That code was removed in revno:89810, and was only used
for MS-DOS, Windows and VMS. I don't know the rationale for using the
system sort on other OSes. Performance, perhaps?
Juanma
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11640
; Package
emacs
.
(Thu, 07 Jun 2012 16:26:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 11640 <at> debbugs.gnu.org (full text, mbox):
> From: Juanma Barranquero <lekktu <at> gmail.com>
> Date: Thu, 7 Jun 2012 13:49:58 +0200
> Cc: Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>, 11640 <at> debbugs.gnu.org
>
> On Thu, Jun 7, 2012 at 1:43 PM, Andreas Schwab <schwab <at> linux-m68k.org> wrote:
>
> > Wouldn't it make sense to use it everywhere?
>
> I don't know. That code was removed in revno:89810, and was only used
> for MS-DOS, Windows and VMS.
I agree with Andreas: if we have a built-in functionality, using it is
better than relying on an external program.
> I don't know the rationale for using the system sort on other
> OSes. Performance, perhaps?
How about tradition? ;-)
Seriously, I find it hard to believe that performance matters in this
case, especially since texinfmt.el is no longer the main recommended
way of producing Info from Texinfo, which is why it doesn't get
updated with the latest features of the Texinfo language.
Stefan, Chong, any objections to sorting the indices in Lisp in this
case?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11640
; Package
emacs
.
(Thu, 07 Jun 2012 16:27:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 11640 <at> debbugs.gnu.org (full text, mbox):
> From: Juanma Barranquero <lekktu <at> gmail.com>
> Date: Thu, 7 Jun 2012 13:04:48 +0200
> Cc: 11640 <at> debbugs.gnu.org
>
> On Wed, Jun 6, 2012 at 6:56 PM, Kazuhiro Ito <kzhr <at> d1.dion.ne.jp> wrote:
>
> > To avoid this problem, Emacs22 does not call sort program on Windows.
> > But this workaround seems to have been dropped when VMS support
> > have been removed (*1).
> >
> > (*1) http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/89810
>
> Does the following patch work for you?
If you eventually install something like this, please mention in the
log that it was inadvertently removed in revision 89810.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11640
; Package
emacs
.
(Thu, 07 Jun 2012 18:52:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 11640 <at> debbugs.gnu.org (full text, mbox):
On Thu, Jun 7, 2012 at 6:23 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> Seriously, I find it hard to believe that performance matters in this
> case, especially since texinfmt.el is no longer the main recommended
> way of producing Info from Texinfo, which is why it doesn't get
> updated with the latest features of the Texinfo language.
I'm perfectly willing to believe you. As I said, I don't know why was
it done otherwise.
> Stefan, Chong, any objections to sorting the indices in Lisp in this
> case?
The patch is even simpler.
2012-06-07 Juanma Barranquero <lekktu <at> gmail.com>
* textmodes/texinfmt.el: Use internal sort (partial revert of revno:89810).
(texinfo-sort-region, texinfo-sort-startkeyfun): Restore functions.
(texinfo-format-printindex): Use `texinfo-sort-region' instead of
calling external sort utility.
=== modified file 'lisp/textmodes/texinfmt.el'
--- lisp/textmodes/texinfmt.el 2012-04-09 13:05:48 +0000
+++ lisp/textmodes/texinfmt.el 2012-06-07 18:38:56 +0000
@@ -2958,6 +2958,28 @@
("ky" . texinfo-format-kindex)))
+;;; Sort and index
+
+;; Sort an index which is in the current buffer between START and END.
+(defun texinfo-sort-region (start end)
+ (require 'sort)
+ (save-restriction
+ (narrow-to-region start end)
+ (goto-char (point-min))
+ (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun)))
+
+;; Subroutine for sorting an index.
+;; At start of a line, return a string to sort the line under.
+(defun texinfo-sort-startkeyfun ()
+ (let ((line (buffer-substring-no-properties (point) (line-end-position))))
+ ;; Canonicalize whitespace and eliminate funny chars.
+ (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line)
+ (setq line (concat (substring line 0 (match-beginning 0))
+ " "
+ (substring line (match-end 0)))))
+ line))
+
+
;;; @printindex
(put 'printindex 'texinfo-format 'texinfo-format-printindex)
@@ -2974,7 +2996,7 @@
(insert "\n* Menu:\n\n")
(setq opoint (point))
(texinfo-print-index nil indexelts)
- (shell-command-on-region opoint (point) "sort -fd" 1)))
+ (texinfo-sort-region opoint (point))))
(defun texinfo-print-index (file indexelts)
(while indexelts
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11640
; Package
emacs
.
(Fri, 08 Jun 2012 05:49:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 11640 <at> debbugs.gnu.org (full text, mbox):
> Stefan, Chong, any objections to sorting the indices in Lisp in this
> case?
Nope,
Stefan
Reply sent
to
Juanma Barranquero <lekktu <at> gmail.com>
:
You have taken responsibility.
(Fri, 08 Jun 2012 12:29:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>
:
bug acknowledged by developer.
(Fri, 08 Jun 2012 12:29:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 11640-done <at> debbugs.gnu.org (full text, mbox):
On Fri, Jun 8, 2012 at 7:45 AM, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
> Nope,
Committed in revno:108524.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 07 Jul 2012 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 344 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.