Add new function image-at-point-p

* lisp/image.el (image-at-point-p): New defun.
* doc/lispref/display.texi (Showing Images): Document above new defun.
This commit is contained in:
Stefan Kangas
2021-10-27 03:22:09 +02:00
parent d22cd6d4c6
commit 203279a024
3 changed files with 17 additions and 0 deletions

View File

@@ -6549,6 +6549,11 @@ cache, it can always be displayed, even if the value of
@code{max-image-size} is subsequently changed (@pxref{Image Cache}).
@end defvar
@defun image-at-point-p
This function returns @code{t} if point is on an image, and @code{nil}
otherwise.
@end defun
Images inserted with the insertion functions above also get a local
keymap installed in the text properties (or overlays) that span the
displayed image. This keymap defines the following commands:

View File

@@ -386,6 +386,11 @@ something usable even if the syntax of the argument isn't completely
correct. The 'kbd-valid-p' predicate does a stricter check of the
syntax.
+++
** New function 'image-at-point-p'.
This function returns t if point is on a valid image, and nil
otherwise.
* Changes in Emacs 29.1 on Non-Free Operating Systems

View File

@@ -1140,6 +1140,13 @@ default is 20%."
(error "No image under point"))
image))
;;;###autoload
(defun image-at-point-p ()
"Return non-nil if there is an image at point."
(condition-case nil
(prog1 t (image--get-image))
(error nil)))
(defun image--get-imagemagick-and-warn (&optional position)
(declare-function image-transforms-p "image.c" (&optional frame))
(unless (or (fboundp 'imagemagick-types) (image-transforms-p))