diff options
| author | Stefan Monnier | 2016-05-23 15:12:24 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2016-05-23 15:12:24 -0400 |
| commit | 5e17f509116e88998be5ac664907aa80ea39710a (patch) | |
| tree | 0ea996fd29e22f0cb60fb90f9cc30fbf6b61a13f | |
| parent | d5f42ab6f06e1d468c6b92f2c1ef7b4d5f97ff84 (diff) | |
| download | emacs-5e17f509116e88998be5ac664907aa80ea39710a.tar.gz emacs-5e17f509116e88998be5ac664907aa80ea39710a.zip | |
* lisp/image.el: Use lexical-binding
(image-scaling-factor, imagemagick-types-inhibit)
(imagemagick-enabled-types): Remove redundant :group.
(image--get-image): Apply de-Morgan and use car-safe.
(image-compute-scaling-factor): Use the argument.
| -rw-r--r-- | lisp/image.el | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/lisp/image.el b/lisp/image.el index 296d4300558..ad219361366 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; image.el --- image API | 1 | ;;; image.el --- image API -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1998-2016 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1998-2016 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -123,7 +123,7 @@ value is used as a list of directories to search. | |||
| 123 | 123 | ||
| 124 | Subdirectories are not automatically included in the search." | 124 | Subdirectories are not automatically included in the search." |
| 125 | :type '(repeat (choice directory variable)) | 125 | :type '(repeat (choice directory variable)) |
| 126 | :initialize 'custom-initialize-delay) | 126 | :initialize #'custom-initialize-delay) |
| 127 | 127 | ||
| 128 | (defcustom image-scaling-factor 'auto | 128 | (defcustom image-scaling-factor 'auto |
| 129 | "When displaying images, apply this scaling factor before displaying. | 129 | "When displaying images, apply this scaling factor before displaying. |
| @@ -135,7 +135,6 @@ size), or the symbol `auto', which will compute a scaling factor | |||
| 135 | based on the font pixel size." | 135 | based on the font pixel size." |
| 136 | :type '(choice number | 136 | :type '(choice number |
| 137 | (const :tag "Automatically compute" auto)) | 137 | (const :tag "Automatically compute" auto)) |
| 138 | :group 'image | ||
| 139 | :version "25.2") | 138 | :version "25.2") |
| 140 | 139 | ||
| 141 | ;; Map put into text properties on images. | 140 | ;; Map put into text properties on images. |
| @@ -460,9 +459,8 @@ If VALUE is nil, PROPERTY is removed from IMAGE." | |||
| 460 | 459 | ||
| 461 | (defun image-compute-scaling-factor (scaling) | 460 | (defun image-compute-scaling-factor (scaling) |
| 462 | (cond | 461 | (cond |
| 463 | ((numberp image-scaling-factor) | 462 | ((numberp scaling) scaling) |
| 464 | image-scaling-factor) | 463 | ((eq scaling 'auto) |
| 465 | ((eq image-scaling-factor 'auto) | ||
| 466 | (let ((width (/ (float (window-width nil t)) (window-width)))) | 464 | (let ((width (/ (float (window-width nil t)) (window-width)))) |
| 467 | ;; If we assume that a typical character is 10 pixels in width, | 465 | ;; If we assume that a typical character is 10 pixels in width, |
| 468 | ;; then we should scale all images according to how wide they | 466 | ;; then we should scale all images according to how wide they |
| @@ -471,7 +469,7 @@ If VALUE is nil, PROPERTY is removed from IMAGE." | |||
| 471 | 1 | 469 | 1 |
| 472 | (/ (float width) 10)))) | 470 | (/ (float width) 10)))) |
| 473 | (t | 471 | (t |
| 474 | (error "Invalid scaling factor %s" image-scaling-factor)))) | 472 | (error "Invalid scaling factor %s" scaling)))) |
| 475 | 473 | ||
| 476 | ;;;###autoload | 474 | ;;;###autoload |
| 477 | (defun put-image (image pos &optional string area) | 475 | (defun put-image (image pos &optional string area) |
| @@ -728,7 +726,7 @@ number, play until that number of seconds has elapsed." | |||
| 728 | (if (setq timer (image-animate-timer image)) | 726 | (if (setq timer (image-animate-timer image)) |
| 729 | (cancel-timer timer)) | 727 | (cancel-timer timer)) |
| 730 | (plist-put (cdr image) :animate-buffer (current-buffer)) | 728 | (plist-put (cdr image) :animate-buffer (current-buffer)) |
| 731 | (run-with-timer 0.2 nil 'image-animate-timeout | 729 | (run-with-timer 0.2 nil #'image-animate-timeout |
| 732 | image (or index 0) (car animation) | 730 | image (or index 0) (car animation) |
| 733 | 0 limit (+ (float-time) 0.2))))) | 731 | 0 limit (+ (float-time) 0.2))))) |
| 734 | 732 | ||
| @@ -739,7 +737,7 @@ number, play until that number of seconds has elapsed." | |||
| 739 | (while tail | 737 | (while tail |
| 740 | (setq timer (car tail) | 738 | (setq timer (car tail) |
| 741 | tail (cdr tail)) | 739 | tail (cdr tail)) |
| 742 | (if (and (eq (timer--function timer) 'image-animate-timeout) | 740 | (if (and (eq (timer--function timer) #'image-animate-timeout) |
| 743 | (eq (car-safe (timer--args timer)) image)) | 741 | (eq (car-safe (timer--args timer)) image)) |
| 744 | (setq tail nil) | 742 | (setq tail nil) |
| 745 | (setq timer nil))) | 743 | (setq timer nil))) |
| @@ -819,7 +817,7 @@ for the animation speed. A negative value means to animate in reverse." | |||
| 819 | (if (numberp limit) | 817 | (if (numberp limit) |
| 820 | (setq done (>= time-elapsed limit))) | 818 | (setq done (>= time-elapsed limit))) |
| 821 | (unless done | 819 | (unless done |
| 822 | (run-with-timer delay nil 'image-animate-timeout | 820 | (run-with-timer delay nil #'image-animate-timeout |
| 823 | image n count time-elapsed limit | 821 | image n count time-elapsed limit |
| 824 | (+ (float-time) delay)))))) | 822 | (+ (float-time) delay)))))) |
| 825 | 823 | ||
| @@ -907,12 +905,11 @@ has no effect." | |||
| 907 | :type '(choice (const :tag "Support all ImageMagick types" nil) | 905 | :type '(choice (const :tag "Support all ImageMagick types" nil) |
| 908 | (const :tag "Disable all ImageMagick types" t) | 906 | (const :tag "Disable all ImageMagick types" t) |
| 909 | (repeat symbol)) | 907 | (repeat symbol)) |
| 910 | :initialize 'custom-initialize-default | 908 | :initialize #'custom-initialize-default |
| 911 | :set (lambda (symbol value) | 909 | :set (lambda (symbol value) |
| 912 | (set-default symbol value) | 910 | (set-default symbol value) |
| 913 | (imagemagick-register-types)) | 911 | (imagemagick-register-types)) |
| 914 | :version "24.3" | 912 | :version "24.3") |
| 915 | :group 'image) | ||
| 916 | 913 | ||
| 917 | (defcustom imagemagick-enabled-types | 914 | (defcustom imagemagick-enabled-types |
| 918 | '(3FR ART ARW AVS BMP BMP2 BMP3 CAL CALS CMYK CMYKA CR2 CRW | 915 | '(3FR ART ARW AVS BMP BMP2 BMP3 CAL CALS CMYK CMYKA CR2 CRW |
| @@ -945,12 +942,11 @@ has no effect." | |||
| 945 | (repeat :tag "List of types" | 942 | (repeat :tag "List of types" |
| 946 | (choice (symbol :tag "type") | 943 | (choice (symbol :tag "type") |
| 947 | (regexp :tag "regexp")))) | 944 | (regexp :tag "regexp")))) |
| 948 | :initialize 'custom-initialize-default | 945 | :initialize #'custom-initialize-default |
| 949 | :set (lambda (symbol value) | 946 | :set (lambda (symbol value) |
| 950 | (set-default symbol value) | 947 | (set-default symbol value) |
| 951 | (imagemagick-register-types)) | 948 | (imagemagick-register-types)) |
| 952 | :version "24.3" | 949 | :version "24.3") |
| 953 | :group 'image) | ||
| 954 | 950 | ||
| 955 | (imagemagick-register-types) | 951 | (imagemagick-register-types) |
| 956 | 952 | ||
| @@ -974,8 +970,7 @@ default is 20%." | |||
| 974 | 970 | ||
| 975 | (defun image--get-image () | 971 | (defun image--get-image () |
| 976 | (let ((image (get-text-property (point) 'display))) | 972 | (let ((image (get-text-property (point) 'display))) |
| 977 | (when (or (not (consp image)) | 973 | (unless (eq (car-safe image) 'image) |
| 978 | (not (eq (car image) 'image))) | ||
| 979 | (error "No image under point")) | 974 | (error "No image under point")) |
| 980 | image)) | 975 | image)) |
| 981 | 976 | ||