emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Image mode


From: Juanma Barranquero
Subject: Re: Image mode
Date: Mon, 5 Feb 2007 20:06:46 +0100

On 2/5/07, Jason Rumney <address@hidden> wrote:

I think we should take a step back and design this properly rather than
introducing more patches.

YES!

At this moment, any patch related to image support is suspicious
unless it *removes* things. In fact, I strongly suggest installing the
following patch (+ ChangeLogs) and starting anew, not committing a
single image-related thing unless we've reached some kind of
agreement.

                   /L/e/k/t/u



Index: lisp/files.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
retrieving revision 1.882
diff -u -2 -r1.882 files.el
--- lisp/files.el       31 Jan 2007 12:37:29 -0000      1.882
+++ lisp/files.el       5 Feb 2007 18:58:22 -0000
@@ -2128,6 +2128,5 @@

(defvar magic-mode-alist
-  `((image-type-auto-detected-p . image-mode-maybe)
-    ;; The < comes before the groups (but the first) to reduce backtracking.
+  `(;; The < comes before the groups (but the first) to reduce backtracking.
    ;; TODO: UTF-16 <?xml may be preceded by a BOM 0xff 0xfe or 0xfe 0xff.
    ;; We use [ \t\n] instead of `\\s ' to make regex overflow less likely.
Index: lisp/image.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/image.el,v
retrieving revision 1.69
diff -u -2 -r1.69 image.el
--- lisp/image.el       28 Jan 2007 07:09:44 -0000      1.69
+++ lisp/image.el       5 Feb 2007 18:55:10 -0000
@@ -66,22 +66,4 @@
be of image type IMAGE-TYPE.")

-(defvar image-type-auto-detectable
-  '((pbm . t)
-    (xbm . t)
-    (bmp . maybe)
-    (gif . maybe)
-    (png . maybe)
-    (xpm . maybe)
-    (jpeg . maybe)
-    (tiff . maybe)
-    (postscript . nil))
-  "Alist of (IMAGE-TYPE . AUTODETECT) pairs used to auto-detect image files.
-\(See `image-type-auto-detected-p').
-
-AUTODETECT can be
- - t      always auto-detect.
- - nil    never auto-detect.
- - maybe  auto-detect only if the image type is available
-           (see `image-type-available-p').")

(defvar image-load-path nil
@@ -329,5 +311,4 @@
  type)

-
;;;###autoload
(defun image-type-available-p (type)
@@ -339,18 +320,4 @@

;;;###autoload
-(defun image-type-auto-detected-p ()
-  "Return t iff the current buffer contains an auto-detectable image.
-Whether image types are auto-detectable or not depends on the setting
-of the variable `image-type-auto-detectable'.
-
-This function is intended to be used from `magic-mode-alist' (which see)."
-  (let* ((type (image-type-from-buffer))
-        (auto (and type (cdr (assq type image-type-auto-detectable)))))
-    (and auto
-        (or (eq auto t)
-            (image-type-available-p type)))))
-
-
-;;;###autoload
(defun create-image (file-or-data &optional type data-p &rest props)
  "Create an image.
Index: lisp/image-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/image-mode.el,v
retrieving revision 1.20
diff -u -2 -r1.20 image-mode.el
--- lisp/image-mode.el  3 Feb 2007 01:01:01 -0000       1.20
+++ lisp/image-mode.el  5 Feb 2007 18:52:50 -0000
@@ -61,9 +61,15 @@
  (use-local-map image-mode-map)
  (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
+  (if (and (display-images-p)
+          (not (get-text-property (point-min) 'display)))
+      (image-toggle-display)
+    ;; Set next vars when image is already displayed but local
+    ;; variables were cleared by kill-all-local-variables
+    (setq cursor-type nil truncate-lines t))
  (run-mode-hooks 'image-mode-hook)
  (if (display-images-p)
      (message "%s" (concat
                     (substitute-command-keys
-                     "Type \\[image-toggle-display] to view as ")
+                     "Type \\[image-toggle-display] to view the image as ")
                     (if (get-text-property (point-min) 'display)
                         "text" "an image") "."))))
@@ -106,6 +112,5 @@
                     auto-mode-alist))))
    (if (assoc-default buffer-file-name mode-alist 'string-match)
-       (let ((auto-mode-alist mode-alist)
-             (magic-mode-alist nil))
+       (let ((auto-mode-alist mode-alist))
          (set-auto-mode)
          (image-minor-mode t))
@@ -175,14 +180,4 @@
          (message "Repeat this command to go back to displaying the file as
text")))))

-;; Don't override the setting from .emacs.
-;;;###autoload (put 'image-toggle-display 'disabled t)
-
-(if (get 'image-toggle-display 'disabled)
-    (put 'image-toggle-display 'disabled "\
-
-Warning: Displaying images in Emacs could be a security risk.
-Please ensure that you are using up-to-date image libraries
-and that the images being displayed come from a trusted source."))
-
(provide 'image-mode)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]