branch: elpa/fj
commit 48a299cb54b9001b40f88789f8c693b5c408dabb
Merge: 79a1ef1006 bc00bbf226
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>
Merge branch 'dev'
---
fj.el | 125 +++++++++++++++++++++++++++++++++++++++++++++----------------
readme.org | 28 ++++++++++----
2 files changed, 114 insertions(+), 39 deletions(-)
diff --git a/fj.el b/fj.el
index 2e77487868..b6cb98484c 100644
--- a/fj.el
+++ b/fj.el
@@ -3,10 +3,15 @@
;; Author: Marty Hiatt <[email protected]>
;; Copyright (C) 2023 Marty Hiatt <[email protected]>
;;
-;; Package-Requires: ((emacs "29.1") (fedi "0.2") (tp "0.5") (transient
"0.9.3") (magit "4.3.8"))
+;; Package-Requires:
+;; ((emacs "29.1")
+;; (fedi "0.2")
+;; (tp "0.8")
+;; (transient "0.10.0")
+;; (magit "4.3.8"))
;; Keywords: git, convenience
;; URL: https://codeberg.org/martianh/fj.el
-;; Version: 0.28
+;; Version: 0.29
;; Separator: -
;; This program is free software; you can redistribute it and/or modify
@@ -338,20 +343,28 @@ SILENT means make a silent request."
(let* ((url (fj-api endpoint))
(resp (fj-authorized-request "GET"
(if no-json
- (fedi-http--get url params silent)
- (fedi-http--get-json url params silent)))))
+ (cons (fedi-http--get url params silent) nil)
+ (fedi-http--get-response url params nil silent))))
+ (headers (cdr resp))
+ (resp (car resp)))
;; FIXME: handle 404 etc!
- (if no-json
- ;; return response buffer, not resulting string. the idea is to then
- ;; call --triage on the result, in case we don't get a 200 response.
- ;; (fj-resp-str resp)
- resp
- (if (or (eq (caar resp) 'errors)
- (eq (caar resp) 'message))
- (user-error "I am Error: %s Endpoint: %s"
- (alist-get 'message resp)
- endpoint)
- resp))))
+ (cond
+ ;; return response buffer, not resulting string. the idea is to then
+ ;; call --triage on the result, in case we don't get a 200 response.
+ ;; (fj-resp-str resp)
+ (no-json resp)
+
+ ((eq (alist-get 'status headers) 404)
+ nil)
+
+ ((or (eq (caar resp) 'errors)
+ (eq (caar resp) 'message))
+
+ (user-error "I am Error: %s Endpoint: %s"
+ (alist-get 'message resp)
+ endpoint))
+
+ (t resp))))
(defun fj-resp-str (resp)
"Return the response string from RESP, an HTTP response buffer."
@@ -2888,15 +2901,20 @@ works on the resulting html."
(concat
"\nš " (substring fedi-horiz-bar 3)
(propertize
- ;; FIXME: markdown rendering adds an unwanted newline, and stripping
- ;; it still renders with an empty line!
- (fj-render-markdown
- (mapconcat (lambda (x)
- (concat
- "[" (alist-get 'name x) "]("
- (alist-get 'browser_download_url x)
- ")"))
- assets "\n"))
+ (mapconcat (lambda (x)
+ (propertize
+ ;; FIXME: markdown rendering adds an unwanted newline,
+ ;; and stripping it still renders with an empty line! we
+ ;; need to render each attachment separately so we can
+ ;; then propertize it with its data
+ (fj-render-markdown
+ (concat
+ "[" (alist-get 'name x) "]("
+ (alist-get 'browser_download_url x)
+ ")"))
+ 'fj-attachment x
+ 'fj-attachment-id (alist-get 'id x)))
+ assets "\n")
'fj-item-body t)))
(defun fj-item-view (&optional repo owner number type page limit)
@@ -3337,9 +3355,8 @@ TS is timestamp, BODY is the item's response."
(fj-propertize-link
(concat
short " "
- (car (string-split
- (map-nested-elt d '(commit message))
- "\n")))
+ (if d (car (string-lines (map-nested-elt d '(commit
message))))
+ "unreachable commit"))
'commit-ref c)))))))
(defun fj-render-timeline-item (item &optional author owner repo)
@@ -3677,12 +3694,12 @@ Returns annotation for CAND, a candidate."
(define-button-type 'fj-search-owner-button
'follow-link t
- 'action 'fj-list-user-repos
+ 'action 'fj-list-own-or-user-repos
'help-echo "RET: View this user.")
(define-button-type 'fj-issues-owner-button
'follow-link t
- 'action 'fj-list-user-repos
+ 'action 'fj-list-own-or-user-repos
'help-echo "RET: View this user.")
(define-button-type 'fj-repo-stargazers-button
@@ -3848,6 +3865,18 @@ unset any default values."
(fj--repo-owner))))
(fj-user-repos owner)))))
+(defun fj-list-own-or-user-repos (pos)
+ "Button action function for owners in tabulated lists.
+POS is current position.
+If owner is `fj-user', call `fj-list-own-repos'.
+Else call `fj-user-repos'.
+We do this because the latter has no sort argument, while the former
+does, and sorting user repos is useful."
+ (let ((user (button-label (button-at pos))))
+ (if (string= fj-user user)
+ (fj-list-own-repos)
+ (fj-list-user-repos))))
+
;; search or user repo TL
(defun fj-star-repo (&optional unstar)
"Star or UNSTAR current repo from tabulated user repos listing."
@@ -3855,7 +3884,7 @@ unset any default values."
(fj-with-repo-entry
(let* ((repo (fj--repo-name))
(owner (fj--repo-owner)))
- (fj-star-repo repo owner unstar))))
+ (fj-star-repo* repo owner unstar))))
(defun fj-unstar-repo ()
"Unstar current repo from tabulated user repos listing."
@@ -4812,7 +4841,9 @@ Used for hitting RET on a given link."
(fj-issue-ref-follow item))
;; ((eq type 'pull)
;; (fj-item-view repo owner item nil :pull))
- ('handle (fj-user-repos item))
+ ('handle (if (string= fj-user item)
+ (fj-list-own-repos)
+ (fj-user-repos item)))
('team (fj-browse-team item))
('repo-tag (fj-repo-tag-follow item))
((or 'commit 'commit-ref)
@@ -4972,9 +5003,39 @@ PAGE and LIMIT as always."
'help-echo .sha)
"\n" fedi-horiz-bar fedi-horiz-bar "\n\n"))))
+(defvar fj-repo-activity-types
+ '("create_repo"
+ "rename_repo"
+ "star_repo"
+ "watch_repo"
+ "commit_repo"
+ "create_issue"
+ "create_pull_request"
+ "transfer_repo"
+ "push_tag"
+ "comment_issue"
+ "merge_pull_request"
+ "close_issue"
+ "reopen_issue"
+ "close_pull_request"
+ "reopen_pull_request"
+ "delete_tag"
+ "delete_branch"
+ "mirror_sync_push"
+ "mirror_sync_create"
+ "mirror_sync_delete"
+ "approve_pull_request"
+ "reject_pull_request"
+ "comment_pull"
+ "publish_release"
+ "pull_review_dismissed"
+ "pull_request_ready_for_review"
+ "auto_merge_pull_request")
+ "List of activity types in repository feeds.")
+
;; GET /repos/{owner}/{repo}/activities/feeds
(defun fj-repo-get-feed (repo owner)
- "Get te activity feed of REPO by OWNER."
+ "Get the activity feed of REPO by OWNER."
(let ((endpoint (format "repos/%s/%s/activities/feeds" owner repo)))
(fj-get endpoint)))
diff --git a/readme.org b/readme.org
index 48d6d2f294..f0ae3daf8e 100644
--- a/readme.org
+++ b/readme.org
@@ -1,4 +1,5 @@
+@@html: <a href="https://elpa.nongnu.org/nongnu/fj.html"><img alt="ELPA"
src="https://elpa.nongnu.org/nongnu/fj.svg"></a>@@
@@html: <a href="https://liberapay.com/martianh/donate"><img alt="Donate using
Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a>@@
* fj.el
@@ -9,6 +10,19 @@ It doesn't interact with =forge= / =magit=, which don't
implement Gitea/Forgejo
It just aims to cover a few of the bread and butter functions that will save
you switching to the browser 80% of the time.
+* install
+
+=fj.el= is available in [[https://elpa.nongnu.org/][ELPA]].
+
+You can also just pull it from the repo with use-package/straight, such as:
+
+#+begin_src emacs-lisp
+(use-package fj
+ :straight (:type git :host codeberg "martianh/fj.el")
+ :config
+ (setq fj-user "martianh"))
+#+end_src
+
* getting started
** authentication
@@ -110,7 +124,7 @@ If you want to insert a link to a line in your source
files, consider using http
If you want verbatim code blocks in comments to have syntax highlighting,
consider installing
-https://github.com/xuchunyang/shr-tag-pre-highlight.el. =fj-.el= uses =shr=
+[[https://github.com/xuchunyang/shr-tag-pre-highlight.el]]. =fj-.el= uses =shr=
for rendering, and =shr-tag-pre-highlight= adds syntax highlighting support
to =shr=. You may also need to customize =shr-tag-pre-highlight-lang-modes= to
ensure the languages you want will work.
@@ -170,7 +184,7 @@ Repo search listing:
[[file:Screenshot-search.png]]
-Repo settings transient:
+Repo settings transient (current setting on the server underlined, current
user choice in green):
[[file:Screenshot-transient.png]]
@@ -178,7 +192,7 @@ Syntax highlighting (optional dependency):
[[file:screenshot-syntax-highlight.png]]
-Diffs (as code as as reviews):
+Diffs (as commits and PRs):
[[file:screenshot-diff.png]]
@@ -277,7 +291,6 @@ Diffs (as code as as reviews):
| | fj-fork-repo | Fork repo entry at point.
|
| | fj-fork-to-parent | From a repo TL listing, jump to
the parent repo. |
| | fj-get-pull-commits | Return the data for the commits
of the current pull. |
-| | fj-git-link-code-range | Call `git-link'.
|
| | fj-inspect-item-data | Browse the JSON data of item at
point. |
| | fj-issue-compose | Compose a new post.
|
| | fj-issue-get-labels | Get labels on ISSUE in REPO by
OWNER. |
@@ -288,8 +301,8 @@ Diffs (as code as as reviews):
| K | fj-item-delete | Delete the item at point or
being viewed. |
| e | fj-item-edit | Edit the item at point or being
viewed. |
| t | fj-item-edit-title | Edit the title of the item at
point or being viewed. |
-| l | fj-item-label-add | Comment on the item at point or
being viewed. |
-| | fj-item-label-remove | Comment on the item at point or
being viewed. |
+| l | fj-item-label-add | Add label to the item at point
or being viewed. |
+| | fj-item-label-remove | Remove label from the item at
point or being viewed. |
| n | fj-item-next | Go to next item or
notification. |
| p | fj-item-prev | Goto previous item or
notification. |
| o | fj-item-reopen | Reopen the item at point or
being viewed. |
@@ -310,7 +323,7 @@ Diffs (as code as as reviews):
| W | fj-list-own-issues | List issues in repos owned by
`fj-user'. |
| | fj-list-own-pulls | List pulls in repos owned by
`fj-user'. |
| O | fj-list-own-repos | List repos for `fj-user'.
|
-| C-c C-x | fj-list-own-repos-read | List repos for `fj-user',
prompting for an order type. |
+| C-c C-c | fj-list-own-repos-read | List repos for `fj-user',
prompting for an order type. |
| P | fj-list-pulls | List pulls for REPO by OWNER,
filtered by STATE. |
| | fj-list-repos | List repos for `fj-user'
extended by `fj-extra-repos'. |
| | fj-list-user-repos | View repos of current entry
user from tabulated repos listing. |
@@ -392,6 +405,7 @@ Diffs (as code as as reviews):
#+RESULTS:
| Custom variable | Description
|
|------------------------------+---------------------------------------------------------------|
+| fj-compose-autocomplete | Whether to enable autocompletion in compose
buffers. |
| fj-compose-comment-mode-hook | Hook run after entering or leaving
`fj-compose-comment-mode'. |
| fj-compose-mode-hook | Hook run after entering or leaving
`fj-compose-mode'. |
| fj-issues-sort-default | Default sort parameter for repo issues
listing. |