From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: .eps in image mode Date: Sun, 24 Dec 2006 12:09:36 -0500 Message-ID: References: <87irg45jh6.fsf@chunyu.hit.edu.cn> Reply-To: rms@gnu.org NNTP-Posting-Host: dough.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: sea.gmane.org 1166980343 9359 80.91.229.10 (24 Dec 2006 17:12:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 24 Dec 2006 17:12:23 +0000 (UTC) Cc: chunyu@hit.edu.cn, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 24 18:12:22 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GyWtY-0005L5-Jy for ged-emacs-devel@m.gmane.org; Sun, 24 Dec 2006 18:12:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GyWtY-0007HX-07 for ged-emacs-devel@m.gmane.org; Sun, 24 Dec 2006 12:12:20 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GyWr4-0003zh-MJ for emacs-devel@gnu.org; Sun, 24 Dec 2006 12:09:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GyWr3-0003yT-Rr for emacs-devel@gnu.org; Sun, 24 Dec 2006 12:09:46 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GyWr3-0003yG-NN for emacs-devel@gnu.org; Sun, 24 Dec 2006 12:09:45 -0500 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GyWr2-0006cB-Hz for emacs-devel@gnu.org; Sun, 24 Dec 2006 12:09:45 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1GyWqu-0002WO-9W; Sun, 24 Dec 2006 12:09:36 -0500 Original-To: "Juanma Barranquero" In-reply-to: (lekktu@gmail.com) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:64210 Archived-At: 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