all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* latexenc and `TeX-master'
@ 2006-01-22  8:58 David Reitter
  2006-01-22 14:24 ` Arne Jørgensen
  2006-01-22 14:26 ` Arne Jørgensen
  0 siblings, 2 replies; 8+ messages in thread
From: David Reitter @ 2006-01-22  8:58 UTC (permalink / raw)


When trying to load a .tex files with a (faulty) TeX Master directive,
the behavior of latexenc-find-file-coding-system is slightly flawed,
leading to an "Wrong type argument: arrayp, nil" error later-on.

The TeX master file in the .tex file I have is a directory:

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "~/web"
%%% End:

What happens in `latexenc-find-file-coding-system' is that this
directory is loaded (in dired mode). In this buffer, both
`coding-system-for-write' and `buffer-file-coding-system' are nil so
that `latexenc-find-file-coding-system' returns nil instead of
`undecided.

While it seems like the "TeX-master" statement is clearly wrong, I
think Emacs should tolerate that or give a useful error message rather
than bailing out. The patch below takes care of that.



*** latexenc.el	02 Dec 2005 13:24:11 +0000	1.11
--- latexenc.el	22 Jan 2006 08:52:12 +0000	
***************
*** 156,162 ****
                                          "")
                                    ".tex" ".ltx" ".dtx" ".drv"))
                       (if (and (null latexenc-main-file) ;Stop at  
first.
!                              (file-exists-p (concat file ext)))
                           (setq latexenc-main-file (concat file  
ext)))))))
               ;; try tex-modes tex-guess-main-file
               (when (and (not latexenc-dont-use-tex-guess-main-file- 
flag)
--- 156,163 ----
                                          "")
                                    ".tex" ".ltx" ".dtx" ".drv"))
                       (if (and (null latexenc-main-file) ;Stop at  
first.
!                              (file-exists-p (concat file ext))
! 			     (not (file-directory-p filename)))
                           (setq latexenc-main-file (concat file  
ext)))))))
               ;; try tex-modes tex-guess-main-file
               (when (and (not latexenc-dont-use-tex-guess-main-file- 
flag)
***************
*** 174,180 ****
                           (find-file-noselect latexenc-main-file t)))
                     (coding-system-base   ;Disregard the EOL part of  
the CS.
                      (with-current-buffer latexenc-main-buffer
!                      (or coding-system-for-write buffer-file-coding- 
system))))
                 'undecided))))
       'undecided))

--- 175,183 ----
                           (find-file-noselect latexenc-main-file t)))
                     (coding-system-base   ;Disregard the EOL part of  
the CS.
                      (with-current-buffer latexenc-main-buffer
!                      (or coding-system-for-write
! 			 buffer-file-coding-system
! 			 'undecided))))
                 'undecided))))
       'undecided))

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: latexenc and `TeX-master'
  2006-01-22  8:58 latexenc and `TeX-master' David Reitter
@ 2006-01-22 14:24 ` Arne Jørgensen
  2006-01-22 17:21   ` Arne Jørgensen
  2006-01-22 14:26 ` Arne Jørgensen
  1 sibling, 1 reply; 8+ messages in thread
From: Arne Jørgensen @ 2006-01-22 14:24 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

David Reitter <david.reitter@gmail.com> writes:

> While it seems like the "TeX-master" statement is clearly wrong, I
> think Emacs should tolerate that or give a useful error message rather
> than bailing out. The patch below takes care of that.

I think you have a good point.

But it is probably better to check if the file is a regular and then
also check if it is actually readable.

Patch attached.

Kind regards

     /arne
-- 
Arne Jørgensen <http://arnested.dk/>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: latexenc.patch --]
[-- Type: text/x-patch, Size: 1279 bytes --]

Index: lisp/international/latexenc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/latexenc.el,v
retrieving revision 1.11
diff -u -p -r1.11 latexenc.el
--- lisp/international/latexenc.el	2 Dec 2005 13:24:11 -0000	1.11
+++ lisp/international/latexenc.el	22 Jan 2006 14:22:40 -0000
@@ -1,6 +1,6 @@
 ;;; latexenc.el --- guess correct coding system in LaTeX files
 
-;; Copyright (C) 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Arne J^[,Ax^[(Brgensen <arne@arnested.dk>
 ;; Keywords: mule, coding system, latex
@@ -156,7 +156,8 @@ coding system names is determined from `
                                        "")
                                  ".tex" ".ltx" ".dtx" ".drv"))
                     (if (and (null latexenc-main-file) ;Stop at first.
-                             (file-exists-p (concat file ext)))
+                             (file-regular-p (concat file ext))
+                             (file-readable-p (concat file ext)))
                         (setq latexenc-main-file (concat file ext)))))))
             ;; try tex-modes tex-guess-main-file
             (when (and (not latexenc-dont-use-tex-guess-main-file-flag)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: latexenc and `TeX-master'
  2006-01-22  8:58 latexenc and `TeX-master' David Reitter
  2006-01-22 14:24 ` Arne Jørgensen
@ 2006-01-22 14:26 ` Arne Jørgensen
  1 sibling, 0 replies; 8+ messages in thread
From: Arne Jørgensen @ 2006-01-22 14:26 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

David Reitter <david.reitter@gmail.com> writes:

> While it seems like the "TeX-master" statement is clearly wrong, I
> think Emacs should tolerate that or give a useful error message rather
> than bailing out. The patch below takes care of that.

I think you have a good point.

But it is probably better to check if the file is a regular and then
also check if it is actually readable.

Patch attached.

Kind regards

     /arne
-- 
Arne Jørgensen <http://arnested.dk/>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: latexenc.patch --]
[-- Type: text/x-patch, Size: 1279 bytes --]

Index: lisp/international/latexenc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/latexenc.el,v
retrieving revision 1.11
diff -u -p -r1.11 latexenc.el
--- lisp/international/latexenc.el	2 Dec 2005 13:24:11 -0000	1.11
+++ lisp/international/latexenc.el	22 Jan 2006 14:22:40 -0000
@@ -1,6 +1,6 @@
 ;;; latexenc.el --- guess correct coding system in LaTeX files
 
-;; Copyright (C) 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Arne J^[,Ax^[(Brgensen <arne@arnested.dk>
 ;; Keywords: mule, coding system, latex
@@ -156,7 +156,8 @@ coding system names is determined from `
                                        "")
                                  ".tex" ".ltx" ".dtx" ".drv"))
                     (if (and (null latexenc-main-file) ;Stop at first.
-                             (file-exists-p (concat file ext)))
+                             (file-regular-p (concat file ext))
+                             (file-readable-p (concat file ext)))
                         (setq latexenc-main-file (concat file ext)))))))
             ;; try tex-modes tex-guess-main-file
             (when (and (not latexenc-dont-use-tex-guess-main-file-flag)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: latexenc and `TeX-master'
  2006-01-22 14:24 ` Arne Jørgensen
@ 2006-01-22 17:21   ` Arne Jørgensen
  2006-01-23  9:54     ` David Reitter
  2006-01-23 14:31     ` Reiner Steib
  0 siblings, 2 replies; 8+ messages in thread
From: Arne Jørgensen @ 2006-01-22 17:21 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

Arne Jørgensen <arne@arnested.dk> writes:

> But it is probably better to check if the file is a regular and then
> also check if it is actually readable.

Readability is already checked later in the code. Checking whether the
file is a regular file is also better checked at that point.

New patch is attached.

Kind regards

     /arne
-- 
Arne Jørgensen <http://arnested.dk/>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: latexenc.patch --]
[-- Type: text/x-patch, Size: 1746 bytes --]

Index: lisp/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.9010
diff -u -p -r1.9010 ChangeLog
--- lisp/ChangeLog	22 Jan 2006 16:24:53 -0000	1.9010
+++ lisp/ChangeLog	22 Jan 2006 17:21:10 -0000
@@ -1,3 +1,8 @@
+2006-01-22  Arne J^[,Ax^[(Brgensen  <arne@arnested.dk>
+
+	* international/latexenc.el (latexenc-find-file-coding-system):
+	Only try to read TeX-master if it is a regular file.
+
 2006-01-22  Andre Spiegel  <spiegel@gnu.org>
 
 	* vc-rcs.el (vc-rcs-state-heuristic): Use file-attributes with
Index: lisp/international/latexenc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/latexenc.el,v
retrieving revision 1.11
diff -u -p -r1.11 latexenc.el
--- lisp/international/latexenc.el	2 Dec 2005 13:24:11 -0000	1.11
+++ lisp/international/latexenc.el	22 Jan 2006 17:21:14 -0000
@@ -1,6 +1,6 @@
 ;;; latexenc.el --- guess correct coding system in LaTeX files
 
-;; Copyright (C) 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Arne J^[,Ax^[(Brgensen <arne@arnested.dk>
 ;; Keywords: mule, coding system, latex
@@ -167,6 +167,7 @@ coding system names is determined from `
                   (setq latexenc-main-file (tex-guess-main-file)))))
             ;; if we found a master/main file get the coding system from it
             (if (and latexenc-main-file
+                     (file-regular-p latexenc-main-file)
                      (file-readable-p latexenc-main-file))
                 (let* ((latexenc-dont-use-tex-guess-main-file-flag t)
                        (latexenc-dont-use-TeX-master-flag t)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: latexenc and `TeX-master'
  2006-01-22 17:21   ` Arne Jørgensen
@ 2006-01-23  9:54     ` David Reitter
  2006-01-23 23:04       ` Arne Jørgensen
  2006-01-23 14:31     ` Reiner Steib
  1 sibling, 1 reply; 8+ messages in thread
From: David Reitter @ 2006-01-23  9:54 UTC (permalink / raw)


On 22 Jan 2006, at 17:21, Arne Jørgensen wrote:

> Arne Jørgensen <arne@arnested.dk> writes:
>
>> But it is probably better to check if the file is a regular and then
>> also check if it is actually readable.
>
> Readability is already checked later in the code. Checking whether the
> file is a regular file is also better checked at that point.

yes, I agree. The second change (below) should catch all other cases.


*** latexenc.el	02 Dec 2005 13:24:11 +0000	1.11
--- latexenc.el	22 Jan 2006 08:52:12 +0000	
***************
*** 174,180 ****
                           (find-file-noselect latexenc-main-file t)))
                     (coding-system-base   ;Disregard the EOL part of  
the CS.
                      (with-current-buffer latexenc-main-buffer
!                      (or coding-system-for-write buffer-file-coding- 
system))))
                 'undecided))))
       'undecided))

--- 175,183 ----
                           (find-file-noselect latexenc-main-file t)))
                     (coding-system-base   ;Disregard the EOL part of  
the CS.
                      (with-current-buffer latexenc-main-buffer
!                      (or coding-system-for-write
! 			 buffer-file-coding-system
! 			 'undecided))))
                 'undecided))))
       'undecided))

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: latexenc and `TeX-master'
  2006-01-22 17:21   ` Arne Jørgensen
  2006-01-23  9:54     ` David Reitter
@ 2006-01-23 14:31     ` Reiner Steib
  2006-01-23 14:53       ` Arne Jørgensen
  1 sibling, 1 reply; 8+ messages in thread
From: Reiner Steib @ 2006-01-23 14:31 UTC (permalink / raw)
  Cc: emacs-devel

On Sun, Jan 22 2006, Arne Jørgensen wrote:

> Arne Jørgensen <arne@arnested.dk> writes:
[...]
> New patch is attached.

Installed.

+	* international/latexenc.el (latexenc-find-file-coding-system):
+	Only try to read TeX-master if it is a regular file.

Ups, I didn't notice that you wrote a ChangeLog entry.

	* international/latexenc.el (latexenc-find-file-coding-system):
	Add file-regular-p check.

If you prefer your entry, I'll change it.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: latexenc and `TeX-master'
  2006-01-23 14:31     ` Reiner Steib
@ 2006-01-23 14:53       ` Arne Jørgensen
  0 siblings, 0 replies; 8+ messages in thread
From: Arne Jørgensen @ 2006-01-23 14:53 UTC (permalink / raw)


Reiner Steib <reinersteib+gmane@imap.cc> skriver:

> On Sun, Jan 22 2006, Arne Jørgensen wrote:
>
>> Arne Jørgensen <arne@arnested.dk> writes:
> [...]
>> New patch is attached.
>
> Installed.

Thanks, Reiner.

> +	* international/latexenc.el (latexenc-find-file-coding-system):
> +	Only try to read TeX-master if it is a regular file.
>
> Ups, I didn't notice that you wrote a ChangeLog entry.
>
> 	* international/latexenc.el (latexenc-find-file-coding-system):
> 	Add file-regular-p check.
>
> If you prefer your entry, I'll change it.

Yours is just as good as mine. No need to change it.

Kind regards,
-- 
Arne Jørgensen <http://arnested.dk/>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: latexenc and `TeX-master'
  2006-01-23  9:54     ` David Reitter
@ 2006-01-23 23:04       ` Arne Jørgensen
  0 siblings, 0 replies; 8+ messages in thread
From: Arne Jørgensen @ 2006-01-23 23:04 UTC (permalink / raw)


David Reitter <david.reitter@gmail.com> writes:

> On 22 Jan 2006, at 17:21, Arne Jørgensen wrote:
>
>> Arne Jørgensen <arne@arnested.dk> writes:
>>
>>> But it is probably better to check if the file is a regular and then
>>> also check if it is actually readable.
>>
>> Readability is already checked later in the code. Checking whether the
>> file is a regular file is also better checked at that point.
>
> yes, I agree. The second change (below) should catch all other cases.
>
>
> *** latexenc.el	02 Dec 2005 13:24:11 +0000	1.11
> --- latexenc.el	22 Jan 2006 08:52:12 +0000	
> ***************
> *** 174,180 ****
>                           (find-file-noselect latexenc-main-file t)))
>                     (coding-system-base   ;Disregard the EOL part of
> the CS.
>                      (with-current-buffer latexenc-main-buffer
> !                      (or coding-system-for-write buffer-file-coding- 
> system))))
>                 'undecided))))
>       'undecided))
>
> --- 175,183 ----
>                           (find-file-noselect latexenc-main-file t)))
>                     (coding-system-base   ;Disregard the EOL part of
> the CS.
>                      (with-current-buffer latexenc-main-buffer
> !                      (or coding-system-for-write
> ! 			 buffer-file-coding-system
> ! 			 'undecided))))
>                 'undecided))))
>       'undecided))

On a first read I just thought this fix was a reindentation of the
code, but now that I've read it more carefully I think it should be
applied :-)

Kind regards

     /arne
-- 
Arne Jørgensen <http://arnested.dk/>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-01-23 23:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-22  8:58 latexenc and `TeX-master' David Reitter
2006-01-22 14:24 ` Arne Jørgensen
2006-01-22 17:21   ` Arne Jørgensen
2006-01-23  9:54     ` David Reitter
2006-01-23 23:04       ` Arne Jørgensen
2006-01-23 14:31     ` Reiner Steib
2006-01-23 14:53       ` Arne Jørgensen
2006-01-22 14:26 ` Arne Jørgensen

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.