unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 1cfc31b8b4707a0704e483dbc93a498405273951 6871 bytes (raw)
name: gnu/packages/patches/emacs-org-recent-headings.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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


debug log:

solving 1cfc31b8b4 ...
found 1cfc31b8b4 in https://yhetil.org/guix-patches/CAAc=MEycq2ivBcsxBBSk24LfQpt=SS2=guU9YfZnDL9_G--G6w@mail.gmail.com/

applying [1/1] https://yhetil.org/guix-patches/CAAc=MEycq2ivBcsxBBSk24LfQpt=SS2=guU9YfZnDL9_G--G6w@mail.gmail.com/
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

1:26: trailing whitespace.
 
1:28: trailing whitespace.
 
1:67: trailing whitespace.
 
1:74: trailing whitespace.
 
1:82: trailing whitespace.
 
Checking patch gnu/packages/patches/emacs-org-recent-headings.patch...
Applied patch gnu/packages/patches/emacs-org-recent-headings.patch cleanly.
warning: squelched 7 whitespace errors
warning: 12 lines add whitespace errors.

index at:
100644 1cfc31b8b4707a0704e483dbc93a498405273951	gnu/packages/patches/emacs-org-recent-headings.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).