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

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

[elpa] externals/hyperbole 85412b4 2/3: Improve Action Key Elisp identif


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 85412b4 2/3: Improve Action Key Elisp identifier finding
Date: Sun, 2 May 2021 02:57:09 -0400 (EDT)

branch: externals/hyperbole
commit 85412b4760b98fc798277ddc6c3ba2df24f258bb
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    Improve Action Key Elisp identifier finding
    
    Plus debugger-source ibtype optimization;
    Change 'unix' to 'posix' in hyrolo;
    Add kotl-mode:kill-whole-line override function.
---
 ChangeLog         | 20 ++++++++++++++++
 hibtypes.el       | 70 ++++++++++++++++++++++++++++++++++---------------------
 hmouse-tag.el     | 55 +++++++++++++++++++++++++++----------------
 hsys-org.el       |  2 +-
 hyrolo.el         |  6 +++--
 kotl/kotl-mode.el |  7 ++++++
 6 files changed, 110 insertions(+), 50 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1e2d4e8..a5ec53d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2021-05-02  Bob Weiner  <rsw@gnu.org>
+
+* kotl/kotl-mode.el (kotl-mode:kill-whole-line): Add override
+    of kill-whole-line for Koutliner.
+
+* hibtypes.el (debugger-source, hib-python-traceback, python-tb-previous-line):
+    Separated handling moving back a line to handle 2 line Python
+    error/traceback entries into a function and an additional ibtype.
+    This eliminates an expensive recursive call to hbut:at-p.
+
+* hmouse-tag.el (smart-lisp): When search for an Elisp identifier,
+    enable the xref etags backend to find symbols not yet loaded
+    into Emacs.
+                (smart-tags-display): Use case-insensitive tags
+    lookup since this should be true for most languages in use
+    today.  Also, make find-tag calls use only exact identifier
+    matches, not partial matches.
+                (smart-lisp): Remove (smart-emacs-lisp-mode-p)
+    check since hkey-alist predicate has checked this already.
+
 2021-05-01  Bob Weiner  <rsw@gnu.org>
 
 * hibtypes.el (pathname): Update to treat "-simple" as an Elisp
diff --git a/hibtypes.el b/hibtypes.el
index a86e11e..ee24bc0 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -83,6 +83,17 @@
 ;; them.  Use load instead to ensure are reloaded when resetting
 ;; ibtype priorities.
 
+(defib python-tb-previous-line ()
+  "If no other implicit button type triggered, move to prior line with 
potential Python line ref.
+In Python, tracebacks may be on a line just below the source
+reference line so since not on a Hyperbole button, move back a
+line and check for a source reference line again."
+  (save-excursion
+    (unless (/= (forward-line -1) 0)
+      ;; Don't wrap this next line in (hact) since has hact call
+      ;; in the function itself.
+      (hib-python-traceback))))
+
 ;;; ========================================================================
 ;;; Runs Hyperbole tests
 ;;; ========================================================================
@@ -219,7 +230,9 @@ display options."
                  (setq path (substring path (match-end 0))
                       full-path (locate-library path elisp-suffix))
                  (cond (full-path
-                       (hact 'hpath:find (concat "-" path)))
+                       (setq path (concat "-" path))
+                       (apply #'ibut:label-set path (hpath:start-end path))
+                       (hact 'hpath:find path))
                       (elisp-suffix
                        (hact 'error "(pathname): \"%s\" not found in 
`load-path'" path))
                       ;; Don't match as a pathname ibut; could be a Lisp
@@ -245,14 +258,20 @@ display options."
                             (and (string-match "\\`\\s-*\\([^;         ]+\\)" 
path)
                                  (executable-find (match-string 1 path))))
                   (hact 'link-to-file path)))
-               ((string-match "\\`[^\\\\/~]+\\.el[cn]?\\(\\.gz\\)?\\'" path)
-                 (apply #'ibut:label-set path (hpath:start-end path))
-                 (if (string-match hpath:prefix-regexp path)
-                     (hact 'hpath:find path)
-                   (setq full-path (locate-library path t))
-                   (if full-path
-                       (hact 'link-to-file full-path)
-                     (hact 'error "(pathname): \"%s\" not found in 
`load-path'" path))))
+               ((setq elisp-suffix (string-match 
"\\`[^\\\\/~]+\\.el[cn]?\\(\\.gz\\)?\\'" path))
+                 (cond ((string-match hpath:prefix-regexp path)
+                       (apply #'ibut:label-set path (hpath:start-end path))
+                       (hact 'hpath:find path))
+                       ((setq full-path
+                             (let ((load-suffixes '(".el")))
+                               (locate-library path elisp-suffix)))
+                       (apply #'ibut:label-set path (hpath:start-end path))
+                       (hact 'link-to-file full-path))
+                      (elisp-suffix
+                       (hact 'error "(pathname): \"%s\" not found in 
`load-path'" path))
+                      ;; Don't match as a pathname ibut; could be a Lisp
+                      ;; symbol or something else starting with a '-'.
+                      (t nil)))
                 ;; Match only if "(filename)" references a valid Info file
                 ;; and point is within the filename, not on any delimiters
                 ;; so that delimited thing matches trigger later.
@@ -928,6 +947,17 @@ in grep and shell buffers."
 ;;; lines.  Supports gdb, dbx, and xdb.
 ;;; ========================================================================
 
+(defun hib-python-traceback ()
+"Test for and jump to line referenced in Python pdb, traceback, or pytype 
error."
+  (when (or (looking-at "\\(^\\|.+ \\)File \"\\([^\"\n\r]+\\)\", line 
\\([0-9]+\\)")
+            (looking-at ">?\\(\\s-+\\)\\([^\"()\n\r]+\\)(\\([0-9]+\\))\\S-"))
+    (let* ((file (match-string-no-properties 2))
+           (line-num (match-string-no-properties 3))
+           (but-label (concat file ":" line-num)))
+      (setq line-num (string-to-number line-num))
+      (ibut:label-set but-label (match-beginning 2) (match-end 2))
+      (hact 'link-to-file-line file line-num))))
+
 (defib debugger-source ()
   "Jump to source line associated with stack frame or breakpoint lines.
 This works with JavaScript and Python tracebacks, gdb, dbx, and xdb.  Such 
lines are recognized in any buffer."
@@ -935,14 +965,9 @@ This works with JavaScript and Python tracebacks, gdb, 
dbx, and xdb.  Such lines
     (beginning-of-line)
     (cond
      ;; Python pdb or traceback, pytype error
-     ((or (looking-at "\\(^\\|.+ \\)File \"\\([^\"\n\r]+\\)\", line 
\\([0-9]+\\)")
-          (looking-at ">?\\(\\s-+\\)\\([^\"()\n\r]+\\)(\\([0-9]+\\))\\S-"))
-      (let* ((file (match-string-no-properties 2))
-             (line-num (match-string-no-properties 3))
-             (but-label (concat file ":" line-num)))
-        (setq line-num (string-to-number line-num))
-        (ibut:label-set but-label (match-beginning 2) (match-end 2))
-        (hact 'link-to-file-line file line-num)))
+     ;; Don't wrap this next line in (hact) since has hact call
+     ;; in the function itself.
+     ((hib-python-traceback))
 
      ;; JavaScript traceback
      ((or (looking-at "[a-zA-Z0-9-:.()? ]+? +at \\([^() \t]+\\) (\\([^:, 
\t()]+\\):\\([0-9]+\\):\\([0-9]+\\))$")
@@ -1012,16 +1037,7 @@ This works with JavaScript and Python tracebacks, gdb, 
dbx, and xdb.  Such lines
              (but-label (concat file ":" line-num)))
         (setq line-num (string-to-number line-num))
         (ibut:label-set but-label)
-        (hact 'link-to-file-line file line-num)))
-
-     ((not (boundp 'debugger-source-prior-line))
-      ;; In Python tracebacks, may be on a line just below the source
-      ;; reference line so if not on a Hyperbole button, move back a
-      ;; line and check for a source line again.
-      (let ((debugger-source-prior-line t))
-       (unless (or (hbut:at-p) (/= (forward-line -1) 0))
-         ;; Don't wrap this next line in (hact) or will break things.
-         (ibtypes::debugger-source)))))))
+        (hact 'link-to-file-line file line-num))))))
 
 ;;; ========================================================================
 ;;; Displays files at specific lines and optional column number
diff --git a/hmouse-tag.el b/hmouse-tag.el
index 6493abe..a49cf04 100644
--- a/hmouse-tag.el
+++ b/hmouse-tag.el
@@ -560,6 +560,9 @@ Excludes character matching square brackets, so may be used 
with skip-characters
 
 (defun smart-lisp (&optional show-doc)
   "Jump to the definition of any selected Lisp identifier or optionally 
SHOW-DOC.
+
+Assume caller has checked that (smart-emacs-lisp-mode-p) is true.
+
 If on an Emacs Lisp require, load, or autoload clause and the
 `find-library' function from the \"load-library\" package has
 been loaded, this jumps to the library source whenever possible.
@@ -576,7 +579,7 @@ pressed in an appropriate buffer and has moved the cursor 
to the selected
 buffer."
 
   (interactive)
-  (unless (and (smart-emacs-lisp-mode-p) (fboundp 'find-library)
+  (unless (and (fboundp 'find-library)
               ;; Handle Emacs Lisp `require', `load', and `autoload' clauses.
               (let ((opoint (point))
                     type
@@ -606,30 +609,40 @@ buffer."
                         (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))
+    (let* ((elisp-flag (smart-emacs-lisp-mode-p))
           (tag (smart-lisp-at-tag-p t))
           (tag-sym (intern-soft tag)))
-      (cond ((and show-doc elisp-p)
+      (cond ((and show-doc elisp-flag)
             ;; Emacs Lisp function, variable and face documentation display.
             (cond ((fboundp tag-sym) (describe-function tag-sym))
                   ((and tag-sym (boundp tag-sym)) (describe-variable tag-sym))
                   ((facep tag-sym) (describe-face tag-sym))
                   (t (error "(smart-lisp): `%s' unbound symbol definition not 
found" tag))))
-           ((and elisp-p (fboundp 'find-function-noselect)
+           ((and elisp-flag (fboundp 'find-function-noselect)
                  (let ((result (smart-lisp-bound-symbol-def tag-sym)))
                    (when (cdr result)
                      (hpath:display-buffer (car result))
                      (goto-char (cdr result))
                      t))))
-           (t (condition-case ()
-                  ;; Tag of any language
-                  (and (featurep 'etags) (smart-tags-display tag show-doc))
-                (error (unless (and elisp-p (stringp smart-emacs-tags-file)
-                                    (condition-case ()
-                                        (smart-tags-display
-                                         tag show-doc (list 
smart-emacs-tags-file))
-                                      (error nil)))
-                         (error "(smart-lisp): `%s' definition not found in 
any tag table" tag)))))))))
+           ;; If elisp-flag is true, then make xref use tags tables to
+           ;; find symbols not yet loaded into Emacs; otherwise, use
+           ;; standard xref backends for the current language.
+           (t (let ((etags-mode (and elisp-flag (boundp 'xref-etags-mode) 
xref-etags-mode)))
+                (unwind-protect
+                    (progn
+                      (and (not etags-mode) elisp-flag (fboundp 
'xref-etags-mode)
+                           (xref-etags-mode 1))
+                      (condition-case ()
+                          ;; Tag of any language
+                          (and (featurep 'etags) (smart-tags-display tag 
show-doc))
+                        (error (unless (and elisp-flag (stringp 
smart-emacs-tags-file)
+                                            (condition-case ()
+                                                (smart-tags-display
+                                                 tag show-doc (list 
smart-emacs-tags-file))
+                                              (error nil)))
+                                 (error "(smart-lisp): No definition found for 
`%s'" tag)))))
+                  (and (not etags-mode) elisp-flag (fboundp 'xref-etags-mode)
+                       (xref-etags-mode 0)))))))))
 
 (defun smart-lisp-at-definition-p ()
     "Return t when point is in a non-help buffer on the first line of a 
non-alias Lisp definition, else nil."
@@ -659,7 +672,7 @@ Returns matching ELisp tag name that point is within, else 
nil."
           (string-match "[^-]-[^-]" identifier)))))
 
 (defun smart-lisp-at-tag-p (&optional no-flash)
-  "Return Lisp tag name that point is within, else nil.
+  "Return possibly non-existent Lisp tag name that point is within, else nil.
 Return nil when point is on the first line of a non-alias Lisp definition."
   (unless (smart-lisp-at-definition-p)
     (save-excursion
@@ -1279,11 +1292,13 @@ See the \"${hyperb:dir}/smart-clib-sym\" script for 
more information."
       found)))
 
 (defun smart-tags-display (tag next &optional list-of-tags-tables)
-  (if next (setq tag nil))
+  (when  next (setq tag nil))
   (let* ((tags-table-list (or list-of-tags-tables
                              (and (boundp 'tags-table-list)
                                   (nconc (smart-tags-file-list) 
tags-table-list))
                              (smart-tags-file-list)))
+        ;; Identifier searches should almost always be case-sensitive today
+        (tags-case-fold-search nil)
         (func (smart-tags-noselect-function))
         (tags-file-name (if tags-table-list
                             nil
@@ -1299,9 +1314,7 @@ See the \"${hyperb:dir}/smart-clib-sym\" script for more 
information."
     ;; For InfoDock (XEmacs may also take this branch), force exact match
     ;; when `next' is false (otherwise tag would = nil and the following
     ;; stringp test would fail).
-    (if (featurep 'infodock)
-       (if (stringp tag)
-           (setq tag (list tag))))
+    (and (featurep 'infodock) (stringp tag) (setq tag (list tag)))
     (if (and func (setq find-tag-result (funcall func tag)))
        (cond ((eq func 'find-tag-internal)
               ;; InfoDock and XEmacs
@@ -1318,10 +1331,12 @@ See the \"${hyperb:dir}/smart-clib-sym\" script for 
more information."
               ;; Emacs with some unknown version of tags.
               ;; Signals an error if tag is not found which is caught by
               ;; many callers of this function.
-              (with-no-warnings (find-tag tag))))
+              ;; Find exact identifier matches only.
+              (with-no-warnings (find-tag (concat "\\`" (regexp-quote tag) 
"\\'") nil t))))
       ;; Signals an error if tag is not found which is caught by
       ;; many callers of this function.
-      (with-no-warnings (find-tag tag)))))
+      ;; Find exact identifier matches only.
+      (with-no-warnings (find-tag (concat "\\`" (regexp-quote tag) "\\'") nil 
t)))))
 
 ;;;###autoload
 (defun smart-tags-file-path (file)
diff --git a/hsys-org.el b/hsys-org.el
index d362fe6..38cef0d 100644
--- a/hsys-org.el
+++ b/hsys-org.el
@@ -26,7 +26,7 @@
 (defcustom hsys-org-enable-smart-keys 'buttons
   "This option applies only in Org major/minor modes when hyperbole-mode is 
active.
 The following table shows what the Smart Keys do in various contexts
-with different settings of this option.  For example, a nil value make
+with different settings of this option.  For example, a nil value makes
 {M-RET} operate as it normally does within Org mode contexts.
 
 
|---------------------+-------------------+------------------+----------+------------------|
diff --git a/hyrolo.el b/hyrolo.el
index 9d82e7e..45af82b 100644
--- a/hyrolo.el
+++ b/hyrolo.el
@@ -76,18 +76,20 @@ executable must be found as well (for Oauth security)."
        ;; If no gpg encryption executable, Oauth login to Google will fail.
        (or (executable-find "gpg2") (executable-find "gpg"))))
 
+'("~/.rolo.otl" "~/.rolo.org" "c:/_rolo.otl")
+
 ;;;###autoload
 (defun hyrolo-initialize-file-list ()
   "Initialize the list of files used for HyRolo search."
   (interactive)
   (let* ((gcontacts (if (hyrolo-google-contacts-p) 
google-contacts-buffer-name))
         (ms "c:/_rolo.otl")
-        (unix "~/.rolo.otl")
+        (posix "~/.rolo.otl")
         (list (delq nil (if (and (boundp 'bbdb-file) (stringp bbdb-file))
                             (if hyperb:microsoft-os-p
                                 (list ms bbdb-file gcontacts)
                               (list  "~/.rolo.otl" bbdb-file gcontacts))
-                          (if hyperb:microsoft-os-p (list ms gcontacts) (list 
unix gcontacts))))))
+                          (if hyperb:microsoft-os-p (list ms gcontacts) (list 
posix gcontacts))))))
     (setq hyrolo-file-list list)
     (when (called-interactively-p 'interactive)
       (message "HyRolo Search List: %S" list))
diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el
index e47e51b..18d141a 100644
--- a/kotl/kotl-mode.el
+++ b/kotl/kotl-mode.el
@@ -599,6 +599,12 @@ With optional prefix argument TOP-P non-nil, refill all 
cells in the outline."
 
 (defalias 'kotl-mode:kill-visual-line 'kotl-mode:kill-line)
 
+(defun kotl-mode:kill-whole-line (&optional arg)
+  "Kill ARG lines from point."
+  (interactive "*P")
+  (let ((kill-whole-line t))
+    (kotl-mode:kill-line arg)))
+
 (defun kotl-mode:kill-region (start end &optional copy-p)
   "Kill region between START and END within a single kcell.
 With optional COPY-P equal to 't, copy region to kill ring but does not
@@ -3131,6 +3137,7 @@ Leave point at end of line now residing at START."
        kill-word
        kill-line
        kill-visual-line
+       kill-whole-line
        kill-region
        kill-ring-save
        kill-sentence



reply via email to

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