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

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

[elpa] externals/hyperbole 1a85b83 10/53: * DEMO (Git References): Added


From: Robert Weiner
Subject: [elpa] externals/hyperbole 1a85b83 10/53: * DEMO (Git References): Added.
Date: Wed, 15 Nov 2017 22:46:59 -0500 (EST)

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

    * DEMO (Git References): Added.
      hib-social.el (hibtypes-github-default-project): Renamed from 
hibtypes-social-github-default-project.
                    (hibtypes-github-default-user): Renamed from 
hibtypes-social-githbu-default-user.
                (hibtypes-git-default-project): Added.
                (hibtypes-git-*, git-reference): Updated to allow
        git#project/commit-hashtag references.  So now all of the
        following are recognized as local git references if the default
        project setting is set up:
          git#hyperbole/5ae3550    (project name and commit hashtag can be 
given; commit diff displayed)
          gt#5ae3550               (project default is used; commit diff 
displayed)
          gt#/hyperbole            (project home directory is displayed)
                    (github-reference): Renamed from github-commit-reference.  
Also added support for syntax:
          gh#/hyperbole            (project home directory is displayed; uses 
default user setting)
          gh#/rswgnu/hyperbole     (project home directory is displayed)
    
        Requires GNU locate for finding all local git repositories.
    
    * hibtypes.el (grep-msg): Added match to context lines produced by 'grep 
-A<num>'
        which use '-' around the line number rather than ':'.
        (hib-debbugs): Lowered priority below hib-social so it doesn't shadow 
valid
           social references since it matching is broad.
    
    * hib-social.el (social-reference, hibtypes-social-regexp): Added missing 
'-'
        character in social-reference matches.
    
    * hui-mouse.el (smart-image-dired-thumbnail, 
smart-image-dired-thumbnail-assist):
        Added to support browsing of directories of images via thumbnails.
        Action Key displays a scaled version of the original image in an Emacs 
window.
        Assist Key displays the original image in an external viewer.
---
 Changes        |  32 ++++++++
 DEMO           |  31 ++++++--
 hib-debbugs.el |   1 -
 hib-social.el  | 238 +++++++++++++++++++++++++++++++++++++++++++++++----------
 hibtypes.el    |  21 ++---
 hpath.el       |   2 +-
 hui-mouse.el   | 199 +++++++++++++++++++++++++----------------------
 7 files changed, 373 insertions(+), 151 deletions(-)

diff --git a/Changes b/Changes
index d645ec2..3996e62 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,35 @@
+2017-09-20  Bob Weiner  <address@hidden>
+
+* DEMO (Git References): Added.
+  hib-social.el (hibtypes-github-default-project): Renamed from 
hibtypes-social-github-default-project.
+                (hibtypes-github-default-user): Renamed from 
hibtypes-social-githbu-default-user.
+               (hibtypes-git-default-project): Added.
+               (hibtypes-git-*, git-reference): Updated to allow
+    git#project/commit-hashtag references.  So now all of the
+    following are recognized as local git references if the default
+    project setting is set up:
+      git#hyperbole/5ae3550    (project name and commit hashtag can be given; 
commit diff displayed)
+      gt#5ae3550               (project default is used; commit diff displayed)
+      gt#/hyperbole            (project home directory is displayed)
+                (github-reference): Renamed from github-commit-reference.  
Also added support for syntax:
+      gh#/hyperbole            (project home directory is displayed; uses 
default user setting)
+      gh#/rswgnu/hyperbole     (project home directory is displayed)
+
+    Requires GNU locate for finding all local git repositories.
+
+* hibtypes.el (grep-msg): Added match to context lines produced by 'grep 
-A<num>'
+    which use '-' around the line number rather than ':'.
+    (hib-debbugs): Lowered priority below hib-social so it doesn't shadow valid
+       social references since it matching is broad.
+
+* hib-social.el (social-reference, hibtypes-social-regexp): Added missing '-'
+    character in social-reference matches.
+
+* hui-mouse.el (smart-image-dired-thumbnail, 
smart-image-dired-thumbnail-assist):
+    Added to support browsing of directories of images via thumbnails.
+    Action Key displays a scaled version of the original image in an Emacs 
window.
+    Assist Key displays the original image in an external viewer.
+
 2017-09-19  Bob Weiner  <address@hidden>
 
 * hib-social.el (hibtypes-social-default-service): Changed to use a radio
diff --git a/DEMO b/DEMO
index f9a6e42..459ab26 100644
--- a/DEMO
+++ b/DEMO
@@ -459,25 +459,44 @@ at instagram.  Try pressing the Action Key on these if 
you like.
 
 The file "hib-social.el" has more details on this.
 
-** Github Commit Hashtags and Usernames
+** Github (Remote) References
 
 For software developers who use Github for publishing and version control,
 Github links are similar to social media links but reference specific Github
-web pages.
+web pages.  Hyperbole automatically locates all your local git repository
+directories and indexes them for later use.
 
 Press the Action Key on address@hidden to go to RSW's gihub home page.
 address@hidden works too. 
 
+References to project home pages look like this (the / is required):
+  github#/hyperbole           (uses user default setting)
+  github#/rswgnu/hyperbole
+
 References to specific commits use the # hash symbol and short versions
 of the git commit hash code:
   gh#rswgnu/hyperbole/5ae3550 (if include user, must include project)
   github#hyperbole/5ae3550    (project can be given with user default)
   gh#5ae3550                  (user and project defaults are used)
 
-An Action Key presses on the first one will work because user, project
-and commit hash code are all included.  The second and third versions
-require the setup of default values as explained in
-"(hyperbole)github-reference".
+An Action Key presses on the first commit reference above will work
+because user, project and commit hash code are all included.  The
+second and third versions require the setup of default values as
+explained in "(hyperbole)github-reference".
+
+** Git (Local) References
+
+Similarly, again for software developers, git references work on local
+git repositories.
+
+  git#/hyperbole         (displays the top directory of the hyperbole 
repository)
+  git#/hyperbole/55a1f0  (displays hyperbole git commit diff)
+  gt#55a1f0              (when within a git repo, displays its commit diff)
+
+The first two examples work anywhere regardless of the buffer since Hyperbole
+locates all git repositories for you by repository/project name.  If you set a
+default project (see "(hyperbole)git-reference"), then the third example will
+work anywhere as well.
 
 ** Grep, Occurrence, Debugger and Compiler Error Buttons, and Cscope Analyzer
    Lines
diff --git a/hib-debbugs.el b/hib-debbugs.el
index f3e80d4..bbdcd40 100644
--- a/hib-debbugs.el
+++ b/hib-debbugs.el
@@ -88,7 +88,6 @@ If the query includes a single id number, displays the 
original message
 submission for that id and allows browsing of the followup discussion.
 The following buffer text formats are accepted (with point prior to any
 attribute): 
-   id-number
    #id-number
    bug#id-number or bug# id-number or bug #id-number
    bug?attr1=val1&attr2=val2&attr3=val3
diff --git a/hib-social.el b/hib-social.el
index fda669f..e004d92 100644
--- a/hib-social.el
+++ b/hib-social.el
@@ -14,11 +14,11 @@
 ;;   This defines an implicit button type, social-reference, that displays 
 ;;   the web page associated with the given hashtag or username.
 ;;
-;;   A hashtag reference is either: [facebook|instagram|twitter]?#<hashtag>
-;;   or [fb|in|tw]?#<hashtag>.
+;;   A hashtag reference is either: 
[facebook|git|github|instagram|twitter]?#<hashtag>
+;;   or [fb|gh|gt|in|tw]?#<hashtag>.
 ;;
-;;   A username reference is either: [facebook|instagram|twitter]?@<username>
-;;   or [fb|in|tw]?@<username>.
+;;   A username reference is either: 
[facebook|github|instagram|twitter]?@<username>
+;;   or [fb|gh|in|tw]?@<username>.
 ;;
 ;;   If the social media service is not given, it defaults to \"twitter\".
 
@@ -38,6 +38,7 @@
 (defcustom hibtypes-social-default-service "twitter"
   "Lowercase string matching the name of the default social media service to 
use when none is specified."
   :type '(radio (const "facebook")
+               (const "git")
                (const "github")
                (const "instagram")
                (const "twitter"))
@@ -48,12 +49,17 @@
   :type 'function
   :group 'hyperbole-button)
 
-(defcustom hibtypes-social-github-default-project nil
+(defcustom hibtypes-git-default-project nil
+  "Default project name to associate with any local git commit link."
+  :type 'string
+  :group 'hyperbole-button)
+
+(defcustom hibtypes-github-default-project nil
   "Default project name to associate with any Github commit link."
   :type 'string
   :group 'hyperbole-button)
 
-(defcustom hibtypes-social-github-default-user nil
+(defcustom hibtypes-github-default-user nil
   "Default user name to associate with any Github commit link."
   :type 'string
   :group 'hyperbole-button)
@@ -65,10 +71,11 @@
 (defconst hibtypes-social-hashtag-alist
   '(("\\`\\(fb\\|facebook\\)\\'"  . "https://www.facebook.com/hashtag/%s";)
     ("\\`\\(gh\\|github\\)\\'"    . "https://github.com/%s/%s/commit/%s";)
+    ("\\`\\(gt\\|git\\)\\'"       . "(cd %s; git show %s)")
     ("\\`\\(in\\|instagram\\)\\'" . 
"https://www.instagram.com/explore/tags/%s/";)
     ("\\`\\(tw\\|twitter\\)\\'"   . 
"https://twitter.com/search?q=%%23%s&src=hashtag";)
 )
-  "Alist of (social-media-service-regexp  . url-with-%s-for-hashtag) 
elements.")
+  "Alist of (social-media-service-regexp  . 
expression-to-display-hashtag-reference) elements.")
 
 (defconst hibtypes-social-username-alist
   '(("\\`\\(fb\\|facebook\\)\\'"  . "https://www.facebook.com/%s";)
@@ -78,7 +85,7 @@
     )
   "Alist of (social-media-service-regexp  . url-with-%s-for-username) 
elements.")
 
-(defconst hibtypes-social-regexp 
"\\([[:alpha:]]*\\)\\(address@hidden)\\([[:alnum:]]*[._/[:alnum:]]*[_[:alnum:]]\\)"
+(defconst hibtypes-social-regexp 
"\\([[:alpha:]]*\\)\\(address@hidden)\\(/?[[:alnum:]]*[-._/[:alnum:]]*[-_[:alnum:]]\\)"
   "Regular expression that matches a social media hashtag or username 
reference.
 See `ibtypes::social-reference' for format details.")
 
@@ -90,16 +97,18 @@ See `ibtypes::social-reference' for format details.")
 ;;; ************************************************************************
 
 (defib social-reference ()
-  "Displays the web page associated with a social media hashtag or username 
reference at point.
+  "Displays the web page associated with a social hashtag or username 
reference at point.
 Reference format is:
-  [facebook|instagram|address@hidden<hashtag-or-username> or
-  [fb|in|address@hidden<hashtag-or-username>.
+  [facebook|git|github|instagram|address@hidden<reference> or
+  [fb|gt|gh|in|address@hidden<reference>.
 
 The first part of the label for a button of this type is the social
-media service name.  The service name defaults to the value of
+service name.  The service name defaults to the value of
 `hibtypes-social-default-service' (default value of \"twitter\")
 when not given, so #hashtag would be the same as twitter#hashtag.
 
+Local git references allow hashtags only, not username references.
+
 This will not match within any single line, single or
 double-quoted strings or within any buffer whose major mode is
 listed in `hibtypes-social-inhibit-modes'."
@@ -110,54 +119,199 @@ listed in `hibtypes-social-inhibit-modes'."
                      (and (eq major-mode 'markdown-mode)
                           (hargs:delimited "(" ")"))))
             (save-excursion
-              (if (looking-at "[#@/._[:alnum:]]")
-                  (skip-chars-backward "#@/._[:alnum:]"))
+              (if (looking-at "[-#@/._[:alnum:]]")
+                  (skip-chars-backward "-#@/._[:alnum:]"))
               (and (looking-at hibtypes-social-regexp)
+                   ;; Ensure prefix matches to a social web service
+                   (save-match-data
+                     (let ((ref (match-string-no-properties 1)))
+                       (delq nil (mapcar (lambda (regexp) (string-match regexp 
ref))
+                                         (mapcar #'car 
hibtypes-social-hashtag-alist)))))
                    (save-match-data
                      ;; Heuristic to ensure this is not an email address
                      (not (and (looking-at mail-address-regexp)
                                (let ((case-fold-search t))
                                  (string-match mail-address-tld-regexp
                                                (match-string-no-properties 
1)))))))))
+
     (save-match-data
       (ibut:label-set (match-string-no-properties 0) (match-beginning 0) 
(match-end 0)))
-    (if (save-match-data (and (equal (match-string-no-properties 2) "#")
-                             (string-match "\\`\\(gh\\|github\\)\\'" 
(match-string-no-properties 1))))
-       (hact 'github-commit-reference (match-string-no-properties 3))
-      (hact 'social-reference (match-string-no-properties 1)
-           (match-string-no-properties 2) (match-string-no-properties 3)))))
-
-(defact github-commit-reference (commit-hashtag &optional user project)
-  "Display the Github web page showing a commit given by COMMIT-HASHTAG and 
optional USER and PROJECT.
-USER defaults to the value of `hibtypes-social-github-default-user'.
-PROJECT defaults to the value of `hibtypes-social-github-default-project'."
-  (if (or (null commit-hashtag) (string-empty-p commit-hashtag))
-      (error "(github-commit-reference): Github commit hashtag must not be 
empty")
-    (let ((case-fold-search t)
-         (url-to-format (assoc-default "github" hibtypes-social-hashtag-alist 
#'string-match)))
-      (when url-to-format
-       (when (string-match 
"\\(\\([^/address@hidden)/\\)?\\([^/address@hidden)/" commit-hashtag)
-         (setq user (or (match-string-no-properties 2 commit-hashtag) user)
-               project (or (match-string-no-properties 3 commit-hashtag) 
project)
-               commit-hashtag (substring commit-hashtag (match-end 0))))
-       (unless (stringp user) (setq user hibtypes-social-github-default-user))
-       (unless (stringp project) (setq project 
hibtypes-social-github-default-project))
-       (when (and  (stringp user) (stringp project))
-         (funcall hibtypes-social-display-function
-                  (format url-to-format user project commit-hashtag)))))))
+    (let ((ref (match-string-no-properties 0))
+         (service (match-string-no-properties 1))
+         (ref-type-str (match-string-no-properties 2))
+         (after-hash-str (match-string-no-properties 3)))
+      (cond ((string-match "\\`\\(gt\\|git\\)#" ref)
+            (hact 'git-reference after-hash-str))
+           ((string-match "\\`\\(gh\\|github\\)#" ref)
+            (hact 'github-reference after-hash-str))
+           (t (hact 'social-reference service ref-type-str after-hash-str))))))
 
 (defact social-reference (service ref-type-str hashtag-or-username)
   "Display the web page at social media SERVICE for REF-TYPE-STR and 
HASHTAG-OR-USERNAME.
 REF-TYPE-STR is either \"#\" for a hashtag reference or \"@\" for a username 
reference."
   (if (or (null service) (equal service "")) (setq service 
hibtypes-social-default-service))
   (let ((case-fold-search t)
-       url-to-format)
+       expr-to-format)
     (when (or (and (equal ref-type-str "#")
-                  (setq url-to-format
+                  (setq expr-to-format
                         (assoc-default service hibtypes-social-hashtag-alist 
#'string-match)))
              (and (equal ref-type-str "@")
-                  (setq url-to-format
+                  (setq expr-to-format
                         (assoc-default service hibtypes-social-username-alist 
#'string-match))))
-      (funcall hibtypes-social-display-function (format url-to-format 
hashtag-or-username)))))
+      (if expr-to-format
+         (funcall hibtypes-social-display-function (format expr-to-format 
hashtag-or-username))
+       (error "(social-reference): Service `%s' does not support reference 
format, `%s%s'"
+              service ref-type-str hashtag-or-username)))))
+
+;;; Remote Github commit references
+
+(defact github-reference (reference &optional user project)
+  "Display the Github entity associated with REFERENCE and optional  USER and 
PROJECT.
+REFERENCE is of the form:
+    <commit-hashtag>
+    <user>/<project>/<commit-hashtag>
+    <project>/<commit-hashtag>
+or  /<project>.
+USER defaults to the value of `hibtypes-github-default-user'.
+If given, PROJECT overrides any project value in REFERENCE.  If no
+PROJECT value is provided, it defaults to the value of
+`hibtypes-github-default-project'."
+  (if (or (null reference) (equal reference ""))
+      (error "(github-reference): Github commit hashtag must not be empty")
+    (let ((case-fold-search t)
+         (url-to-format (assoc-default "github" hibtypes-social-hashtag-alist 
#'string-match)))
+      (when url-to-format
+       (cond ((string-match 
"\\`/?\\(\\([^/address@hidden)/\\)?\\([^/address@hidden)/\\([0-9a-fA-F]+\\)\\'" 
reference)
+              ;; /?[user/]project/hashcode
+              (setq user (or user (match-string-no-properties 2 reference))
+                    project (or project (match-string-no-properties 3 
reference))
+                    reference (match-string-no-properties 4 reference)))
+             ((string-match 
"\\`/?\\(\\([^/address@hidden)/\\)\\([^/address@hidden)\\'" reference)
+              ;; /?user/project
+              (setq user (or user (match-string-no-properties 2 reference))
+                    project (or project (match-string-no-properties 3 
reference))
+                    reference nil))
+             ((string-match "\\`/\\([^/address@hidden)\\'" reference)
+              ;; /project
+              (setq project (or project (match-string-no-properties 1 
reference))
+                    reference nil)))
+       (unless (stringp user) (setq user hibtypes-github-default-user))
+       (unless (stringp project) (setq project 
hibtypes-github-default-project))
+       (if (and  (stringp user) (stringp project))
+           (funcall hibtypes-social-display-function
+                    (if reference
+                        (format url-to-format user project reference)
+                      (format "https://github.com/%s/%s"; user project)))
+         (cond ((and (null user) (null project))
+                (error "(github-reference): Set `hibtypes-github-default-user' 
and `hibtypes-github-default-project'"))
+               ((null user)
+                (error "(github-reference): Set 
`hibtypes-github-default-user'"))
+               (t
+                (error "(github-reference): Set 
`hibtypes-github-default-project'"))))))))
+
+;;; Local git repository commit references
+
+(defvar hibtypes-git-repos-cache 
+  (expand-file-name "Local-Git-Repos" hbmap:dir-user)
+  "Filename of cache of local git repository directories found by 
`locate-command'.")
+
+(defun hibtypes-git-build-repos-cache (&optional prompt-flag)
+  "Store cache of local git repo directories in `hibtypes-git-repos-cache'.
+With optional prompt-flag non-nil, prompt user whether to build the cache 
before building.
+Return t if built, nil otherwise."
+  (when (or (not prompt-flag)
+           (y-or-n-p "Find all local git repositories (will take some time)?"))
+    (message "Please wait while all local git repositories are found...")
+    (unless (zerop (shell-command (format "%s -r \.git$ | sed -e 's+/.git$++' 
> %s"
+                                         (if (and (boundp 'locate-command) 
(string-match "locate" locate-command))
+                                             locat-command
+                                           "locate")
+                                         hibtypes-git-repos-cache)))
+      (error "(hibtypes-git-build-repos-cache): Cache build failed; 
`locate-command' must accept `-r' argument for regexp matching"))
+    (message "Please wait while all local git repositories are found...Done")
+    t))
+
+(defun hibtypes-git-project-directory (project-name)
+  "Given git PROJECT-NAME, return local git repository directory or nil if 
none found."
+  (if (or (and (file-readable-p hibtypes-git-repos-cache)
+              ;; Non-zero file size
+              (not (zerop (nth 7 (file-attributes hibtypes-git-repos-cache)))))
+         (hibtypes-git-build-repos-cache t))
+      ;; echo -n deletes trailing newline
+      (shell-command-to-string (format "echo -n `grep -m1 '/%s$' %s`" 
project-name hibtypes-git-repos-cache))
+    (message "")
+    nil))
+
+;; Pseudo-code for next action definition:
+;;  1. If within a git repo directory, use that repo unless specified in path
+;;  2. If project name is given or is default, see if assocated repo dir is in 
cache and use it.
+;;  3. Prompt to rebuild locate db and then goto 2 if yes else quit
+;;  4. Run: (cd <dir-found>; git show <commit-hashcode>)
+;;  5. Otherwise, do nothing.
+(defact git-reference (reference &optional project)
+  "Display the git entity associated with REFERENCE and optional PROJECT.
+REFERENCE is of the form:
+    <commit-hashtag>
+    /?<project>/<commit-hashtag>
+or  /<project>.
+If given, PROJECT overrides any project value in REFERENCE.  If no
+PROJECT value is provided, it defaults to the value of
+`hibtypes-git-default-project'."
+  (if (or (null reference) (equal reference ""))
+      (error "(git-reference): Git commit hashtag must not be empty")
+    (let ((case-fold-search t)
+         (shell-cmd-to-format (assoc-default "git" 
hibtypes-social-hashtag-alist #'string-match)))
+      (when shell-cmd-to-format
+       (cond ((string-match "\\`/?\\([^/address@hidden)/\\([0-9a-fA-F]+\\)\\'" 
reference)
+              ;; /?project/hashtag
+              (setq project (or project (match-string-no-properties 1 
reference))
+                    reference (match-string-no-properties 2 reference)))
+             ((string-match "\\`/\\([^/address@hidden)\\'" reference)
+              ;; /project
+              (setq project (or project (match-string-no-properties 1 
reference))
+                    reference nil))
+             ((string-match "/.*/" reference)
+              ;; Invalid user/project/hashtag
+              (error "(git-reference): Username or path not allowed, only 
<project>/<commit hashtag>")))
+       (let ((cmd)
+             ;; `project' now may be a project directory or a project name.
+             ;; If a project name:
+             ;;   If reference is within a git project, use its project 
directory.
+             ;;   Otherwise, look up the project in Hyperbole's local git repo 
directory cache;
+             ;;   the user is prompted to have it built when necessary.
+             (project-dir (or (and project (file-readable-p project) 
(file-directory-p project) project)
+                              (locate-dominating-file default-directory 
".git"))))
+         (unless (stringp project)
+           (unless (setq project (cond (project-dir (file-name-nondirectory 
(directory-file-name project-dir)))
+                                       ((stringp hibtypes-git-default-project)
+                                        hibtypes-git-default-project)))
+             (error "(git-reference): Set `hibtypes-git-default-project' to a 
default project name")))
+         (unless project-dir (setq project-dir (and project 
(hibtypes-git-project-directory project))))
+         (if (or (null project-dir) (equal project-dir ""))
+             (if (and project
+                      ;; Maybe the Hyperbole git project cache is
+                      ;; out-of-date and needs to be rebuilt.  Prompt
+                      ;; user and if rebuilt, continue.
+                      (hibtypes-git-build-repos-cache t))
+                 (setq project-dir (and project 
(hibtypes-git-project-directory project)))
+               (error "(git-reference): No git directory found for project 
`%s'" project)))
+         (if (equal project-dir "") (setq project-dir nil))
+         (cond ((and project-dir (file-readable-p project-dir) 
(file-directory-p project-dir))
+                (if reference
+                    ;; Display commit diffs in a help buffer
+                    ;; Ensure these do not invoke with-output-to-temp-buffer a 
second time.
+                    (let ((temp-buffer-show-hook)
+                          (temp-buffer-show-function))
+                      (setq cmd (format shell-cmd-to-format project-dir 
reference))
+                      (with-help-window (format "*git %s commit %s*" project 
reference)
+                        (princ (format "Command: %s\n\n" cmd))
+                        (princ (shell-command-to-string cmd))))
+                  ;; Project-only reference, run dired on the project home 
directory
+                  (hpath:display-buffer (dired-internal-noselect
+                                         (file-name-as-directory 
project-dir)))))
+               (t (if project-dir
+                      (error "(git-reference): git project `%s' directory is 
unreadable or invalid: \"%s\""
+                             project project-dir)
+                    (error "(git-reference): No git project found for `%s'" 
project)))))))))
 
 (provide 'hib-social)
diff --git a/hibtypes.el b/hibtypes.el
index b96ecad..fcdb1dd 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -234,16 +234,16 @@ must have an attached file."
                     (hact 'annot-bib ref))))))
 
 ;;; ========================================================================
-;;; Handles social media hashtag and username references, e.g. 
twitter#myhashtag
+;;; Handles Gnu debbugs issue ids, e.g. bug#45678 or just 45678.
 ;;; ========================================================================
 
-(require 'hib-social)
+(require 'hib-debbugs)
 
 ;;; ========================================================================
-;;; Handles Gnu debbugs issue ids, e.g. bug#45678 or just 45678.
+;;; Handles social media hashtag and username references, e.g. 
twitter#myhashtag
 ;;; ========================================================================
 
-(require 'hib-debbugs)
+(require 'hib-social)
 
 ;;; ========================================================================
 ;;; Displays in-file Markdown link referents.
@@ -568,11 +568,10 @@ Messages are recognized in any buffer."
     (save-excursion
       (beginning-of-line)
       (if (or
-          ;; UNIX C compiler and Introl 68HC11 C compiler errors
-          (looking-at "\\([^ \t\n\r:]+\\): ?\\([0-9]+\\)[ :]")
+          ;; Grep matches, UNIX C compiler and Introl 68HC11 C compiler errors
+          (looking-at "\\([^ \t\n\r:]+\\): ?\\([1-9][0-9]*\\)[ :]")
           ;; HP C compiler errors
-          (looking-at
-           "[a-zA-Z0-9]+: \"\\([^\t\n\r\",]+\\)\", line \\([0-9]+\\):")
+          (looking-at "[a-zA-Z0-9]+: \"\\([^\t\n\r\",]+\\)\", line 
\\([0-9]+\\):")
           ;; BSO/Tasking 68HC08 C compiler errors
           (looking-at
            "[a-zA-Z 0-9]+: \\([^ \t\n\r\",]+\\) line \\([0-9]+\\)[ \t]*:")
@@ -589,8 +588,10 @@ Messages are recognized in any buffer."
           (looking-at "\\([^ \t\n\r:()]+\\)(\\([0-9]+\\)): ")
           ;; Microsoft JVC
           ;; file.java(6,1) : error J0020: Expected 'class' or 'interface'
-          (looking-at
-           "^\\(\\([a-zA-Z]:\\)?[^:\( \t\n\r-]+\\)[:\(][ \t]*\\([0-9]+\\),"))
+          (looking-at "^\\(\\([a-zA-Z]:\\)?[^:\( \t\n\r-]+\\)[:\(][ 
\t]*\\([0-9]+\\),")
+          ;; Grep match context lines (-A<num> option)
+          (and (string-match "grep\\|shell" (buffer-name))
+               (looking-at "\\([^ \t\n\r:]+\\)-\\([1-9][0-9]*\\)-")))
          (let* ((file (match-string-no-properties 1))
                 (line-num  (match-string-no-properties 2))
                 (but-label (concat file ":" line-num))
diff --git a/hpath.el b/hpath.el
index ee886b9..c3d631c 100644
--- a/hpath.el
+++ b/hpath.el
@@ -686,7 +686,7 @@ program)."
 
 (defun hpath:to-markup-anchor (hash anchor)
   "Move point to the definition of ANCHOR if found or if only HASH is non-nil, 
move to the beginning of the buffer."
-  (cond ((and (stringp anchor) (not (string-empty-p anchor)))
+  (cond ((and (stringp anchor) (not (equal anchor "")))
         (cond ((memq major-mode hui-select-markup-modes)
                ;; In HTML-like mode where link ids are case-sensitive.
                (let ((opoint (point))
diff --git a/hui-mouse.el b/hui-mouse.el
index 23a5fc4..d2db531 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -322,6 +322,9 @@ Its default value is #'smart-scroll-down."
     ((and (boundp 'hyrolo-display-buffer) (equal (buffer-name) 
hyrolo-display-buffer)) .
      ((smart-hyrolo) . (smart-hyrolo-assist)))
     ;;
+    ((eq major-mode 'image-dired-thumbnail-mode) .
+     ((smart-image-dired-thumbnail) . (smart-image-dired-thumbnail-assist)))
+    ;;
     ;; Gomoku game
     ((eq major-mode 'gomoku-mode) . 
      ((gomoku-human-plays) . (gomoku-human-takes-back)))
@@ -402,97 +405,6 @@ smart keyboard keys.")
       ref)))
 
 ;;; ************************************************************************
-;;; smart-helm functions
-;;; ************************************************************************
-
-(defun smart-helm-at-header ()
-  "Return t iff Action Mouse Key depress was on the first header line of the 
current buffer."
-  (or (helm-pos-header-line-p)
-      (and (eventp action-key-depress-args)
-          (eq (posn-area (event-start action-key-depress-args))
-              'header-line))))
-
-(defun smart-helm-line-has-action ()
-  "Marks and returns the actions for the helm selection item at point, or nil 
if line lacks any action.
-Assumes Hyperbole has already checked that point is in a helm buffer."
-  (if hkey-debug (setq cursor-type t))
-  (let ((helm-buffer (if (equal helm-action-buffer (buffer-name)) helm-buffer 
(buffer-name))))
-    (save-excursion
-      (with-helm-buffer
-       (when (not (or (eobp)
-                      (smart-helm-at-header)
-                      (helm-pos-candidate-separator-p)))
-         (helm-mark-current-line)
-         (helm-get-current-action))))))
-
-(defun smart-helm-alive-p ()
-  ;; Handles case where helm-action-buffer is visible but helm-buffer
-  ;; is not, which (helm-alive-p) doesn't handle.
-  (and (featurep 'helm)
-       helm-alive-p
-       (window-live-p (helm-window))
-       (minibuffer-window-active-p (minibuffer-window))))
-
-(defun smart-helm-resume-helm ()
-  "Resumes helm session for the current buffer if not already active."
-  (unless (smart-helm-alive-p)
-    (unless (equal helm-action-buffer (buffer-name))
-      ;; helm-resume doesn't seem to set this properly.
-      (setq helm-buffer (buffer-name)))
-    (helm-resume helm-buffer)
-    (sit-for 0.2)))
-
-(defun smart-helm()
-  "Executes helm actions based on Action Key click locations:
-  On a candidate line, performs the candidate's first action and remains in 
the minibuffer;
-  On the first header line, displays a list of actions available for the 
selected candidate;
-  On an action list line, performs the action after exiting the minibuffer;
-  At the end of the buffer, quits from helm and exits the minibuffer.
-  On a candidate separator line, does nothing.
-  In the minibuffer window, ends the helm session and performs the selected 
item's action."
-  (let ((non-text-area-p (and (eventp action-key-depress-args)
-                             (posn-area (event-start 
action-key-depress-args))))
-       (separator (helm-pos-candidate-separator-p))
-       (eob (eobp)))
-    (smart-helm-resume-helm)
-    (if (> (minibuffer-depth) 0)
-       (select-window (minibuffer-window)))
-    (when (and (smart-helm-alive-p) (not separator))
-      (let* ((key (kbd (cond
-                       (eob "C-g")
-                       ;; If line of the key press is the first /
-                       ;; header line in the window or outside the
-                       ;; buffer area, then use {TAB} command to
-                       ;; switch between match list and action list.
-                       (non-text-area-p "TAB")
-                       ;; RET: Performs action of selection and exits the 
minibuffer.
-                       ;; C-j: Performs action of selection and stays in 
minibuffer.
-                       (hkey-value
-                        (if (helm-action-window) "RET" "C-j"))
-                       (t "RET"))))
-            (binding (key-binding key)))
-       (if hkey-debug
-           (message "(HyDebug): In smart-helm, key to execute is: {%s}; 
binding is: %s"
-                    (key-description key) binding))
-       (call-interactively binding)))))
-
-(defun smart-helm-assist()
-  "Displays the selected item (including its action for the helm line at 
point."
-  (smart-helm-resume-helm)
-  ;; Hyperbole has checked that this line has an action prior
-  ;; to invoking this function.
-  (unwind-protect
-      (with-help-window "*Helm Help*"
-       (let ((helm-buffer (if (equal helm-action-buffer (buffer-name)) 
helm-buffer (buffer-name))))
-           (with-helm-buffer
-             (princ "The current helm selection item is:\n\t")
-             (princ (helm-get-selection (helm-buffer-get)))
-             (princ "\nwith an action of:\n\t")
-             (princ (helm-get-current-action)))))
-    (if (> (minibuffer-depth) 0)
-       (select-window (minibuffer-window)))))
-
-;;; ************************************************************************
 ;;; smart-buffer-menu functions
 ;;; ************************************************************************
 
@@ -861,6 +773,97 @@ If assist-key is pressed within:
        (t (smart-scroll-down))))
 
 ;;; ************************************************************************
+;;; smart-helm functions
+;;; ************************************************************************
+
+(defun smart-helm-at-header ()
+  "Return t iff Action Mouse Key depress was on the first header line of the 
current buffer."
+  (or (helm-pos-header-line-p)
+      (and (eventp action-key-depress-args)
+          (eq (posn-area (event-start action-key-depress-args))
+              'header-line))))
+
+(defun smart-helm-line-has-action ()
+  "Marks and returns the actions for the helm selection item at point, or nil 
if line lacks any action.
+Assumes Hyperbole has already checked that point is in a helm buffer."
+  (if hkey-debug (setq cursor-type t))
+  (let ((helm-buffer (if (equal helm-action-buffer (buffer-name)) helm-buffer 
(buffer-name))))
+    (save-excursion
+      (with-helm-buffer
+       (when (not (or (eobp)
+                      (smart-helm-at-header)
+                      (helm-pos-candidate-separator-p)))
+         (helm-mark-current-line)
+         (helm-get-current-action))))))
+
+(defun smart-helm-alive-p ()
+  ;; Handles case where helm-action-buffer is visible but helm-buffer
+  ;; is not; fixed in helm with commit gh#emacs-helm/helm/cc15f73.
+  (and (featurep 'helm)
+       helm-alive-p
+       (window-live-p (helm-window))
+       (minibuffer-window-active-p (minibuffer-window))))
+
+(defun smart-helm-resume-helm ()
+  "Resumes helm session for the current buffer if not already active."
+  (unless (smart-helm-alive-p)
+    (unless (equal helm-action-buffer (buffer-name))
+      ;; helm-resume doesn't seem to set this properly.
+      (setq helm-buffer (buffer-name)))
+    (helm-resume helm-buffer)
+    (sit-for 0.2)))
+
+(defun smart-helm()
+  "Executes helm actions based on Action Key click locations:
+  On a candidate line, performs the candidate's first action and remains in 
the minibuffer;
+  On the first header line, displays a list of actions available for the 
selected candidate;
+  On an action list line, performs the action after exiting the minibuffer;
+  At the end of the buffer, quits from helm and exits the minibuffer.
+  On a candidate separator line, does nothing.
+  In the minibuffer window, ends the helm session and performs the selected 
item's action."
+  (let ((non-text-area-p (and (eventp action-key-depress-args)
+                             (posn-area (event-start 
action-key-depress-args))))
+       (separator (helm-pos-candidate-separator-p))
+       (eob (eobp)))
+    (smart-helm-resume-helm)
+    (if (> (minibuffer-depth) 0)
+       (select-window (minibuffer-window)))
+    (when (and (smart-helm-alive-p) (not separator))
+      (let* ((key (kbd (cond
+                       (eob "C-g")
+                       ;; If line of the key press is the first /
+                       ;; header line in the window or outside the
+                       ;; buffer area, then use {TAB} command to
+                       ;; switch between match list and action list.
+                       (non-text-area-p "TAB")
+                       ;; RET: Performs action of selection and exits the 
minibuffer.
+                       ;; C-j: Performs action of selection and stays in 
minibuffer.
+                       (hkey-value
+                        (if (helm-action-window) "RET" "C-j"))
+                       (t "RET"))))
+            (binding (key-binding key)))
+       (if hkey-debug
+           (message "(HyDebug): In smart-helm, key to execute is: {%s}; 
binding is: %s"
+                    (key-description key) binding))
+       (call-interactively binding)))))
+
+(defun smart-helm-assist()
+  "Displays the selected item (including its action for the helm line at 
point."
+  (smart-helm-resume-helm)
+  ;; Hyperbole has checked that this line has an action prior
+  ;; to invoking this function.
+  (unwind-protect
+      (with-help-window "*Helm Help*"
+       (let ((helm-buffer (if (equal helm-action-buffer (buffer-name)) 
helm-buffer (buffer-name))))
+           (with-helm-buffer
+             (princ "The current helm selection item is:\n\t")
+             (princ (helm-get-selection (helm-buffer-get)))
+             (princ "\nwith an action of:\n\t")
+             (princ (helm-get-current-action)))))
+    (if (> (minibuffer-depth) 0)
+       (select-window (minibuffer-window)))))
+
+;;; ************************************************************************
 ;;; smart-hmail functions
 ;;; ************************************************************************
 
@@ -947,6 +950,20 @@ buffer and has moved the cursor to the selected buffer."
 (defalias 'smart-hyrolo-assist 'smart-hyrolo)
 
 ;;; ************************************************************************
+;;; smart-image-dired functions
+;;; ************************************************************************
+
+(defun smart-image-dired-thumbnail ()
+  "Selects thumbnail and scales its image for display in another Emacs window."
+  (image-dired-mouse-select-thumbnail action-key-release-args)
+  (image-dired-display-thumbnail-original-image))
+
+(defun smart-image-dired-thumbnail-assist ()
+  "Selects thumbnail and uses the external viewer named by 
`image-dired-external-viewer' to display it."
+  (image-dired-mouse-select-thumbnail assist-key-release-args)
+  (image-dired-thumbnail-display-external))
+
+;;; ************************************************************************
 ;;; smart-imenu functions
 ;;; ************************************************************************
 



reply via email to

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