* Re: .eps in image mode
[not found] <87irg45jh6.fsf@chunyu.hit.edu.cn>
@ 2006-12-23 20:14 ` Richard Stallman
2006-12-23 22:52 ` Juanma Barranquero
0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2006-12-23 20:14 UTC (permalink / raw)
Cc: emacs-devel
C-x C-f a.eps open it again, then a.eps is in Image mode.
We put something in magic-mode-alist that specifies Image mode for all
postscript files. Maybe that is wrong.
Which Postscript files should go into Image mode by default?
None?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: .eps in image mode
2006-12-23 20:14 ` .eps in image mode Richard Stallman
@ 2006-12-23 22:52 ` Juanma Barranquero
2006-12-24 17:09 ` Richard Stallman
0 siblings, 1 reply; 5+ messages in thread
From: Juanma Barranquero @ 2006-12-23 22:52 UTC (permalink / raw)
Cc: Chunyu Wang, emacs-devel
On 12/23/06, Richard Stallman <rms@gnu.org> wrote:
> We put something in magic-mode-alist that specifies Image mode for all
> postscript files. Maybe that is wrong.
Certainly it is very permissive:
("\\`[\t\n\r ]*%!PS" . postscript)
> Which Postscript files should go into Image mode by default?
> None?
auto-mode-alist (which would've been the one detecting .ps files until
now) contains this:
("\\.[eE]?[pP][sS]\\'" . ps-mode)
and `image-file-name-extensions' does not contain `.ps'. So probably
we shouldn't try to identify .ps files as images by default.
/L/e/k/t/u
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: .eps in image mode
2006-12-23 22:52 ` Juanma Barranquero
@ 2006-12-24 17:09 ` Richard Stallman
2006-12-25 3:15 ` Juanma Barranquero
0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2006-12-24 17:09 UTC (permalink / raw)
Cc: chunyu, emacs-devel
and `image-file-name-extensions' does not contain `.ps'. So probably
we shouldn't try to identify .ps files as images by default.
Does this patch give the right results?
*** image.el 19 Dec 2006 11:57:52 -0500 1.64
--- image.el 23 Dec 2006 21:04:58 -0500
***************
*** 34,53 ****
(defconst image-type-header-regexps
! '(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm)
! ("\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+" . pbm)
! ("\\`GIF8" . gif)
! ("\\`\x89PNG\r\n\x1a\n" . png)
! ("\\`[\t\n\r ]*#define" . xbm)
! ("\\`\\(?:MM\0\\*\\|II\\*\0\\)" . tiff)
! ("\\`[\t\n\r ]*%!PS" . postscript)
! ("\\`\xff\xd8" . (image-jpeg-p . jpeg)))
! "Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types.
When the first bytes of an image file match REGEXP, it is assumed to
! be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol,
! IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called
! with one argument, a string containing the image data. If PREDICATE returns
! a non-nil value, TYPE is the image's type.")
(defconst image-type-file-name-regexps
'(("\\.png\\'" . png)
--- 34,60 ----
(defconst image-type-header-regexps
! '(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" xpm)
! ("\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+" pbm)
! ("\\`GIF8" gif)
! ("\\`\x89PNG\r\n\x1a\n" png)
! ("\\`[\t\n\r ]*#define" xbm)
! ("\\`\\(?:MM\0\\*\\|II\\*\0\\)" tiff)
! ("\\`[\t\n\r ]*%!PS" postscript t)
! ("\\`\xff\xd8" (image-jpeg-p . jpeg)))
! "Alist of (REGEXP IMAGE-TYPE) pairs used to auto-detect image types.
When the first bytes of an image file match REGEXP, it is assumed to
! be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol.
!
! An element can also be (REGEXP IMAGE-TYPE NOT-ALWAYS). If
! NOT-ALWAYS is non-nil, that means that REGEXP identifies a
! file that _can_ be treated as an image of type IMAGE-TYPE,
! but such files should not be spontaneously treated as images.
!
! IMAGE-TYPE can be a pair (PREDICATE . TYPE) instead of a
! symbol. Then PREDICATE is called with one argument, a
! string containing the image data. If PREDICATE returns a
! non-nil value, TYPE is the image's type.")
(defconst image-type-file-name-regexps
'(("\\.png\\'" . png)
***************
*** 205,211 ****
type)
(while types
(let ((regexp (car (car types)))
! (image-type (cdr (car types))))
(if (or (and (symbolp image-type)
(string-match regexp data))
(and (consp image-type)
--- 212,218 ----
type)
(while types
(let ((regexp (car (car types)))
! (image-type (nth 1 (car types))))
(if (or (and (symbolp image-type)
(string-match regexp data))
(and (consp image-type)
***************
*** 218,234 ****
;;;###autoload
! (defun image-type-from-buffer ()
"Determine the image type from data in the current buffer.
! Value is a symbol specifying the image type or nil if type cannot
! be determined."
(let ((types image-type-header-regexps)
type
(opoint (point)))
(goto-char (point-min))
(while types
(let ((regexp (car (car types)))
! (image-type (cdr (car types)))
data)
(if (or (and (symbolp image-type)
(looking-at regexp))
--- 225,246 ----
;;;###autoload
! (defun image-type-from-buffer (&optional include-maybes)
"Determine the image type from data in the current buffer.
! Value is a symbol specifying the image type, or nil if none
! corresponds to the buffer contents.
!
! If INCLUDE-MAYBES is nil (the default), we return nil for
! file types that should not always be treated as images
! even though they can be so treated."
(let ((types image-type-header-regexps)
type
(opoint (point)))
(goto-char (point-min))
(while types
(let ((regexp (car (car types)))
! (image-type (nth 1 (car types)))
! (not-always (nth 2 (car types)))
data)
(if (or (and (symbolp image-type)
(looking-at regexp))
***************
*** 241,247 ****
(min (point-max)
(+ (point-min) 256))))))
(setq image-type (cdr image-type))))
! (setq type image-type
types nil)
(setq types (cdr types)))))
(goto-char opoint)
--- 253,259 ----
(min (point-max)
(+ (point-min) 256))))))
(setq image-type (cdr image-type))))
! (setq type (unless not-always image-type)
types nil)
(setq types (cdr types)))))
(goto-char opoint)
***************
*** 261,267 ****
(with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally file nil 0 256)
! (image-type-from-buffer))))
;;;###autoload
--- 273,279 ----
(with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally file nil 0 256)
! (image-type-from-buffer t))))
;;;###autoload
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: .eps in image mode
2006-12-24 17:09 ` Richard Stallman
@ 2006-12-25 3:15 ` Juanma Barranquero
2006-12-26 2:25 ` Richard Stallman
0 siblings, 1 reply; 5+ messages in thread
From: Juanma Barranquero @ 2006-12-25 3:15 UTC (permalink / raw)
Cc: chunyu, emacs-devel
On 12/24/06, Richard Stallman <rms@gnu.org> wrote:
> Does this patch give the right results?
> *** image.el 19 Dec 2006 11:57:52 -0500 1.64
> --- image.el 23 Dec 2006 21:04:58 -0500
It certainly works for `magic-mode-alist', i.e., it forces PostScript
files not to be automatically detected as images.
As for this part, INCLUDE-MAYBES is declared as a new argument, but it
is not referenced outside of the docstring, so
`image-type-from-file-header' still returns nil for PostScript files:
> --- 225,246 ----
>
>
> ;;;###autoload
> ! (defun image-type-from-buffer (&optional include-maybes)
> "Determine the image type from data in the current buffer.
> ! Value is a symbol specifying the image type, or nil if none
> ! corresponds to the buffer contents.
> !
> ! If INCLUDE-MAYBES is nil (the default), we return nil for
> ! file types that should not always be treated as images
> ! even though they can be so treated."
> (let ((types image-type-header-regexps)
> type
> (opoint (point)))
> (goto-char (point-min))
> (while types
> (let ((regexp (car (car types)))
> ! (image-type (nth 1 (car types)))
> ! (not-always (nth 2 (car types)))
> data)
> (if (or (and (symbolp image-type)
> (looking-at regexp))
/L/e/k/t/u
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: .eps in image mode
2006-12-25 3:15 ` Juanma Barranquero
@ 2006-12-26 2:25 ` Richard Stallman
0 siblings, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2006-12-26 2:25 UTC (permalink / raw)
Cc: chunyu, emacs-devel
Does this replacement patch fix the remaining problem?
*** image.el 19 Dec 2006 11:57:52 -0500 1.64
--- image.el 25 Dec 2006 12:26:35 -0500
***************
*** 34,53 ****
(defconst image-type-header-regexps
! '(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm)
! ("\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+" . pbm)
! ("\\`GIF8" . gif)
! ("\\`\x89PNG\r\n\x1a\n" . png)
! ("\\`[\t\n\r ]*#define" . xbm)
! ("\\`\\(?:MM\0\\*\\|II\\*\0\\)" . tiff)
! ("\\`[\t\n\r ]*%!PS" . postscript)
! ("\\`\xff\xd8" . (image-jpeg-p . jpeg)))
! "Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types.
When the first bytes of an image file match REGEXP, it is assumed to
! be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol,
! IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called
! with one argument, a string containing the image data. If PREDICATE returns
! a non-nil value, TYPE is the image's type.")
(defconst image-type-file-name-regexps
'(("\\.png\\'" . png)
--- 34,60 ----
(defconst image-type-header-regexps
! '(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" xpm)
! ("\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+" pbm)
! ("\\`GIF8" gif)
! ("\\`\x89PNG\r\n\x1a\n" png)
! ("\\`[\t\n\r ]*#define" xbm)
! ("\\`\\(?:MM\0\\*\\|II\\*\0\\)" tiff)
! ("\\`[\t\n\r ]*%!PS" postscript t)
! ("\\`\xff\xd8" (image-jpeg-p . jpeg)))
! "Alist of (REGEXP IMAGE-TYPE) pairs used to auto-detect image types.
When the first bytes of an image file match REGEXP, it is assumed to
! be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol.
!
! An element can also be (REGEXP IMAGE-TYPE NOT-ALWAYS). If
! NOT-ALWAYS is non-nil, that means that REGEXP identifies a
! file that _can_ be treated as an image of type IMAGE-TYPE,
! but such files should not be spontaneously treated as images.
!
! IMAGE-TYPE can be a pair (PREDICATE . TYPE) instead of a
! symbol. Then PREDICATE is called with one argument, a
! string containing the image data. If PREDICATE returns a
! non-nil value, TYPE is the image's type.")
(defconst image-type-file-name-regexps
'(("\\.png\\'" . png)
***************
*** 205,211 ****
type)
(while types
(let ((regexp (car (car types)))
! (image-type (cdr (car types))))
(if (or (and (symbolp image-type)
(string-match regexp data))
(and (consp image-type)
--- 212,218 ----
type)
(while types
(let ((regexp (car (car types)))
! (image-type (nth 1 (car types))))
(if (or (and (symbolp image-type)
(string-match regexp data))
(and (consp image-type)
***************
*** 218,234 ****
;;;###autoload
! (defun image-type-from-buffer ()
"Determine the image type from data in the current buffer.
! Value is a symbol specifying the image type or nil if type cannot
! be determined."
(let ((types image-type-header-regexps)
type
(opoint (point)))
(goto-char (point-min))
(while types
(let ((regexp (car (car types)))
! (image-type (cdr (car types)))
data)
(if (or (and (symbolp image-type)
(looking-at regexp))
--- 225,246 ----
;;;###autoload
! (defun image-type-from-buffer (&optional include-maybes)
"Determine the image type from data in the current buffer.
! Value is a symbol specifying the image type, or nil if none
! corresponds to the buffer contents.
!
! If INCLUDE-MAYBES is nil (the default), we return nil for
! file types that should not always be treated as images
! even though they can be so treated."
(let ((types image-type-header-regexps)
type
(opoint (point)))
(goto-char (point-min))
(while types
(let ((regexp (car (car types)))
! (image-type (nth 1 (car types)))
! (not-always (nth 2 (car types)))
data)
(if (or (and (symbolp image-type)
(looking-at regexp))
***************
*** 241,247 ****
(min (point-max)
(+ (point-min) 256))))))
(setq image-type (cdr image-type))))
! (setq type image-type
types nil)
(setq types (cdr types)))))
(goto-char opoint)
--- 253,260 ----
(min (point-max)
(+ (point-min) 256))))))
(setq image-type (cdr image-type))))
! (setq type (if (or include-maybes (not not-always))
! image-type)
types nil)
(setq types (cdr types)))))
(goto-char opoint)
***************
*** 261,267 ****
(with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally file nil 0 256)
! (image-type-from-buffer))))
;;;###autoload
--- 274,280 ----
(with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally file nil 0 256)
! (image-type-from-buffer t))))
;;;###autoload
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-12-26 2:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <87irg45jh6.fsf@chunyu.hit.edu.cn>
2006-12-23 20:14 ` .eps in image mode Richard Stallman
2006-12-23 22:52 ` Juanma Barranquero
2006-12-24 17:09 ` Richard Stallman
2006-12-25 3:15 ` Juanma Barranquero
2006-12-26 2:25 ` Richard Stallman
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.