aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2019-04-28 16:29:44 -0400
committerNoam Postavsky2019-04-28 16:45:13 -0400
commit74712470fcb95cd4ef6ef5c61eee73cb8e02a8bd (patch)
tree3c802c616119719cf8434e77706fd22915df0a8c
parentcaadbd94921b66fd6820dbc95783765837b931f7 (diff)
downloademacs-74712470fcb95cd4ef6ef5c61eee73cb8e02a8bd.tar.gz
emacs-74712470fcb95cd4ef6ef5c61eee73cb8e02a8bd.zip
Replace use of obsolete string-make-unibyte
* lisp/image-file.el (insert-image-file): Use encode-coding-region instead of string-make-unibyte. * test/lisp/image-file-tests.el: New test.
-rw-r--r--lisp/image-file.el7
-rw-r--r--test/lisp/image-file-tests.el44
2 files changed, 46 insertions, 5 deletions
diff --git a/lisp/image-file.el b/lisp/image-file.el
index abc4686d69c..6cadc42110f 100644
--- a/lisp/image-file.el
+++ b/lisp/image-file.el
@@ -110,11 +110,8 @@ absolute file name and number of characters inserted."
110 (let* ((ibeg (point)) 110 (let* ((ibeg (point))
111 (iend (+ (point) (cadr rval))) 111 (iend (+ (point) (cadr rval)))
112 (visitingp (and visit (= ibeg (point-min)) (= iend (point-max)))) 112 (visitingp (and visit (= ibeg (point-min)) (= iend (point-max))))
113 (data 113 (image (create-image (encode-coding-region ibeg iend 'binary t)
114 (string-make-unibyte 114 nil t))
115 (buffer-substring-no-properties ibeg iend)))
116 (image
117 (create-image data nil t))
118 (props 115 (props
119 `(display ,image 116 `(display ,image
120 yank-handler 117 yank-handler
diff --git a/test/lisp/image-file-tests.el b/test/lisp/image-file-tests.el
new file mode 100644
index 00000000000..b3676d1f02c
--- /dev/null
+++ b/test/lisp/image-file-tests.el
@@ -0,0 +1,44 @@
1;;; image-file-tests.el --- Test suite for image-files -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;;; Code:
23
24(require 'ert)
25(require 'image-file)
26
27(defconst image-file-tests-data-directory
28 (expand-file-name "data/image" (getenv "EMACS_TEST_DIRECTORY"))
29 "Directory containing image test data.")
30
31(ert-deftest insert-image-file ()
32 (skip-unless (image-type-available-p 'png))
33 (with-temp-buffer
34 (set-buffer-multibyte t)
35 (insert-image-file (expand-file-name "blank-100x200.png"
36 image-file-tests-data-directory))
37 (should (image--get-image)))
38 (with-temp-buffer
39 (set-buffer-multibyte nil)
40 (insert-image-file (expand-file-name "blank-100x200.png"
41 image-file-tests-data-directory))
42 (should (image--get-image))))
43
44;;; image-file-tests.el ends here