From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#17335: 24.4.50; function value for `help-echo': mouseover & frame Date: Thu, 24 Apr 2014 09:05:17 -0700 (PDT) Message-ID: <6fff687a-bdb0-45a3-8994-552d677e24f4@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1398390520 15946 80.91.229.3 (25 Apr 2014 01:48:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Apr 2014 01:48:40 +0000 (UTC) To: 17335@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 25 03:48:33 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WdVFf-0004H9-Gb for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 Apr 2014 03:48:31 +0200 Original-Received: from localhost ([::1]:53330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdVFf-0005wk-6E for geb-bug-gnu-emacs@m.gmane.org; Thu, 24 Apr 2014 21:48:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdUjN-0004LS-Pk for bug-gnu-emacs@gnu.org; Thu, 24 Apr 2014 21:16:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WdUiI-0001t9-SN for bug-gnu-emacs@gnu.org; Thu, 24 Apr 2014 21:15:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49431) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdUiI-0001t3-PJ for bug-gnu-emacs@gnu.org; Thu, 24 Apr 2014 21:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WdUiI-0003Sg-GI for bug-gnu-emacs@gnu.org; Thu, 24 Apr 2014 21:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Apr 2014 01:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 17335 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.139838843713286 (code B ref -1); Fri, 25 Apr 2014 01:14:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Apr 2014 01:13:57 +0000 Original-Received: from localhost ([127.0.0.1]:57588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WdUiB-0003SB-Tv for submit@debbugs.gnu.org; Thu, 24 Apr 2014 21:13:56 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53486) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WdUi9-0003S0-An for submit@debbugs.gnu.org; Thu, 24 Apr 2014 21:13:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WdUh9-0001Gy-38 for submit@debbugs.gnu.org; Thu, 24 Apr 2014 21:13:52 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:38133) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdUh8-0001Gp-Vc for submit@debbugs.gnu.org; Thu, 24 Apr 2014 21:12:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdUgQ-0000UI-9g for bug-gnu-emacs@gnu.org; Thu, 24 Apr 2014 21:12:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WdM9I-0007g3-VK for bug-gnu-emacs@gnu.org; Thu, 24 Apr 2014 12:05:30 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:20223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdM9I-0007fK-Lk for bug-gnu-emacs@gnu.org; Thu, 24 Apr 2014 12:05:20 -0400 Original-Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s3OG5IL4009161 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Apr 2014 16:05:19 GMT Original-Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s3OG5HL0011388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 24 Apr 2014 16:05:18 GMT Original-Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s3OG5H5b020985 for ; Thu, 24 Apr 2014 16:05:17 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6691.5000 (x86)] X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:88272 Archived-At: 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)) ; <=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D (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 # # 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=3D/c/Devel/emacs/snapshot/trunk --enable-checking=3Dyes,glyphs 'CFLAGS=3D-O0 -g3' LDFLAGS=3D-Lc:/Devel/emacs/lib 'CPPFLAGS=3D-DGC_MCHECK=3D1 -Ic:/Devel/emacs/include''