From: Drew Adams <drew.adams@oracle.com>
To: 17335@debbugs.gnu.org
Subject: bug#17335: 24.4.50; function value for `help-echo': mouseover & frame
Date: Thu, 24 Apr 2014 09:05:17 -0700 (PDT) [thread overview]
Message-ID: <6fff687a-bdb0-45a3-8994-552d677e24f4@default> (raw)
emacs -Q
1. Set things up so that image-dired can work. On Windows, I load
library cygwin-mount.el and then setup-cygwin.el (both on Emacs Wiki).
2. Evaluate this code. It makes it so that a mouseover on an image file
name in Dired shows a thumbnail of the image in a tooltip.
(require 'image-dired)
(tooltip-mode 1)
;; Like `image-dired-create-thumb', but single file & returns thumbnail.
(defun diredp-image-dired-create-thumb (&optional arg)
"Create thumbnail image file for this file.
With a prefix arg, replace any existing thumbnail for the file.
Return the name of the thumbnail image file, or nil if none."
(interactive "P")
(let* ((curr-file (dired-get-filename))
(thumb-name (image-dired-thumb-name curr-file)))
(when arg (clear-image-cache))
(when (or arg (not (file-exists-p thumb-name)))
(unless (zerop (image-dired-create-thumb
curr-file (image-dired-thumb-name curr-file)))
(error "Thumbnail image file could not be created")))
(and (file-exists-p thumb-name) thumb-name)))
;; REPLACE ORIGINAL in `dired.el'.
;; 1. Put `mouse-face' on whole line, not just file name.
;; 2. Add text property `dired-filename' to only the file name.
;; 3. Show image-file preview on mouseover, if `tooltip-mode'.
;;
;; #3 is what is important for this bug report.
;;
(defun dired-insert-set-properties (beg end)
"Add various text properties to the lines in the region.
Highlight entire line upon mouseover.
Add text property `dired-filename' to the file name.
Handle `dired-hide-details-mode' invisibility spec (Emacs 24.4+)."
(let ((inhibit-field-text-motion t)) ; Just in case.
(save-excursion
(goto-char beg)
(while (< (point) end)
(condition-case nil
(cond ((dired-move-to-filename)
(add-text-properties
(line-beginning-position) (line-end-position)
'(mouse-face highlight
help-echo diredp-mouseover-help)) ; <===========
(put-text-property
(point) (save-excursion
(dired-move-to-end-of-filename) (point))
'dired-filename t)
(put-text-property
(+ (line-beginning-position) 1) (1- (point))
'invisible 'dired-hide-details-detail)
(dired-move-to-end-of-filename)
(when (< (+ (point) 4) (line-end-position))
(put-text-property
(+ (point) 4) (line-end-position)
'invisible 'dired-hide-details-link)))
(t
(unless (or (looking-at-p "^$")
(looking-at-p dired-subdir-regexp))
(put-text-property
(line-beginning-position) (1+ (line-end-position))
'invisible 'dired-hide-details-information))))
(error nil))
(forward-line 1)))))
(defun diredp-mouseover-help (window buffer pos)
"`help-echo' function for Dired."
(let (file)
(if (and tooltip-mode
(with-selected-frame (window-frame window)
;; (with-selected-window window
;; (select-frame-set-input-focus (window-frame window))
(with-current-buffer buffer
(goto-char pos)
(string-match-p
(image-file-name-regexp)
(setq file (dired-get-filename nil 'NO-ERROR))))))
(let ((img-file (diredp-image-dired-create-thumb file)))
(propertize " " 'display (create-image img-file)))
"mouse-2: visit this file in another window")))
3. `C-x 5 b *Messages*', so you can see redisplay error messages.
4. `C-x 5 d' to a directory that has some image files. Move the mouse
over these file names. No problem: a thumbnail tooltip is shown for each
file you mouseover.
5. `C-x 5 o', to select another frame, or just click another frame's
title bar. This takes input focus away from the Dired frame.
6. Now mouseover the same files in the Dired frame, without first
clicking its title bar or otherwise selecting it (giving it focus).
You will see *lots* of error messages such as this in buffer *Messages*:
Error during redisplay: (diredp-mouseover-help #<window 12 on TEST> #<buffer TEST> 426) signaled (error "No file on this line")
(The code could be wrapped in `ignore-errors', but that's not the point
here.)
7. The `help-echo' function is correctly passed the WINDOW, BUFFER, and
POSition. The problem seems to be that (a) mouseover is active, even
though the frame is not selected (for some meaning of selected, probably
including focus), and (b) when the `help-echo' function is invoked, the
frame is not selected/focused, or the wrong buffer is used somehow (?).
IOW, mouseover is activated and passed the correct WINDOW, BUFFER, and
POSition, but the code above is apparently not sufficient to make Emacs
actually use these arguments as I would expect it to.
8. I tried wrapping the `with-current-buffer' with
`(with-selected-window WINDOW...)'. That didn't help. I tried wrapping
it with `(with-selected-frame (window-frame WINDOW)...' (as shown above).
That didn't help. I tried `(select-frame-set-input-focus (window-frame
WINDOW))', but that didn't help either.
Am I missing something? Should I add something else here, to make the
mouseover use WINDOW and BUFFER as I have been expecting? Or is it a
bug that mouseover is active at all when the frame is not selected?
FWIW: Other Window apps seem to behave the same way wrt focus and
mouseover: mouseover is active even if the "frame" is not selected for
input focus (e.g., by clicking its title bar). So I don't imagine that
Emacs is doing anything wrong in that regard.
I cannot tell whether I am seeing a bug or I'm just missing knowing the
proper code to use to get the `help-echo' function to temporarily make
the WINDOW and BUFFER and WINDOW's frame current/selected/focused.
A guess would be that I need to give the frame the input focus
(temporarily), but using `select-frame-set-input-focus' did not seem to
help.
In GNU Emacs 24.4.50.1 (i686-pc-mingw32)
of 2014-04-21 on ODIEONE
Bzr revision: 117005 dancol@dancol.org-20140421180019-po4wdeg7gqvvlh5d
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
`configure --prefix=/c/Devel/emacs/snapshot/trunk
--enable-checking=yes,glyphs 'CFLAGS=-O0 -g3'
LDFLAGS=-Lc:/Devel/emacs/lib 'CPPFLAGS=-DGC_MCHECK=1
-Ic:/Devel/emacs/include''
reply other threads:[~2014-04-24 16:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6fff687a-bdb0-45a3-8994-552d677e24f4@default \
--to=drew.adams@oracle.com \
--cc=17335@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.