branch: externals/hyperbole
commit fed154781c5bf75e81ab67889b005f4fd00e1a72
Author: Bob Weiner <[email protected]>
Commit: Bob Weiner <[email protected]>
* hib-social.el (hibtypes-social-default-service): Changed to use a radio
button choice when customizing this.
(hibtypes-social-hashtag-alist,
hibtypes-social-username-alist): Added
github user and commit lookup via social link syntax.
(hibtypes-social-github-default-user):
(hibtypes-social-github-default-project)
(github-commit-reference): Added this new action and its
above default values.
(hibtypes-social-regexp): Updated to allow
github#user/project/commit-hashtag references. So now all of the
following are recognized as github commit links if the default user
and project settings are set up:
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)
Additionally, gh@rswgnu can be used to jump to user rswgnu's github
home page.
DEMO (Github): Added to demonstrate github references.
* hibtypes.el (annot-bib): Moved in priority below social hashtags and
denied matching to anything containing a # or @ character so
[twitter@someuser] doesn't match as an annot-bib entry.
* hui-mouse.el (hkey-alist): Added helm support for Smart Key presses in
the minibuffer window (runs the standard RET command).
---
Changes | 30 ++++++++++++++++++++++++
DEMO | 25 +++++++++++++++++++-
hib-social.el | 75 +++++++++++++++++++++++++++++++++++++++++++++--------------
hibtypes.el | 30 +++++++++++++-----------
hui-menu.el | 2 +-
hui-mouse.el | 7 ++++--
6 files changed, 133 insertions(+), 36 deletions(-)
diff --git a/Changes b/Changes
index 44b7f55..d645ec2 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,36 @@
+2017-09-19 Bob Weiner <[email protected]>
+
+* hib-social.el (hibtypes-social-default-service): Changed to use a radio
+ button choice when customizing this.
+ (hibtypes-social-hashtag-alist,
hibtypes-social-username-alist): Added
+ github user and commit lookup via social link syntax.
+ (hibtypes-social-github-default-user):
+ (hibtypes-social-github-default-project)
+ (github-commit-reference): Added this new action and its
+ above default values.
+ (hibtypes-social-regexp): Updated to allow
+ github#user/project/commit-hashtag references. So now all of the
+ following are recognized as github commit links if the default user
+ and project settings are set up:
+ 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)
+
+ Additionally, gh@rswgnu can be used to jump to user rswgnu's github
+ home page.
+ DEMO (Github): Added to demonstrate github references.
+
+* hibtypes.el (annot-bib): Moved in priority below social hashtags and
+ denied matching to anything containing a # or @ character so
+ [twitter@someuser] doesn't match as an annot-bib entry.
+
+* hui-mouse.el (hkey-alist): Added helm support for Smart Key presses in
+ the minibuffer window (runs the standard RET command).
+
2017-09-18 Bob Weiner <[email protected]>
* hui-mouse.el (smart-helm): Finalized and added doc. of contexts and actions.
+ Made smart-helm ignore helm candidate separator lines.
* hui-window.el (smart-coords-in-window-p):
(hmouse-drag-window-side): Handled null value of coords.
diff --git a/DEMO b/DEMO
index 53d0a58..f9a6e42 100644
--- a/DEMO
+++ b/DEMO
@@ -1,3 +1,6 @@
+
+
+
* GNU Hyperbole Demonstration and Introduction by Bob Weiner
Welcome to GNU Hyperbole. Hyperbole will super-charge your GNU Emacs
@@ -441,7 +444,7 @@ includes your system information.
** Social Media Hashtags and Usernames
-An Action Key press a social media hashtag or username reference at point
+An Action Key press on a social media hashtag or username reference at point
displays the web page associated with the reference at the associated
service. References are of the form:
[facebook|instagram|twitter]?[#@]<hashtag-or-username> or
@@ -456,6 +459,26 @@ 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
+
+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.
+
+Press the Action Key on github@rswgnu to go to RSW's gihub home page.
+gh@rswgnu works too.
+
+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".
+
** Grep, Occurrence, Debugger and Compiler Error Buttons, and Cscope Analyzer
Lines
diff --git a/hib-social.el b/hib-social.el
index 62e441d..fda669f 100644
--- a/hib-social.el
+++ b/hib-social.el
@@ -37,7 +37,10 @@
(defcustom hibtypes-social-default-service "twitter"
"Lowercase string matching the name of the default social media service to
use when none is specified."
- :type 'string
+ :type '(radio (const "facebook")
+ (const "github")
+ (const "instagram")
+ (const "twitter"))
:group 'hyperbole-button)
(defcustom hibtypes-social-display-function #'browse-url
@@ -45,23 +48,37 @@
:type 'function
:group 'hyperbole-button)
+(defcustom hibtypes-social-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
+ "Default user name to associate with any Github commit link."
+ :type 'string
+ :group 'hyperbole-button)
+
;;; ************************************************************************
;;; Private variables
;;; ************************************************************************
(defconst hibtypes-social-hashtag-alist
- '(("\\`\\(fb\\|facebook\\)\\'" . "https://www.facebook.com/hashtag/%s")
- ("\\`\\(tw\\|twitter\\)\\'" .
"https://twitter.com/search?q=%%23%s&src=hashtag")
- ("\\`\\(in\\|instagram\\)\\'" .
"https://www.instagram.com/explore/tags/%s/"))
+ '(("\\`\\(fb\\|facebook\\)\\'" . "https://www.facebook.com/hashtag/%s")
+ ("\\`\\(gh\\|github\\)\\'" . "https://github.com/%s/%s/commit/%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.")
(defconst hibtypes-social-username-alist
- '(("\\`\\(fb\\|facebook\\)\\'" . "https://www.facebook.com/%s")
- ("\\`\\(tw\\|twitter\\)\\'" . "https://twitter.com/search?q=@%s")
- ("\\`\\(in\\|instagram\\)\\'" . "https://www.instagram.com/%s/"))
+ '(("\\`\\(fb\\|facebook\\)\\'" . "https://www.facebook.com/%s")
+ ("\\`\\(gh\\|github\\)\\'" . "https://github.com/%s/")
+ ("\\`\\(in\\|instagram\\)\\'" . "https://www.instagram.com/%s/")
+ ("\\`\\(tw\\|twitter\\)\\'" . "https://twitter.com/search?q=@%s")
+ )
"Alist of (social-media-service-regexp . url-with-%s-for-username)
elements.")
-(defconst hibtypes-social-regexp
"\\([[:alpha:]]*\\)\\([#@]\\)\\([._[:alnum:]]*[_[:alnum:]]\\)"
+(defconst hibtypes-social-regexp
"\\([[:alpha:]]*\\)\\([#@]\\)\\([[:alnum:]]*[._/[:alnum:]]*[_[:alnum:]]\\)"
"Regular expression that matches a social media hashtag or username
reference.
See `ibtypes::social-reference' for format details.")
@@ -93,8 +110,8 @@ 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)
(save-match-data
;; Heuristic to ensure this is not an email address
@@ -104,19 +121,41 @@ listed in `hibtypes-social-inhibit-modes'."
(match-string-no-properties
1)))))))))
(save-match-data
(ibut:label-set (match-string-no-properties 0) (match-beginning 0)
(match-end 0)))
- (hact 'social-reference (match-string-no-properties 1)
- (match-string-no-properties 2) (match-string-no-properties 3))))
-
-(defact social-reference (service ref-type-char hashtag-or-username)
- "Display the web page at social media SERVICE for REF-TYPE-CHAR and
HASHTAG-OR-USERNAME.
-REF-TYPE-CHAR is either \"#\" for a hashtag reference or \"@\" for a username
reference."
+ (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 "\\(\\([^/#@]+\\)/\\)?\\([^/#@]+\\)/"
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)))))))
+
+(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)
- (when (or (and (equal ref-type-char "#")
+ (when (or (and (equal ref-type-str "#")
(setq url-to-format
(assoc-default service hibtypes-social-hashtag-alist
#'string-match)))
- (and (equal ref-type-char "@")
+ (and (equal ref-type-str "@")
(setq url-to-format
(assoc-default service hibtypes-social-username-alist
#'string-match))))
(funcall hibtypes-social-display-function (format url-to-format
hashtag-or-username)))))
diff --git a/hibtypes.el b/hibtypes.el
index 795bd6a..b96ecad 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -212,26 +212,15 @@ current major mode is one handled by func-menu."
;; (hact 'imenu-display-item-where item-name item-pos)))))))
;;; ========================================================================
-;;; Handles social media hashtag and username references, e.g.
twitter#myhashtag
-;;; ========================================================================
-
-(require 'hib-social)
-
-;;; ========================================================================
-;;; Handles Gnu debbugs issue ids, e.g. bug#45678 or just 45678.
-;;; ========================================================================
-
-(require 'hib-debbugs)
-
-;;; ========================================================================
;;; Handles internal references within an annotated bibliography, delimiters=[]
;;; ========================================================================
(defib annot-bib ()
"Displays annotated bibliography entries referenced internally.
References must be delimited by square brackets, must begin with a word
-constituent character, and must not be in buffers whose names begin with a
-` ' or `*' character or which do not have an attached file."
+constituent character, not contain @ or # characters, must not be
+in buffers whose names begin with a space or asterisk character, and
+must have an attached file."
(and (not (bolp))
buffer-file-name
(let ((chr (aref (buffer-name) 0)))
@@ -240,10 +229,23 @@ constituent character, and must not be in buffers whose
names begin with a
(let* ((ref-and-pos (hbut:label-p t "[" "]" t))
(ref (car ref-and-pos)))
(and ref (eq ?w (char-syntax (aref ref 0)))
+ (not (string-match "[#@]" ref))
(progn (ibut:label-set ref-and-pos)
(hact 'annot-bib ref))))))
;;; ========================================================================
+;;; Handles social media hashtag and username references, e.g.
twitter#myhashtag
+;;; ========================================================================
+
+(require 'hib-social)
+
+;;; ========================================================================
+;;; Handles Gnu debbugs issue ids, e.g. bug#45678 or just 45678.
+;;; ========================================================================
+
+(require 'hib-debbugs)
+
+;;; ========================================================================
;;; Displays in-file Markdown link referents.
;;; ========================================================================
diff --git a/hui-menu.el b/hui-menu.el
index 16b387c..637e22e 100644
--- a/hui-menu.el
+++ b/hui-menu.el
@@ -246,7 +246,7 @@ Return t if cutoff, else nil."
:style toggle :selected (and (boundp 'hyrolo-add-hook)
(listp hyrolo-add-hook)
(memq 'hyrolo-set-date
hyrolo-add-hook))]
- ["Toggle-Smart-Key-Debug" hkey-toggle-debug
+ ["Toggle-Smart-Key-Debug (HyDebug)" hkey-toggle-debug
:style toggle :selected hkey-debug]
))
"Untitled menu of Hyperbole options.")
diff --git a/hui-mouse.el b/hui-mouse.el
index d17a05b..23a5fc4 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -103,9 +103,11 @@ Its default value is #'smart-scroll-down."
(hargs:select-p hkey-value 'assist)))
;;
;; If reading a Hyperbole menu item and nothing is selected, just return.
+ ;; If in a helm session, quit the session and activate the selected item.
((and (> (minibuffer-depth) 0)
(eq (selected-window) (minibuffer-window))
- (eq hargs:reading-p 'hmenu)) .
+ (or (eq hargs:reading-p 'hmenu)
+ (smart-helm-alive-p))) .
((funcall (key-binding (kbd "RET"))) . (funcall (key-binding (kbd
"RET")))))
;;
;; The ID-edit package supports rapid killing, copying, yanking and
@@ -446,7 +448,8 @@ Assumes Hyperbole has already checked that point is in a
helm buffer."
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."
+ 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))