From 35224e5dd4d0ab5881591c731ee6de02512d2242 Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Sun, 8 Dec 2024 23:19:24 +0100 Subject: [PATCH] Depend on Emacs 29.1 Ghub 4.2.0 depends on Emacs 29.1, we can drop some backward compatibility kludges here as well. --- CHANGELOG | 2 + lisp/forge-topic.el | 90 ++++++++++----------------------------------- lisp/forge.el | 4 +- 3 files changed, 24 insertions(+), 72 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4d441db3..d2ffb9d1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/lisp/forge-topic.el b/lisp/forge-topic.el index 23a81d19..dd66c0c7 100644 --- a/lisp/forge-topic.el +++ b/lisp/forge-topic.el @@ -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 @@ -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) @@ -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 @@ -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) @@ -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 @@ -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)) diff --git a/lisp/forge.el b/lisp/forge.el index 106d7a81..094237a4 100644 --- a/lisp/forge.el +++ b/lisp/forge.el @@ -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")