* bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
@ 2012-06-06 16:56 Kazuhiro Ito
2012-06-07 11:04 ` Juanma Barranquero
0 siblings, 1 reply; 9+ messages in thread
From: Kazuhiro Ito @ 2012-06-06 16:56 UTC (permalink / raw)
To: 11640
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
2012-06-06 16:56 bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort Kazuhiro Ito
@ 2012-06-07 11:04 ` Juanma Barranquero
2012-06-07 11:43 ` Andreas Schwab
2012-06-07 16:24 ` Eli Zaretskii
0 siblings, 2 replies; 9+ messages in thread
From: Juanma Barranquero @ 2012-06-07 11:04 UTC (permalink / raw)
To: Kazuhiro Ito; +Cc: 11640
On Wed, Jun 6, 2012 at 6:56 PM, Kazuhiro Ito <kzhr@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)))
\f
+;;; 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))
+
+\f
;;; @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
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
2012-06-07 11:04 ` Juanma Barranquero
@ 2012-06-07 11:43 ` Andreas Schwab
2012-06-07 11:49 ` Juanma Barranquero
2012-06-07 16:24 ` Eli Zaretskii
1 sibling, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2012-06-07 11:43 UTC (permalink / raw)
To: Juanma Barranquero; +Cc: Kazuhiro Ito, 11640
Juanma Barranquero <lekktu@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@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
2012-06-07 11:43 ` Andreas Schwab
@ 2012-06-07 11:49 ` Juanma Barranquero
2012-06-07 16:23 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Juanma Barranquero @ 2012-06-07 11:49 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Kazuhiro Ito, 11640
On Thu, Jun 7, 2012 at 1:43 PM, Andreas Schwab <schwab@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
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
2012-06-07 11:49 ` Juanma Barranquero
@ 2012-06-07 16:23 ` Eli Zaretskii
2012-06-07 18:47 ` Juanma Barranquero
2012-06-08 5:45 ` Stefan Monnier
0 siblings, 2 replies; 9+ messages in thread
From: Eli Zaretskii @ 2012-06-07 16:23 UTC (permalink / raw)
To: Juanma Barranquero, Stefan Monnier, Chong Yidong; +Cc: kzhr, 11640, schwab
> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Thu, 7 Jun 2012 13:49:58 +0200
> Cc: Kazuhiro Ito <kzhr@d1.dion.ne.jp>, 11640@debbugs.gnu.org
>
> On Thu, Jun 7, 2012 at 1:43 PM, Andreas Schwab <schwab@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?
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
2012-06-07 11:04 ` Juanma Barranquero
2012-06-07 11:43 ` Andreas Schwab
@ 2012-06-07 16:24 ` Eli Zaretskii
1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2012-06-07 16:24 UTC (permalink / raw)
To: Juanma Barranquero; +Cc: kzhr, 11640
> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Thu, 7 Jun 2012 13:04:48 +0200
> Cc: 11640@debbugs.gnu.org
>
> On Wed, Jun 6, 2012 at 6:56 PM, Kazuhiro Ito <kzhr@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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
2012-06-07 16:23 ` Eli Zaretskii
@ 2012-06-07 18:47 ` Juanma Barranquero
2012-06-08 5:45 ` Stefan Monnier
1 sibling, 0 replies; 9+ messages in thread
From: Juanma Barranquero @ 2012-06-07 18:47 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 11640, kzhr, schwab, Chong Yidong
On Thu, Jun 7, 2012 at 6:23 PM, Eli Zaretskii <eliz@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@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)))
\f
+;;; 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))
+
+\f
;;; @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
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
2012-06-07 16:23 ` Eli Zaretskii
2012-06-07 18:47 ` Juanma Barranquero
@ 2012-06-08 5:45 ` Stefan Monnier
2012-06-08 12:25 ` Juanma Barranquero
1 sibling, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2012-06-08 5:45 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Juanma Barranquero, kzhr, 11640, schwab, Chong Yidong
> Stefan, Chong, any objections to sorting the indices in Lisp in this
> case?
Nope,
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
2012-06-08 5:45 ` Stefan Monnier
@ 2012-06-08 12:25 ` Juanma Barranquero
0 siblings, 0 replies; 9+ messages in thread
From: Juanma Barranquero @ 2012-06-08 12:25 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 11640-done
On Fri, Jun 8, 2012 at 7:45 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Nope,
Committed in revno:108524.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-06-08 12:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-06 16:56 bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort Kazuhiro Ito
2012-06-07 11:04 ` Juanma Barranquero
2012-06-07 11:43 ` Andreas Schwab
2012-06-07 11:49 ` Juanma Barranquero
2012-06-07 16:23 ` Eli Zaretskii
2012-06-07 18:47 ` Juanma Barranquero
2012-06-08 5:45 ` Stefan Monnier
2012-06-08 12:25 ` Juanma Barranquero
2012-06-07 16:24 ` Eli Zaretskii
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).