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

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

[elpa] scratch/hyperbole-merge-7.0.2b 30600eb 04/23: Added extensive git


From: Stefan Monnier
Subject: [elpa] scratch/hyperbole-merge-7.0.2b 30600eb 04/23: Added extensive gitlab-reference ibtype; improved github-reference
Date: Tue, 5 Feb 2019 16:11:18 -0500 (EST)

branch: scratch/hyperbole-merge-7.0.2b
commit 30600eb69c365cba9b116145882b818d6b2ca69e
Author: Bob Weiner <address@hidden>
Commit: Bob Weiner <address@hidden>

    Added extensive gitlab-reference ibtype; improved github-reference
    
    * hib-social.el (github-reference): Added =item-id syntax.
                    (gitlab-reference): Added to support Gitlab references.
    
    2017-12-18  Bob Weiner  <address@hidden>
    
    * hib-social.el (github-reference): Fixed resolution of these formats of 
issue reference:
        gh#gh-34 and gh#issue/34 (needed to be plural).
---
 Changes            |  10 +++
 hib-social.el      | 246 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 man/hyperbole.texi |   2 +-
 3 files changed, 237 insertions(+), 21 deletions(-)

diff --git a/Changes b/Changes
index ea00ef8..c43725c 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,13 @@
+2017-12-19  Bob Weiner  <address@hidden>
+
+* hib-social.el (github-reference): Added =item-id syntax.
+                (gitlab-reference): Added to support Gitlab references.
+
+2017-12-18  Bob Weiner  <address@hidden>
+
+* hib-social.el (github-reference): Fixed resolution of these formats of issue 
reference:
+    gh#gh-34 and gh#issue/34 (needed to be plural).
+
 2017-12-17  Bob Weiner  <address@hidden>
 
 * kotl/kfill.el: Eliminated use of filladapt.el since it causes kotl-mode 
filling errors.
diff --git a/hib-social.el b/hib-social.el
index 2f0e550..f10eb6c 100644
--- a/hib-social.el
+++ b/hib-social.el
@@ -16,11 +16,11 @@
 ;;   When the referent is a web page, this calls the function given by
 ;;   `hibtypes-social-display-function' to display it, initially set to 
`browse-url'.
 ;;
-;;   A hashtag reference is either: 
[facebook|github|git|instagram|twitter]#<hashtag>
-;;   or using 2-letter service abbreviations: [fb|gh|gt|in|tw]#<hashtag>.
+;;   A hashtag reference is either: 
[facebook|github|gitlab|git|instagram|twitter]#<hashtag>
+;;   or using 2-letter service abbreviations: [fb|gh|gl|gt|in|tw]#<hashtag>.
 ;;
-;;   A username reference is either: 
[facebook|github|instagram|twitter]@<username>
-;;   or [fb|gh|in|tw]@<username>.
+;;   A username reference is either: 
[facebook|github|gitlab|instagram|twitter]@<username>
+;;   or [fb|gh|gl|in|tw]@<username>.
 ;;
 ;;   If the social media service is not given, it defaults to the value of
 ;;   `hibtypes-social-default-service', initially set to \"twitter\".
@@ -32,6 +32,7 @@
 
 ;;     address@hidden                             Display user's home page
 ;;     address@hidden
+;;     address@hidden
 ;;     address@hidden
 ;;     address@hidden
 
@@ -90,6 +91,45 @@
 ;;
 
 
+;;   Gitlab (remote) reference links
+;;
+;;     address@hidden                                 Display user's home page 
& projects
+;;
+;;     gitlab#rswgnu/hyperbole                   Display user's project
+;;     gl#rswgnu/helm/global_mouse               Display user project's branch
+;;     gl#rswgnu/hyperbole/55a1f0                Display user project's commit 
diff
+;;
+;;     gl#orgs/gitlab/people                     List the org, gitlab's staff
+;;
+;;     (setq hibtypes-gitlab-default-user "rswgnu")
+;;     gitlab#/hyperbole                         Display default user's project
+;;
+;;
+;;     Once you set the default user and project variables, you can leave
+;;     them off any reference links:
+;;
+;;       (setq hibtypes-gitlab-default-user "emacs-helm")
+;;       (setq hibtypes-gitlab-default-project "helm")
+;;
+;;     like so:
+;;
+;;       gl#issues                               List emacs-helm/helm's open 
issues
+;;       gl#1878                                 Display a specific project 
issue
+;;
+;;       gl#pulls                                List project's open pull 
requests
+;;       gl#pull/1871                            Display a specific project 
pull request
+;;
+;;       gl#branches                             List project's branches
+;;       gl#branch/global_mouse                  List files in a specific 
branch
+;;       gl#global_mouse                         You can even leave off the 
`branch' keyword
+;;
+;;       gl#tags                                 List project's tagged 
commits, typically releases
+;;       gl#tag/v2.8.4 or gl#v2.8.4              List files in a specific 
tagged commit
+;;
+;;       gl#commits                              List project's commits
+;;       gl#898e55c                              Display default user and 
default
+;;                                               project commit diff
+
 ;;   Github (remote) reference links
 ;;
 ;;     address@hidden                                 Display user's home page 
& projects
@@ -112,12 +152,12 @@
 ;;
 ;;     like so:
 ;;
-;;       gh#issues                               List emacs-helm/helm's open 
issues
-;;       gh#1878                                 Display a specific project 
issue
-;;
-;;       gh#pulls                                List project's open pull 
requests
+;;       gh#pulls                                List project's open pull 
requests (PRs)
 ;;       gh#pull/1871                            Display a specific project 
pull request
 ;;
+;;       gh#issues                               List emacs-helm/helm's open 
issues
+;;       gh#1878                                 Display a specific project 
issue (or PR)
+;;
 ;;       gh#branches                             List project's branches
 ;;       gh#branch/global_mouse                  List files in a specific 
branch
 ;;       gh#global_mouse                         You can even leave off the 
`branch' keyword
@@ -147,6 +187,7 @@
   :type '(radio (const "facebook")
                (const "git")
                (const "github")
+               (const "gitlab")
                (const "instagram")
                (const "twitter"))
   :group 'hyperbole-button)
@@ -171,6 +212,16 @@
   :type 'string
   :group 'hyperbole-button)
 
+(defcustom hibtypes-gitlab-default-project nil
+  "Default project name to associate with any Github commit link."
+  :type 'string
+  :group 'hyperbole-button)
+
+(defcustom hibtypes-gitlab-default-user nil
+  "Default user name to associate with any Github commit link."
+  :type 'string
+  :group 'hyperbole-button)
+
 ;;; ************************************************************************
 ;;; Private variables
 ;;; ************************************************************************
@@ -178,6 +229,7 @@
 (defconst hibtypes-social-hashtag-alist
   '(("\\`\\(fb\\|facebook\\)\\'"  . "https://www.facebook.com/hashtag/%s";)
     ("\\`\\(gh\\|github\\)\\'"    . "https://github.com/%s/%s/%s%s";)
+    ("\\`\\(gl\\|gitlab\\)\\'"    . "https://www.gitlab.com/%s/%s/%s%s";)
     ("\\`\\(gt\\|git\\)\\'"       . "(cd %s; git %s %s)")
     ("\\`\\(in\\|instagram\\)\\'" . 
"https://www.instagram.com/explore/tags/%s/";)
     ("\\`\\(tw\\|twitter\\)\\'"   . 
"https://twitter.com/search?q=%%23%s&src=hashtag";)
@@ -187,6 +239,7 @@
 (defconst hibtypes-social-username-alist
   '(("\\`\\(fb\\|facebook\\)\\'"  . "https://www.facebook.com/%s";)
     ("\\`\\(gh\\|github\\)\\'"    . "https://github.com/%s/";)
+    ("\\`\\(gl\\|gitlab\\)\\'"    . "https://www.gitlab.com/%s/";)
     ("\\`\\(in\\|instagram\\)\\'" . "https://www.instagram.com/%s/";)
     ("\\`\\(tw\\|twitter\\)\\'"   . "https://twitter.com/address@hidden";)
     )
@@ -212,8 +265,8 @@ See `ibtypes::social-reference' for format details.")
 (defib social-reference ()
   "Display the web page associated with a social hashtag or username reference 
at point.
 Reference format is:
-  [facebook|git|github|instagram|address@hidden<reference> or
-  [fb|gt|gh|in|address@hidden<reference>.
+  [facebook|git|github|gitlab|instagram|address@hidden<reference> or
+  [fb|gt|gh|gl|in|address@hidden<reference>.
 
 The first part of the label for a button of this type is the social
 service name.  The service name defaults to the value of
@@ -257,6 +310,8 @@ listed in `hibtypes-social-inhibit-modes'."
             (hact 'git-reference after-hash-str))
            ((string-match "\\`\\(gh\\|github\\)#" ref)
             (hact 'github-reference after-hash-str))
+           ((string-match "\\`\\(gl\\|gitlab\\)#" ref)
+            (hact 'gitlab-reference after-hash-str))
            (t (hact 'social-reference service ref-kind-str after-hash-str))))))
 
 ;; Don't make this a defact or its arguments may be improperly expanded as 
pathnames.
@@ -289,10 +344,10 @@ REFERENCE is a string of one of the following forms:
 or  /<project>.
 
 <ref-item> is one of these:
-  one of the words: branches, commits, issues, pulls, or tags; the associated 
items are listed;
+  one of the words: branches, commits, issues, pulls, status or tags; the 
associated items are listed;
 
-  one of the words: branch, commit, issue, pull or tag followed by a '/' and
-  item id; the item is shown;
+  one of the words: branch, commit, issue, pull or tag followed by a '/' or 
'=' and 
+  an item-id; the item is shown;
 
   an issue reference given by a positive integer, e.g. 92 or prefaced with 
GH-, e.g. GH-92;
   the issue is displayed;
@@ -314,7 +369,7 @@ PROJECT value is provided, it defaults to the value of
                 (url-to-format (assoc-default "github" 
hibtypes-social-hashtag-alist #'string-match))
                 (ref-type))
             (when url-to-format
-              (cond ((string-match 
"\\`\\(branch\\|commit\\|issue\\|pull\\|tag\\)/" reference)
+              (cond ((string-match 
"\\`\\(branch\\|commit\\|issue\\|pull\\|tag\\)[/=]" reference)
                      ;; [branch | commit | issue | pull | tag]/ref-item
                      nil)
                     ((string-match 
"\\`/?\\(\\([^/address@hidden)/\\)\\([^/address@hidden)\\'" reference)
@@ -342,14 +397,16 @@ PROJECT value is provided, it defaults to the value of
                        ;; All branches, commits, open issues, pull requests or 
commit tags reference
                        (setq ref-type reference
                              reference ""))
-                      ((and (< (length reference) 7) (string-match 
"\\`\\([gG][hH]-\\)?[0-9]+\\'" reference))
-                       ;; Specific issue reference
-                       (setq ref-type "issues/"))
-                      ((string-match "\\`\\(commit\\|issue\\|pull\\)/" 
reference)
+                      ((and (< (length reference) 8) (string-match 
"\\`\\([gG][hH]-\\)?[0-9]+\\'" reference))
+                       ;; Issue ref-id reference
+                       (setq ref-type "issues/"
+                             reference (substring reference (match-end 1) 
(match-end 0))))
+                      ((string-match "\\`\\(commit\\|issue\\|pull\\)[/=]" 
reference)
                        ;; Specific reference preceded by keyword branch, 
commit,
                        ;; issue, or pull
-                       (setq ref-type (substring reference 0 (match-end 0))
-                             reference (substring reference (match-end 0))))
+                       (setq ref-type (substring reference 0 (match-end 1))
+                             reference (substring reference (match-end 0))
+                             ref-type (concat ref-type (if (string-equal 
ref-type "issue") "s/" "/"))))
                       ((string-match "\\`[0-9a-f]+\\'" reference)
                        ;; Commit reference
                        (setq ref-type "commit/"))
@@ -373,6 +430,155 @@ PROJECT value is provided, it defaults to the value of
             (unless url-to-format
               (error "(github-reference): Add an entry for github to 
`hibtypes-social-hashtag-alist'"))))))
 
+;;; Remote Gitlab commit references
+
+;; Don't make this a defact or its arguments may be improperly expanded as 
pathnames.
+(defun gitlab-reference (reference &optional user project)
+  "Display the Gitlab entity associated with REFERENCE and optional USER and 
PROJECT.
+REFERENCE is a string of one of the following forms:
+    <ref-item>
+    <user>/<project>/<ref-item>
+    <project>/<ref-item>
+or  /<project>.
+
+<ref-item> is one of these:
+  one of the words: activity, analytics, boards or kanban, branches, commits, 
issues or
+  list, jobs, labels, members, merge_requests, milestones, pages, pipelines, 
pipeline_charts,
+  pulls, schedules, snippets, status or tags; the associated items are listed;
+
+  one of the words: branch, commit(s), issue(s), milestone(s), pull(s), 
snippet(s) or
+  tag(s) followed by a '/' or '=' and an item-id; the item is shown;
+
+  an issue reference given by a positive integer, e.g. 92 or prefaced with 
GL-, e.g. GL-92;
+  the issue is displayed;
+
+  a commit reference given by a hex number, 55a1f0; the commit diff is 
displayed;
+
+  a branch or tag reference given by an alphanumeric name, e.g. hyper20; the
+  files in the branch are listed.
+
+USER defaults to the value of `hibtypes-gitlab-default-user'.
+If given, PROJECT overrides any project value in REFERENCE.  If no
+PROJECT value is provided, it defaults to the value of
+`hibtypes-gitlab-default-project'."
+  (cond ((or (null reference) (equal reference ""))
+        (error "(gitlab-reference): Gitlab reference must not be empty"))
+       ((equal reference "status")
+        (funcall hibtypes-social-display-function "https://status.gitlab.com";))
+       (t (let ((case-fold-search t)
+                (url-to-format (assoc-default "gitlab" 
hibtypes-social-hashtag-alist #'string-match))
+                (ref-type))
+            (when url-to-format
+              (cond ((string-match 
"\\`\\(branch\\|commits?\\|issues?\\milestones?\\|pulls?\\|snippets?\\|tags?\\)[/=]"
 reference)
+                     ;; Reference to a specific ref-item
+                     nil)
+                    ((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)/\\)?\\([^/address@hidden)/\\(address@hidden)\\'" 
reference)
+                     ;; /?[user/]project/ref-item
+                     (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)\\'" reference)
+                     ;; /project
+                     (setq project (or project (match-string-no-properties 1 
reference))
+                           reference nil)))
+              (unless (stringp user) (setq user hibtypes-gitlab-default-user))
+              (unless (stringp project) (setq project 
hibtypes-gitlab-default-project))
+              (when (equal project "pages")
+                ;; Project web pages use a reverse pages/<project> URL format
+                (setq project user
+                      user "pages"
+                      ref-type nil
+                      reference nil))
+              (when reference
+                (cond  ((string-match 
"\\`\\(analytics\\|cycle_analytics\\)\\'" reference)
+                       ;; Project analytics
+                       (setq ref-type "cycle_analytics"
+                             reference ""))
+                       ((string-match "\\`\\(boards\\|kanban\\)\\'" reference)
+                       ;; Kanban-type Issue Stage Boards
+                       (setq ref-type "boards"
+                             reference ""))
+                      ((equal reference "jobs")
+                       ;; Manual/automated project-related jobs that run
+                       (setq ref-type "-/jobs"
+                             reference ""))
+                      ((equal reference "list")
+                       ;; List all issues
+                       (setq ref-type "issues"
+                             reference ""))
+                      ((equal reference "members")
+                       ;; Members of the project
+                       (setq ref-type "project_members"
+                             reference ""))
+                      ((equal reference "pipeline_charts")
+                       ;; Continuous Integration Pipeline Charts
+                       (setq ref-type "pipelines/charts"
+                             reference ""))
+                      ((equal reference "schedules")
+                       ;; Schedules for CI Pipelines
+                       (setq ref-type "pipeline_schedules"
+                             reference ""))
+                      ((string-match "\\`\\(service\\|service_desk\\)\\'" 
reference)
+                       ;; Project help desk 
+                       (setq ref-type "issues/service_desk"
+                             reference ""))
+                      ((member reference '("activity" "branches" "commits" 
"issues" "labels"
+                                           "merge_requests" "milestones" 
"pages" "pipelines"
+                                           "pulls" "snippets" "tags"))
+                       ;; All activity, branches, commits, cycle analytics, 
open issues, issue labels,
+                       ;; merge requests, milestones, web pages, pull 
requests, code snippets
+                       ;; or commit tags reference
+                       (setq ref-type reference
+                             reference ""))
+                      ((and (< (length reference) 8) (string-match 
"\\`\\([gG][lL]-\\)?[0-9]+\\'" reference))
+                       ;; Issue ref-id reference
+                       (setq ref-type "issues/"
+                             reference (substring reference (match-end 1) 
(match-end 0))))
+                      ((string-match "\\`label[/=]" reference)
+                       ;; Labeled category of issues
+                       (setq ref-type "issues?label_name%5B%5D="
+                             reference (substring reference (match-end 0))))
+                      ((string-match 
"\\`\\(commit\\|issues\\|milestones\\|pull\\|snippets\\|tags\\)[/=]" reference)
+                       ;; Ref-id preceded by a keyword
+                       (setq ref-type (concat (substring reference 0 
(match-end 1)) "/")
+                             reference (substring reference (match-end 0))))
+                      ((string-match 
"\\`\\(issue\\|milestone\\|snippet\\|tag\\)[/=]" reference)
+                       ;; Ref-id preceded by a singular keyword that must be 
converted to plural
+                       (setq ref-type (concat (substring reference 0 
(match-end 1)) "s/")
+                             reference (substring reference (match-end 0))))
+                      ((string-match "\\`\\(commit\\|pull\\)s[/=]" reference)
+                       ;; Ref-id preceded by a plural keyword that must be 
converted to singular
+                       (setq ref-type (concat (substring reference 0 
(match-end 1)) "/")
+                             reference (substring reference (1+ (match-end 
0)))))
+                      ((string-match "\\`[0-9a-f]+\\'" reference)
+                       ;; Commit reference
+                       (setq ref-type "commit/"))
+                      (t
+                       ;; Specific branch or commit tag reference
+                       (setq ref-type "tree/")
+                       (when (string-match "\\`\\(branch\\|tag\\)[/=]" 
reference)
+                         ;; If preceded by optional keyword, remove that from 
the reference.
+                         (setq reference (substring reference (match-end 
0)))))))
+              (if (and (stringp user) (stringp project))
+                  (funcall hibtypes-social-display-function
+                           (setq a (if reference
+                               (format url-to-format user project ref-type 
reference)
+                               ;; Remove trailing /
+                               (substring (format url-to-format user project 
"" "") 0 -1))))
+                (cond ((and (null user) (null project))
+                       (error "(gitlab-reference): Set 
`hibtypes-gitlab-default-user' and `hibtypes-gitlab-default-project'"))
+                      ((null user)
+                       (error "(gitlab-reference): Set 
`hibtypes-gitlab-default-user'"))
+                      (t
+                       (error "(gitlab-reference): Set 
`hibtypes-gitlab-default-project'")))))
+            (unless url-to-format
+              (error "(gitlab-reference): Add an entry for gitlab to 
`hibtypes-social-hashtag-alist'"))))))
+
 ;;; Local git repository commit references
 
 (defib git-commit-reference ()
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index c699a03..e219197 100644
--- a/man/hyperbole.texi
+++ b/man/hyperbole.texi
@@ -7882,7 +7882,7 @@ When in a Treemacs file browser buffer:
      (3) at the end of an entry line: invoke @code{action-key-eol-function},
          typically to scroll up proportionally, if an Action Key press; invoke
          @code{assist-key-eol-function}, typically to scroll down 
proportionally,
-         if an Asisst Key press;
+         if an Assist Key press;
      (4) on the first line of the buffer (other than the end of line),
          dired is run on the current directory of this Treemacs;
      (5) at the end of the first or last line of the buffer,



reply via email to

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