emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Flymake refactored


From: João Távora
Subject: Re: Flymake refactored
Date: Mon, 09 Oct 2017 00:21:07 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux)

Mark Oteiza <address@hidden> writes:

>> Agree, makes sense. But this seems akward to do in
>> tabulated-list-mode. I don't mind if you beat me to it :-)
>
> Patch below :)

Thanks, applied it. But tweaked it again (patch below) to at least have
mouse-face 'highlight on the message when hovering on it. This is
slightly more complicated but more in line with what the Elisp manual
node seems to suggest doing in "Clickable Text" (there seems to be more
than one way tho).

Feel free to tweak again and push to the
scratch/flymake-diagnostics-buffer branch.

> Probably overkill, but my best example is the Freefem++ manual: an 860

Yes, 10 minutes is overkill, but we can probably scale it to 10% or
so. Unfortunately, I don't have time to work on this properly now, so
don't hold back :-)

João

commit 9412afa5f601f0d3f6d6d094bf5b918a41a3e136
Author: João Távora <address@hidden>
Date:   Mon Oct 9 00:12:48 2017 +0100

    Tweak the Flymake diagnostics buffer again
    
    * lisp/progmodes/flymake.el
    (flymake-diagnostics-buffer-mode-map): Don't bind [mouse-1].
    (flymake-show-diagnostic): Rename from
    flymake-show-diagnostic-at-point.  Really use another window.
    (flymake-goto-diagnostic): Rename from
    flymake-goto-diagnostic-at-point.
    (flymake--diagnostics-buffer-entries): Use a button just for
    the message bit.

diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index fb5fc7db12..6796fc2b76 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -990,31 +990,31 @@ flymake--diagnostics-buffer-source
 
 (defvar flymake-diagnostics-buffer-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [mouse-1] 'flymake-goto-diagnostic-at-point)
-    (define-key map (kbd "RET") 'flymake-goto-diagnostic-at-point)
-    (define-key map (kbd "SPC") 'flymake-show-diagnostic-at-point)
+    (define-key map (kbd "RET") 'flymake-goto-diagnostic)
+    (define-key map (kbd "SPC") 'flymake-show-diagnostic)
     map))
 
-(defun flymake-show-diagnostic-at-point ()
-  "Show location of diagnostic at point."
-  (interactive)
-  (let* ((id (or (tabulated-list-get-id)
+(defun flymake-show-diagnostic (pos &optional other-window)
+  "Show location of diagnostic at POS."
+  (interactive (list (point) t))
+  (let* ((id (or (tabulated-list-get-id pos)
                  (user-error "Nothing at point")))
          (overlay (plist-get id :overlay)))
     (with-current-buffer (overlay-buffer overlay)
       (with-selected-window
-          (display-buffer (current-buffer))
+          (display-buffer (current-buffer) other-window)
         (goto-char (overlay-start overlay))
         (pulse-momentary-highlight-region (overlay-start overlay)
                                           (overlay-end overlay)
                                           'highlight))
       (current-buffer))))
 
-(defun flymake-goto-diagnostic-at-point ()
-  "Show location of diagnostic at point."
-  (interactive)
+(defun flymake-goto-diagnostic (pos)
+  "Show location of diagnostic at POS.
+POS can be a buffer position or a button"
+  (interactive "d")
   (pop-to-buffer
-   (flymake-show-diagnostic-at-point)))
+   (flymake-show-diagnostic (if (button-type pos) (button-start pos) pos))))
 
 (defun flymake--diagnostics-buffer-entries ()
   (with-current-buffer flymake--diagnostics-buffer-source
@@ -1039,7 +1039,11 @@ flymake--diagnostics-buffer-entries
                      ,(propertize (format "%s" type)
                                   'face (flymake--lookup-type-property
                                          type 'mode-line-face 'flymake-error))
-                     ,(format "%s" (flymake--diag-text diag))]))))
+                     (,(format "%s" (flymake--diag-text diag))
+                      mouse-face highlight
+                      help-echo "mouse-2: visit this diagnostic"
+                      face nil
+                      mouse-action flymake-goto-diagnostic)]))))
 
 (define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode
   "Flymake diagnostics"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]