emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/hyperbole a933051 19/53: Supported Emacs button mouse a


From: Robert Weiner
Subject: [elpa] externals/hyperbole a933051 19/53: Supported Emacs button mouse action; improved Lisp outlining support; improved load library links
Date: Wed, 15 Nov 2017 22:47:01 -0500 (EST)

branch: externals/hyperbole
commit a9330517f34c231162e1c3dd62ab19ba401df742
Author: Bob Weiner <address@hidden>
Commit: Bob Weiner <address@hidden>

    Supported Emacs button mouse action; improved Lisp outlining support; 
improved load library links
    
    * hui-mouse.el (smart-push-button-help): Added 2nd optional arg, 
use-mouse-action,
        which if non-nil, displays help for mouse-action property if any, and 
falls
        back to action property otherwise.
                   (hkey-alist): push-button - Changed to use mouse-action if
        last-command-event was a mouse event.  Previously, mouse actions were
         not supported.
    
    * hmouse-tag.el (smart-lisp-at-tag-p): Changed to not match anywhere on the 
first
        line of def constructs.  This aids in using Smart Keys for outline
        folding within Lisp buffers.
                    (smart-lisp-at-definition-p): Added to test if point is on
        the first line of a non-alias Lisp definition.
                    (smart-lisp-at-load-expression-p): Added to test if point
        is on any type of Lisp library load expression.
                    (smart-lisp): Changed call of buffer-substring-no-properties
        to match-string-no-properties.
                    (smart-lisp): Fixed regexp matching of require and autoload 
expressions.
           For require and load, moved point to start of the buffer.
           For autoload, triggered an error if library is found but symbol def 
is not.
    
    * hui-mouse.el (smart-outline-char-invisible-p): Substituted 
outline-invisible-p
        call for kproperty:get, which may not yet be defined.
                   (smart-outline-subtree-hidden-p): Fixed to match only when 
point is
        on a heading.
                   (smart-imenu-item-at-p): Updated to ignore when 
smart-lisp-at-definition-p
        or smart-lisp-at-load-expression-p tests are true.
                   (hkey-alist): smart-imenu - ignored non-alias identifiers on 
the
        first line of a Lisp def.
---
 Changes       | 31 +++++++++++++++++++++++++++++++
 hmouse-tag.el | 59 +++++++++++++++++++++++++++++++++++++++++------------------
 hui-mouse.el  | 42 ++++++++++++++++++++++++++----------------
 3 files changed, 98 insertions(+), 34 deletions(-)

diff --git a/Changes b/Changes
index 0e5f959..34103db 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,34 @@
+2017-09-28  Bob Weiner  <address@hidden>
+
+* hui-mouse.el (smart-push-button-help): Added 2nd optional arg, 
use-mouse-action,
+    which if non-nil, displays help for mouse-action property if any, and falls
+    back to action property otherwise.
+               (hkey-alist): push-button - Changed to use mouse-action if
+    last-command-event was a mouse event.  Previously, mouse actions were
+     not supported.
+
+* hmouse-tag.el (smart-lisp-at-tag-p): Changed to not match anywhere on the 
first
+    line of def constructs.  This aids in using Smart Keys for outline
+    folding within Lisp buffers.
+                (smart-lisp-at-definition-p): Added to test if point is on
+    the first line of a non-alias Lisp definition.
+                (smart-lisp-at-load-expression-p): Added to test if point
+    is on any type of Lisp library load expression.
+                (smart-lisp): Changed call of buffer-substring-no-properties
+    to match-string-no-properties.
+                (smart-lisp): Fixed regexp matching of require and autoload 
expressions.
+       For require and load, moved point to start of the buffer.
+       For autoload, triggered an error if library is found but symbol def is 
not.
+
+* hui-mouse.el (smart-outline-char-invisible-p): Substituted 
outline-invisible-p
+    call for kproperty:get, which may not yet be defined.
+               (smart-outline-subtree-hidden-p): Fixed to match only when 
point is
+    on a heading.
+               (smart-imenu-item-at-p): Updated to ignore when 
smart-lisp-at-definition-p
+    or smart-lisp-at-load-expression-p tests are true.
+               (hkey-alist): smart-imenu - ignored non-alias identifiers on the
+    first line of a Lisp def.
+
 2017-09-27  Bob Weiner  <address@hidden>
 
 * hui-mouse.el (smart-buffer-menu-no-marks): Added and called in 
smart-buffer-menu.
diff --git a/hmouse-tag.el b/hmouse-tag.el
index 830e991..04f13f9 100644
--- a/hmouse-tag.el
+++ b/hmouse-tag.el
@@ -565,19 +565,33 @@ buffer."
   (interactive)
   (unless (and (smart-emacs-lisp-mode-p) (fboundp 'find-library)
               ;; Handle Emacs Lisp `require', `load', and `autoload' clauses.
-              (let ((lib)
-                    (opoint (point)))
+              (let ((opoint (point))
+                    type
+                    name
+                    lib)
                 (setq lib (and (search-backward "\(" nil t)
-                               (looking-at (concat
-                                            "(\\(require\\|load\\|autoload\\)"
-                                            "[ \t]+.*['\"]"
-                                            "\\([^][() \t\n\r`'\"]+\\)"))))
+                               (or
+                                ;; load with a filename
+                                (looking-at "(\\(load\\)[ 
\t]+\\(\\)\"\\([^][() \t\n\r`'\"]+\\)")
+                                ;; autoload or require with a name and filename
+                                (looking-at "(\\(autoload\\|require\\)[ 
\t]+'\\([^][() \t\n\r`'\"]+\\)[ \t\n\r]+\"\\([^][() \t\n\r`'\"]+\\)")
+                                ;; require without a separate filename
+                                (looking-at "(\\(require\\)\\(\\)[ 
\t]+'\\([^][() \t\n\r`'\"]+\\)"))))
                 (goto-char opoint)
                 (when lib
-                  (setq lib (buffer-substring-no-properties
-                             (match-beginning 2) (match-end 2)))
+                  (setq type (match-string-no-properties 1)
+                        name (match-string-no-properties 2)
+                        lib (match-string-no-properties 3))
                   (hpath:display-buffer (current-buffer))
                   (find-library lib)
+                  (goto-char (point-min))
+                  (when (equal type "autoload")
+                    ;; Ignore defgroup matches
+                    (if (re-search-forward
+                         (format "^[; \t]*(def.[^r][^ \t\n\r]*[ \t]+%s[ 
\t\n\r]" (regexp-quote name))
+                         nil t)
+                        (goto-char (match-beginning 0))
+                      (error "(smart-lisp): Found autoload library but no 
definition for `%s'" name)))
                   t)))
     (let* ((elisp-p (smart-emacs-lisp-mode-p))
           (tag (smart-lisp-at-tag-p t))
@@ -604,18 +618,27 @@ buffer."
                                       (error nil)))
                          (error "(smart-lisp): `%s' definition not found in 
any tag table" tag)))))))))
 
-(defun smart-lisp-at-tag-p (&optional no-flash)
-  "Returns Lisp tag name that point is within, else nil.
-Returns nil when point is within a Lisp `def' keyword."
-  (let* ((identifier-chars "-_:/*+=%$&?!<>a-zA-Z0-9~^")
-        (identifier (concat "[-<>*a-zA-Z][" identifier-chars "]*"))
-        (opoint (point)))
+(defun smart-lisp-at-definition-p ()
+    "Returns t when point is on the first line of a non-alias Lisp definition, 
else nil."
     (save-excursion
       (beginning-of-line)
-      (if (and (looking-at "\\(;*[ \t]*\\)?(def[^- \t\n\r]+")
-              (< opoint (match-end 0)))
-         nil
-       (goto-char opoint)
+      (and (looking-at "\\(;*[ \t]*\\)?(def")
+          ;; Ignore alias definitions since those typically have symbol tags 
to lookup.
+          (not (looking-at "\\(;*[ \t]*\\)?(def[^ \t\n\r]*alias")))))
+
+(defun smart-lisp-at-load-expression-p ()
+    "Returns t when point is on the first line of a Lisp library load 
expression, else nil."
+    (save-excursion
+      (beginning-of-line)
+      (looking-at "\\(;*[ \t]*\\)?(\\(autoload\\|load\\|require\\)")))
+
+(defun smart-lisp-at-tag-p (&optional no-flash)
+  "Returns Lisp tag name that point is within, else nil.
+Returns nil when point is on the first line of a non-alias Lisp definition."
+  (unless (smart-lisp-at-definition-p)
+    (let* ((identifier-chars "-_:/*+=%$&?!<>a-zA-Z0-9~^")
+          (identifier (concat "[-<>*a-zA-Z][" identifier-chars "]*")))
+      (save-excursion
        (skip-chars-backward identifier-chars)
        (if (and (looking-at identifier)
                 ;; Ignore any all punctuation matches.
diff --git a/hui-mouse.el b/hui-mouse.el
index ff8665e..12255cb 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -86,7 +86,8 @@ Its default value is #'smart-scroll-down."
   '(
     ;; Handle Emacs push buttons in buffers
     ((and (fboundp 'button-at) (button-at (point))) .
-     ((push-button) . (smart-push-button-help)))
+     ((push-button nil (mouse-event-p last-command-event))
+      . (smart-push-button-help nil (mouse-event-p last-command-event))))
     ;;
     ;; If click in the minibuffer and reading an argument,
     ;; accept argument or give completion help.
@@ -219,9 +220,9 @@ Its default value is #'smart-scroll-down."
      ((pages-directory-goto) . (pages-directory-goto)))
     ;;
     ;; Imenu listing in GNU Emacs
-    ((smart-imenu-item-at-p) .
-     ((smart-imenu-display-item-where (car hkey-value) (cdr hkey-value)) .
-      (imenu-choose-buffer-index)))
+    ((smart-imenu-item-at-p)
+     . ((smart-imenu-display-item-where (car hkey-value) (cdr hkey-value)) 
.emacs
+       (imenu-choose-buffer-index)))
     ;;
     ;; Function menu listing mode in XEmacs
     ((eq major-mode 'fume-list-mode) .
@@ -1097,8 +1098,12 @@ Does nothing unless imenu has been loaded and an index 
has been
 created for the current buffer.  When return value is non-nil, also
 sets `hkey-value' to (identifier . identifier-definition-buffer-position)."
   (and (featurep 'imenu) imenu--index-alist
-       (setq hkey-value (hargs:find-tag-default))
-       (setq hkey-value (cons hkey-value (smart-imenu-item-p hkey-value 
variable-flag)))
+       ;; Ignore non-alias identifiers on the first line of a Lisp def.
+       (not (and (smart-lisp-mode-p) (smart-lisp-at-definition-p)))
+       ;; Ignore Lisp loading expressions
+       (not (smart-lisp-at-load-expression-p))
+       (setq hkey-value (hargs:find-tag-default)
+            hkey-value (cons hkey-value (smart-imenu-item-p hkey-value 
variable-flag)))
        (cdr hkey-value)))
 
 ;; Derived from `imenu' function in the imenu library.
@@ -1295,7 +1300,7 @@ If key is pressed:
  (2) at the end of buffer, show all buffer text 
  (3) at the beginning of a heading line, cut the headings subtree from the
      buffer;
- (4) on a header line but not at the beginning or end, if headings subtree is
+ (4) on a heading line but not at the beginning or end, if headings subtree is
      hidden then show it, otherwise hide it;
  (5) anywhere else, invoke `action-key-eol-function', typically to scroll up
      a windowful."
@@ -1316,7 +1321,7 @@ If key is pressed:
        ((or (eolp) (zerop (save-excursion (beginning-of-line)
                                           (outline-level))))
         (funcall action-key-eol-function))
-       ;; On an outline header line but not at the start/end of line.
+       ;; On an outline heading line but not at the start/end of line.
        ((smart-outline-subtree-hidden-p)
         (outline-show-subtree))
        (t (outline-hide-subtree))))
@@ -1335,7 +1340,7 @@ If assist-key is pressed:
  (2) at the end of buffer, hide all bodies in buffer;
  (3) at the beginning of a heading line, cut the current heading (sans
      subtree) from the buffer;
- (4) on a header line but not at the beginning or end, if heading body is
+ (4) on a heading line but not at the beginning or end, if heading body is
      hidden then show it, otherwise hide it;
  (5) anywhere else, invoke `assist-key-eol-function', typically to scroll down
      a windowful."
@@ -1353,7 +1358,7 @@ If assist-key is pressed:
        ((or (eolp) (zerop (save-excursion (beginning-of-line)
                                           (outline-level))))
         (funcall assist-key-eol-function))
-       ;; On an outline header line but not at the start/end of line.
+       ;; On an outline heading line but not at the start/end of line.
        ((smart-outline-subtree-hidden-p)
         (outline-show-entry))
        (t (outline-hide-entry))))
@@ -1378,14 +1383,16 @@ CURR-ENTRY-LEVEL is not needed."
 
 (defun smart-outline-subtree-hidden-p ()
   "Returns t if at least initial subtree of heading is hidden, else nil."
-  (outline-invisible-in-p (point) (or (save-excursion (re-search-forward 
"[\n\r]" nil t)) (point))))
+  (and (outline-on-heading-p t)
+       (outline-invisible-in-p
+       (point) (or (save-excursion (re-search-forward "[\n\r]" nil t)) 
(point)))))
 
 (defun smart-outline-char-invisible-p (&optional pos)
   "Return t if the character after point is invisible/hidden, else nil."
   (or pos (setq pos (point)))
   (when (or
         ;; New-style Emacs outlines with invisible properties to hide lines
-        (kproperty:get pos 'invisible)
+        (outline-invisible-p pos)
         (delq nil (mapcar (lambda (o) (overlay-get o 'invisible))
                           (overlays-at (or pos (point)))))
         ;; Old-style Emacs outlines using \r (^M) characters to hide lines
@@ -1404,14 +1411,17 @@ CURR-ENTRY-LEVEL is not needed."
 ;;; ************************************************************************
 
 ;; Emacs push button support
-(defun smart-push-button-help (&optional pos)
+(defun smart-push-button-help (&optional pos use-mouse-action)
   "Show help about a push button's action at optional POS or at point in the 
current buffer."
-  (let ((expr (button-get (button-at (or pos (point))) 'action))
+  (let* ((button (button-at (or pos (point))))
+        (action (or (and use-mouse-action (button-get button 'mouse-action))
+                    (button-get button 'action)))
         ;; Ensure these do not invoke with-output-to-temp-buffer a second time.
         (temp-buffer-show-hook)
         (temp-buffer-show-function))
-    (if (functionp expr) (describe-function expr)
-      (with-help-window (print (format "Button's action is: '%s'" expr))))))
+    (if (functionp action)
+       (describe-function action)
+      (with-help-window (print (format "Button's action is: '%s'" action))))))
 
 ;;; ************************************************************************
 ;;; smart-tar functions



reply via email to

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