diff mbox series

[bug#37080] Update emacs-org-recent-headings.

Message ID CAAc=MEycq2ivBcsxBBSk24LfQpt=SS2=guU9YfZnDL9_G--G6w@mail.gmail.com
State Accepted
Headers show
Series [bug#37080] Update emacs-org-recent-headings. | expand

Commit Message

Brian Leung Aug. 19, 2019, 6:34 a.m. UTC
The version of emacs-org-recent-headings on Guix doesn't work correctly for
people with Helm installed. I submitted patches to the upstream maintainer
of emacs-org-recent-headings. Attached is a Guix patch incorporating the
changes.

Comments

Ludovic Courtès Aug. 27, 2019, 10:30 a.m. UTC | #1
Hi Brian,

Brian Leung <bkleung89@gmail.com> skribis:

> The version of emacs-org-recent-headings on Guix doesn't work correctly for
> people with Helm installed. I submitted patches to the upstream maintainer
> of emacs-org-recent-headings. Attached is a Guix patch incorporating the
> changes.

Have these patches been applied upstream?

Since we’re building from an upstream commit, we might just as well wait
until the changes are available upstream.

Thanks,
Ludo’.
Brian Leung Aug. 27, 2019, 4:52 p.m. UTC | #2
Hi Ludovic,

The patches haven't been applied upstream. The upstream maintainer doesn't
review PRs in a timely manner, so I thought it might be worth submitting
the patch here.

Thanks,
Brian

On Tue, Aug 27, 2019 at 12:30 PM Ludovic Courtès <ludo@gnu.org> wrote:

> Hi Brian,
>
> Brian Leung <bkleung89@gmail.com> skribis:
>
> > The version of emacs-org-recent-headings on Guix doesn't work correctly
> for
> > people with Helm installed. I submitted patches to the upstream
> maintainer
> > of emacs-org-recent-headings. Attached is a Guix patch incorporating the
> > changes.
>
> Have these patches been applied upstream?
>
> Since we’re building from an upstream commit, we might just as well wait
> until the changes are available upstream.
>
> Thanks,
> Ludo’.
>
Maxim Cournoyer Sept. 10, 2019, 4:24 a.m. UTC | #3
Hello Brian,

Brian Leung <bkleung89@gmail.com> writes:

> Hi Ludovic,
>
> The patches haven't been applied upstream. The upstream maintainer doesn't
> review PRs in a timely manner, so I thought it might be worth submitting
> the patch here.
>
> Thanks,
> Brian
>
> On Tue, Aug 27, 2019 at 12:30 PM Ludovic Courtès <ludo@gnu.org> wrote:
>
>> Hi Brian,
>>
>> Brian Leung <bkleung89@gmail.com> skribis:
>>
>> > The version of emacs-org-recent-headings on Guix doesn't work correctly
>> for
>> > people with Helm installed. I submitted patches to the upstream
>> maintainer
>> > of emacs-org-recent-headings. Attached is a Guix patch incorporating the
>> > changes.
>>
>> Have these patches been applied upstream?
>>
>> Since we’re building from an upstream commit, we might just as well wait
>> until the changes are available upstream.
>>
>> Thanks,
>> Ludo’.

+1, especially since the patches submitted upstream are still a WIP, AFAICT.
(see: https://github.com/alphapapa/org-recent-headings/issues/11).

Let's wait until a conclusion for a fix is reached and merged upstream
before we continue.

Thanks for your efforts in investigating the problem and working on a fix.

Maxim
diff mbox series

Patch

From 240c13331359e8c19fc5aa2b35a6839b37fabda2 Mon Sep 17 00:00:00 2001
From: Brian Leung <bkleung89@gmail.com>
Date: Sun, 11 Aug 2019 18:21:19 +0200
Subject: [PATCH] gnu: emacs-org-recent-headings: Update to 0.1-1.6336a0c.

* gnu/packages/emacs-xyz.scm: Update to 0.1-1.6336a0c.
* gnu/packages/patches/emacs-org-recent-headings.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
 gnu/local.mk                                  |   1 +
 gnu/packages/emacs-xyz.scm                    |  57 +++++---
 .../patches/emacs-org-recent-headings.patch   | 137 ++++++++++++++++++
 3 files changed, 174 insertions(+), 21 deletions(-)
 create mode 100644 gnu/packages/patches/emacs-org-recent-headings.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index aab29beb0a..04d35686aa 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -782,6 +782,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/emacs-fix-scheme-indent-function.patch	\
   %D%/packages/patches/emacs-json-reformat-fix-tests.patch	\
   %D%/packages/patches/emacs-highlight-stages-add-gexp.patch	\
+  %D%/packages/patches/emacs-org-recent-headings.patch	        \
   %D%/packages/patches/emacs-scheme-complete-scheme-r5rs-info.patch	\
   %D%/packages/patches/emacs-source-date-epoch.patch		\
   %D%/packages/patches/emacs-unpackaged-req.patch		\
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index ffc662f746..28571911d7 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -10853,28 +10853,43 @@  a heuristic based on frequency and recency.")
       (license license:gpl3+))))
 
 (define-public emacs-org-recent-headings
-  (package
-    (name "emacs-org-recent-headings")
-    (version "0.1")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/alphapapa/org-recent-headings.git")
-                    (commit version)))
-              (file-name (git-file-name name version))
-              (sha256
-               (base32
-                "0gsrzmg3mssh9s28yjm9m866fnhm1pcligssz1q6brga6dm6f2yy"))))
-    (build-system emacs-build-system)
-    (propagated-inputs
-     `(("emacs-org" ,emacs-org)
-       ("emacs-dash" ,emacs-dash)
-       ("emacs-frecency" ,emacs-frecency)))
-    (home-page "https://github.com/alphapapa/org-recent-headings")
-    (synopsis "Navigate to recently used Org headings and lists")
-    (description "This package maintains a list of recently used Org headings,
+  (let ((commit "6336a0c36ef1048ba1f4e07716a421dce106d082")
+        (revision "1"))
+    (package
+      (name "emacs-org-recent-headings")
+      (version (git-version "0.1" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/alphapapa/org-recent-headings.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1lpkjvlm969pr64j25zkpmsacjnr7qbq9zfwwzb9xyqlhaf5zzz0"))
+                ;; XXX: Remove once
+                ;; https://github.com/alphapapa/org-recent-headings/pull/12
+                ;; and
+                ;; https://github.com/alphapapa/org-recent-headings/pull/13
+                ;; are merged.  We need this patch to ensure that Helm users
+                ;; on Guix are able to use the package properly, since the
+                ;; upstream and the release version currently mishandle the
+                ;; optional Helm dependency. People who aren't using
+                ;; Guix-installed packages don't seem to be encountering this
+                ;; problem.
+                (patches (search-patches "emacs-org-recent-headings.patch"))))
+      (build-system emacs-build-system)
+      (propagated-inputs
+       `(("emacs-org" ,emacs-org)
+         ("emacs-frecency" ,emacs-frecency)))
+      (inputs
+       `(("emacs-dash" ,emacs-dash)
+         ("emacs-s" ,emacs-s)))
+      (home-page "https://github.com/alphapapa/org-recent-headings")
+      (synopsis "Navigate to recently used Org headings and lists")
+      (description "This package maintains a list of recently used Org headings,
 as well as functions for navigating between these headings.")
-    (license license:gpl3+)))
+      (license license:gpl3+))))
 
 (define-public emacs-org-super-agenda
   ;; emacs-org-sidebar depends on a newer commit than the latest release version.
diff --git a/gnu/packages/patches/emacs-org-recent-headings.patch b/gnu/packages/patches/emacs-org-recent-headings.patch
new file mode 100644
index 0000000000..1cfc31b8b4
--- /dev/null
+++ b/gnu/packages/patches/emacs-org-recent-headings.patch
@@ -0,0 +1,137 @@ 
+From 9452ff5d9d36974d522fcb9d66ea7243202b1eb5 Mon Sep 17 00:00:00 2001
+From: Brian Leung <bkleung89@gmail.com>
+Date: Thu, 15 Aug 2019 04:42:37 +0200
+Subject: [PATCH] Change handling of optional dependencies.
+
+org-recent-headings-helm: `declare-function` does not seem to work on
+macros, so `helm-make-source` is used instead of
+helm-build-sync-source.
+
+org-recent-headings-ivy: Add dispatch actions.
+---
+ org-recent-headings.el | 89 ++++++++++++++++++++++++++++++------------
+ 1 file changed, 63 insertions(+), 26 deletions(-)
+
+diff --git a/org-recent-headings.el b/org-recent-headings.el
+index aea76f5..335fb89 100644
+--- a/org-recent-headings.el
++++ b/org-recent-headings.el
+@@ -222,27 +222,26 @@ With prefix argument ARG, turn on if positive, otherwise off."
+ 
+ ;;;;; Helm
+ 
+-(with-eval-after-load 'helm
+-
+-  ;; This declaration is absolutely necessary for some reason.  Even if `helm' is loaded
+-  ;; before this package is loaded, an "invalid function" error will be raised when this
+-  ;; package is loaded, unless this declaration is here.  Even if I manually "(require
+-  ;; 'helm)" and then load this package after the error (and Helm is already loaded, and I've
+-  ;; verified that `helm-build-sync-source' is defined), once Emacs has tried to load this
+-  ;; package thinking that the function is invalid, it won't stop thinking it's invalid.  It
+-  ;; also seems to be related to `defvar' not doing anything when run a second time (unless
+-  ;; called with `eval-defun').  But at the same time, the error didn't always happen in my
+-  ;; config, or with different combinations of `with-eval-after-load', "(when (fboundp 'helm)
+-  ;; ...)", and loading packages in a different order.  I don't know exactly why it's
+-  ;; happening, but at the moment, this declaration seems to fix it.  Let us hope it really
+-  ;; does.  I hope no one else is suffering from this, because if so, I have inflicted mighty
+-  ;; annoyances upon them, and I wouldn't blame them if they never used this package again.
+-  (declare-function helm-build-sync-source "helm")
+-  (declare-function helm-exit-and-execute-action "helm")
+-  (declare-function helm-marked-candidates "helm")
+-  (declare-function with-helm-alive-p "helm")
+-  (declare-function helm-make-actions "helm-lib")
++;; This declaration is absolutely necessary for some reason.  Even if `helm' is loaded
++;; before this package is loaded, an "invalid function" error will be raised when this
++;; package is loaded, unless this declaration is here.  Even if I manually "(require
++;; 'helm)" and then load this package after the error (and Helm is already loaded, and I've
++;; verified that `helm-build-sync-source' is defined), once Emacs has tried to load this
++;; package thinking that the function is invalid, it won't stop thinking it's invalid.  It
++;; also seems to be related to `defvar' not doing anything when run a second time (unless
++;; called with `eval-defun').  But at the same time, the error didn't always happen in my
++;; config, or with different combinations of `with-eval-after-load', "(when (fboundp 'helm)
++;; ...)", and loading packages in a different order.  I don't know exactly why it's
++;; happening, but at the moment, this declaration seems to fix it.  Let us hope it really
++;; does.  I hope no one else is suffering from this, because if so, I have inflicted mighty
++;; annoyances upon them, and I wouldn't blame them if they never used this package again.
++(declare-function helm-make-source "ext:helm-source")
++(declare-function helm-exit-and-execute-action "ext:helm")
++(declare-function helm-marked-candidates "ext:helm")
++;; (declare-function with-helm-alive-p "ext:helm")
++(declare-function helm-make-actions "ext:helm-lib")
+ 
++(with-eval-after-load 'helm
+   (defvar helm-map)
+   (defvar org-recent-headings-helm-map
+     (let ((map (copy-keymap helm-map)))
+@@ -251,7 +250,7 @@ With prefix argument ARG, turn on if positive, otherwise off."
+     "Keymap for `helm-source-org-recent-headings'.")
+ 
+   (defvar helm-source-org-recent-headings
+-    (helm-build-sync-source " Recent Org headings"
++    (helm-make-source " Recent Org headings" 'helm-source-sync
+       :candidates (lambda ()
+                     (org-recent-headings--prepare-list)
+                     org-recent-headings-list)
+@@ -297,16 +296,54 @@ With prefix argument ARG, turn on if positive, otherwise off."
+ 
+ ;;;;; Ivy
+ 
+-(with-eval-after-load 'ivy
++(declare-function ivy-read "ext:ivy")
++(declare-function ivy-set-actions "ext:ivy")
+ 
+-  ;; TODO: Might need to declare `ivy-completing-read' also, but I
+-  ;; haven't hit the error yet.
++(with-eval-after-load 'ivy
++  (defun org-recent-headings-make-tuple (entry)
++    "Make a tuple containing the display text of ENTRY paired with ENTRY."
++    (let* ((init-display (org-recent-headings-entry-display entry))
++           (heading-fragment (substring init-display
++                                        (next-property-change 0 init-display)))
++           (final-display (concat (org-recent-headings-entry-file entry)
++                                  ":"
++                                  heading-fragment)))
++      (cons final-display entry)))
++
++  (defun org-recent-headings--show-entry-indirect-ivy (cand)
++    "Ivy-friendly wrapper for org-recent-headings--show-entry-indirect."
++    (org-recent-headings--show-entry-indirect
++     (cdr cand)))
++  (defun org-recent-headings--show-entry-direct-ivy (cand)
++    "Ivy-friendly wrapper for org-recent-headings--show-entry-direct."
++    (org-recent-headings--show-entry-direct
++     (cdr cand)))
++  (defun org-recent-headings--bookmark-entry-ivy (cand)
++    "Ivy-friendly wrapper for org-recent-headings--bookmark-entry"
++    (org-recent-headings--bookmark-entry
++     (cdr cand)))
++  (defun org-recent-headings--show-entry-default-ivy (cand)
++    "Ivy-friendly wrapper for org-recent-headings--show-entry-default."
++    (funcall org-recent-headings-show-entry-function
++             (cdr cand)))
+ 
+   (defun org-recent-headings-ivy ()
+     "Choose from recent Org headings with Ivy."
+     (interactive)
+-    (let ((completing-read-function  #'ivy-completing-read))
+-      (org-recent-headings))))
++    (ivy-read "Recent Org headings: "
++              (progn
++                (org-recent-headings--prepare-list)
++                (-map #'org-recent-headings-make-tuple
++                      org-recent-headings-list))
++              :history 'org-recent-headings-ivy-history
++              :caller 'org-recent-headings-ivy
++              :action 'org-recent-headings--show-entry-default-ivy))
++
++  (ivy-set-actions
++   'org-recent-headings-ivy
++   '(("n" org-recent-headings--show-entry-indirect-ivy "show in indirect buffer")
++     ("d" org-recent-headings--show-entry-direct-ivy "show in direct buffer")
++     ("b" org-recent-headings--bookmark-entry-ivy "bookmark heading"))))
+ 
+ ;;;; Functions
+ 
+-- 
+2.22.0
+
-- 
2.23.0