Skip to content

Commit

Permalink
Depend on Emacs 29.1
Browse files Browse the repository at this point in the history
Ghub 4.2.0 depends on Emacs 29.1, we can drop some backward
compatibility kludges here as well.
  • Loading branch information
tarsius committed Dec 8, 2024
1 parent b29f84c commit 35224e5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 72 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- mode: org -*-
* v0.4.5 UNRELEASED

- At least Emacs 29.1 is required now.

- Started cashing calls to ~git~ during transient menu refreshes, similar
to how such calls are cached when refreshing a Magit buffer. #712

Expand Down
90 changes: 20 additions & 70 deletions lisp/forge-topic.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The following %-sequences are supported:
"Width of repository slugs (i.e., \"OWNER/NAME\")."
:package-version '(forge . "0.4.0")
:group 'forge
:type (if (>= emacs-major-version 28) 'natnum 'number))
:type 'natnum)

(defcustom forge-bug-reference-hooks
'(find-file-hook
Expand Down Expand Up @@ -98,8 +98,7 @@ does not inherit from `magit-dimmed'."
:group 'forge-faces)

(defface forge-topic-header-line
`((t :inherit magit-header-line
,@(and (>= emacs-major-version 29) '(:foreground reset))))
'((t :inherit magit-header-line :foreground reset))
"Face for the `header-line' in `forge-topic-mode' buffers."
:group 'forge-faces)

Expand Down Expand Up @@ -136,9 +135,8 @@ were closed without being merged."
;;;;; Notifications

(defface forge-topic-unread
`((t :weight bold
:box ( :line-width ,(if (>= emacs-major-version 28) (cons -1 -1) -1)
:style nil)))
'((t :weight bold
:box (:line-width (-1 . -1) :style nil)))
"Face used for summaries of entities with unread notifications.
This face is always used together with, and takes preference over,
a `forge-{issue,pullreq}-STATE' face and should not specify any
Expand Down Expand Up @@ -208,9 +206,8 @@ A face attribute should be used that is not already used by any
;;;; Labels

(defface forge-topic-label
`((t :inherit secondary-selection
:box ( :line-width ,(if (>= emacs-major-version 28) (cons -1 -1) -1)
:style released-button)))
'((t :inherit secondary-selection
:box (:line-width (-1 . -1) :style released-button)))
"Face used for topic labels, marks and milestones."
:group 'forge-faces)

Expand Down Expand Up @@ -1716,39 +1713,6 @@ alist, containing just `text' and `position'.")

;;; Bug-Reference

(when (< emacs-major-version 28)
(defun bug-reference-fontify (start end)
"Apply bug reference overlays to region."
(save-excursion
(let ((beg-line (progn (goto-char start) (line-beginning-position)))
(end-line (progn (goto-char end) (line-end-position))))
;; Remove old overlays.
(bug-reference-unfontify beg-line end-line)
(goto-char beg-line)
(while (and (< (point) end-line)
(re-search-forward bug-reference-bug-regexp end-line 'move))
(when (and (or (not bug-reference-prog-mode)
;; This tests for both comment and string syntax.
(nth 8 (syntax-ppss)))
;; This is the part where this redefinition differs
;; from the original defined in "bug-reference.el".
(not (and (derived-mode-p 'magit-status-mode
'forge-notifications-mode)
(= (match-beginning 0)
(line-beginning-position))))
;; End of additions.
)
(let ((overlay (make-overlay (match-beginning 0) (match-end 0)
nil t nil)))
(overlay-put overlay 'category 'bug-reference)
;; Don't put a link if format is undefined
(when bug-reference-url-format
(overlay-put overlay 'bug-reference-url
(if (stringp bug-reference-url-format)
(format bug-reference-url-format
(match-string-no-properties 2))
(funcall bug-reference-url-format)))))))))))

(defun forge-bug-reference-setup ()
"Setup `bug-reference' in the current buffer.
If forge data has been fetched for the current repository, then
Expand All @@ -1760,34 +1724,20 @@ modify `bug-reference-bug-regexp' if appropriate."
(derived-mode-p 'forge-topics-mode 'forge-notifications-mode))
(magit--with-safe-default-directory nil
(when-let ((repo (forge-get-repository :tracked?)))
(if (>= emacs-major-version 28)
(when (derived-mode-p 'magit-status-mode
'forge-notifications-mode)
(setq-local
bug-reference-auto-setup-functions
(let ((hook bug-reference-auto-setup-functions))
(list (lambda ()
;; HOOK is not allowed to be a lexical var:
;; (run-hook-with-args-until-success 'hook)
(catch 'success
(dolist (f hook)
(when (funcall f)
(setq bug-reference-bug-regexp
(concat "." bug-reference-bug-regexp))
(throw 'success t)))))))))
(setq-local bug-reference-url-format
(if (forge--childp repo 'forge-gitlab-repository)
(lambda ()
(forge--format repo
(if (equal (match-string 3) "#")
'issue-url-format
'pullreq-url-format)
`((?i . ,(match-string 2)))))
(forge--format repo 'issue-url-format '((?i . "%s")))))
(setq-local bug-reference-bug-regexp
(if (forge--childp repo 'forge-gitlab-repository)
"\\(?3:[!#]\\)\\(?2:[0-9]+\\)"
"#\\(?2:[0-9]+\\)")))
(when (derived-mode-p 'magit-status-mode
'forge-notifications-mode)
(setq-local
bug-reference-auto-setup-functions
(let ((hook bug-reference-auto-setup-functions))
(list (lambda ()
;; HOOK is not allowed to be a lexical var:
;; (run-hook-with-args-until-success 'hook)
(catch 'success
(dolist (f hook)
(when (funcall f)
(setq bug-reference-bug-regexp
(concat "." bug-reference-bug-regexp))
(throw 'success t)))))))))
(if (derived-mode-p 'prog-mode)
(bug-reference-prog-mode 1)
(bug-reference-mode 1))
Expand Down
4 changes: 2 additions & 2 deletions lisp/forge.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

;; Package-Version: 0.4.4
;; Package-Requires: (
;; (emacs "27.1")
;; (emacs "29.1")
;; (compat "30.0.0.0")
;; (closql "2.1.0")
;; (dash "2.19.1")
;; (emacsql "4.1.0")
;; (ghub "4.1.1")
;; (ghub "4.2.0")
;; (let-alist "1.0.6")
;; (magit "4.1.3")
;; (markdown-mode "2.6")
Expand Down

0 comments on commit 35224e5

Please sign in to comment.