diff options
-rw-r--r-- | attic/counsel.org | 38 | ||||
-rw-r--r-- | lib/doc/jao-counsel-recoll.el | 60 | ||||
-rw-r--r-- | lib/doc/jao-org-links.el (renamed from lib/org/jao-org-links.el) | 1 | ||||
-rw-r--r-- | lib/doc/jao-org-notes.el (renamed from lib/org/jao-org-notes.el) | 0 | ||||
-rw-r--r-- | lib/org/jao-org-gnus.el | 72 | ||||
-rw-r--r-- | lib/org/jao-org-popup.el | 31 | ||||
-rw-r--r-- | lib/org/jao-org-utils.el | 43 | ||||
-rw-r--r-- | org.org | 36 |
8 files changed, 61 insertions, 220 deletions
diff --git a/attic/counsel.org b/attic/counsel.org index 5732fb7..6fbd591 100644 --- a/attic/counsel.org +++ b/attic/counsel.org @@ -64,13 +64,6 @@ :diminish) #+end_src * counsel add-ons -*** recoll - #+BEGIN_SRC emacs-lisp - (use-package jao-recoll) - (use-package jao-counsel-recoll - :after counsel - :bind (("C-c R" . jao-counsel-recoll))) - #+END_SRC *** notmuch #+begin_src emacs-lisp (use-package counsel-notmuch @@ -78,6 +71,37 @@ :config (with-eval-after-load "gnus-group" (define-key gnus-group-mode-map "Gg" 'counsel-notmuch))) #+end_src +*** recoll + #+begin_src emacs-lisp + (require 'jao-recoll) + (defvar jao-counsel-recoll--history nil) + (defun jao-counsel-recoll--function (str) + (let ((xs (counsel-recoll-function str))) + (cl-remove-if-not (lambda (x) (string-prefix-p "file://" x)) xs))) + + (defun jao-counsel-recoll (&optional initial-input) + (interactive) + (counsel-require-program "recoll") + (ivy-read "recoll: " 'jao-counsel-recoll--function + :initial-input initial-input + :dynamic-collection t + :history 'jao-counsel-recoll--history + :action (lambda (x) + (when (string-match "file://\\(.*\\)\\'" x) + (let ((file-name (match-string 1 x))) + (if (string-match "pdf$" x) + (jao-open-doc file-name) + (find-file file-name))))) + :unwind #'counsel-delete-process + :caller 'jao-counsel-recoll)) + + (defun jao-counsel-recoll--recoll (_s) (jao-recoll ivy-text)) + + (ivy-set-actions 'jao-counsel-recoll + '(("x" jao-counsel-recoll--recoll "List in buffer"))) + + (global-set-key (kbd "C-c R") #'jao-counsel-recoll) + #+end_src * ivy rich #+begin_src emacs-lisp (use-package ivy-rich diff --git a/lib/doc/jao-counsel-recoll.el b/lib/doc/jao-counsel-recoll.el deleted file mode 100644 index adae881..0000000 --- a/lib/doc/jao-counsel-recoll.el +++ /dev/null @@ -1,60 +0,0 @@ -;;; jao-counsel-recoll.el --- counsel and recoll -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 jao - -;; Author: jao <mail@jao.io> -;; Keywords: docs - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Helpers for using recoll with counsel - -;;; Code: - -(require 'jao-recoll) -(require 'counsel) -(require 'ivy) - -(defvar jao-counsel-recoll--history nil) -(defun jao-counsel-recoll--function (str) - (let ((xs (counsel-recoll-function str))) - (cl-remove-if-not (lambda (x) (string-prefix-p "file://" x)) xs))) - -;;;###autoload -(defun jao-counsel-recoll (&optional initial-input) - (interactive) - (counsel-require-program "recoll") - (ivy-read "recoll: " 'jao-counsel-recoll--function - :initial-input initial-input - :dynamic-collection t - :history 'jao-counsel-recoll--history - :action (lambda (x) - (when (string-match "file://\\(.*\\)\\'" x) - (let ((file-name (match-string 1 x))) - (if (string-match "pdf$" x) - (jao-open-doc file-name) - (find-file file-name))))) - :unwind #'counsel-delete-process - :caller 'jao-counsel-recoll)) - -(defun jao-counsel-recoll--recoll (_s) (jao-recoll ivy-text)) - -(ivy-set-actions 'jao-counsel-recoll - '(("x" jao-counsel-recoll--recoll "List in buffer"))) - - -(provide 'jao-counsel-recoll) -;;; jao-counsel-recoll.el ends here diff --git a/lib/org/jao-org-links.el b/lib/doc/jao-org-links.el index 2882f7a..ee6af7c 100644 --- a/lib/org/jao-org-links.el +++ b/lib/doc/jao-org-links.el @@ -1,6 +1,5 @@ ;; -*- lexical-binding: t; -*- -(require 'jao-org-utils) (require 'jao-maildir) (require 'pdf-info) diff --git a/lib/org/jao-org-notes.el b/lib/doc/jao-org-notes.el index a1b9dbe..a1b9dbe 100644 --- a/lib/org/jao-org-notes.el +++ b/lib/doc/jao-org-notes.el diff --git a/lib/org/jao-org-gnus.el b/lib/org/jao-org-gnus.el deleted file mode 100644 index cdeec65..0000000 --- a/lib/org/jao-org-gnus.el +++ /dev/null @@ -1,72 +0,0 @@ -;; Support for saving Gnus messages by Message-ID -(defun mde-org-gnus-save-by-mid () - (when (memq major-mode '(gnus-summary-mode gnus-article-mode)) - (when (eq major-mode 'gnus-article-mode) - (gnus-article-show-summary)) - (let* ((group gnus-newsgroup-name) - (method (gnus-find-method-for-group group))) - (when (memq (car method) '(nnml nntp)) - (let* ((article (gnus-summary-article-number)) - (header (gnus-summary-article-header article)) - (from (mail-header-from header)) - (message-id - (save-match-data - (let ((mid (mail-header-id header))) - (if (string-match "<\\(.*\\)>" mid) - (match-string 1 mid) - (error "Malformed message ID header %s" mid))))) - (date (mail-header-date header)) - (subject (gnus-summary-subject-string))) - (org-store-link-props :type "mid" :from from :subject subject - :message-id message-id :group group - :link (org-make-link "mid:" message-id)) - (apply 'org-store-link-props - :description (org-email-link-description) - org-store-link-plist) - t))))) - -(defvar mde-mid-resolve-methods '() - "List of methods to try when resolving message ID's. For Gnus, -it is a cons of 'gnus and the select (type and name).") -(setq mde-mid-resolve-methods - '((gnus nnml ""))) - -(defvar mde-org-gnus-open-level 1 - "Level at which Gnus is started when opening a link") -(defun mde-org-gnus-open-message-link (msgid) - "Open a message link with Gnus" - (require 'gnus) - (require 'org-table) - (catch 'method-found - (message "[MID linker] Resolving %s" msgid) - (dolist (method mde-mid-resolve-methods) - (cond - ((and (eq (car method) 'gnus) - (eq (cadr method) 'nnml)) - (funcall (cdr (assq 'gnus org-link-frame-setup)) - mde-org-gnus-open-level) - (when gnus-other-frame-object - (select-frame gnus-other-frame-object)) - (let* ((msg-info (nnml-find-group-number - (concat "<" msgid ">") - (cdr method))) - (group (and msg-info (car msg-info))) - (message (and msg-info (cdr msg-info))) - (qname (and group - (if (gnus-methods-equal-p - (cdr method) - gnus-select-method) - group - (gnus-group-full-name group (cdr method)))))) - (when msg-info - (gnus-summary-read-group qname nil t) - (gnus-summary-goto-article message nil t)) - (throw 'method-found t))) - (t (error "Unknown link type")))))) - -(eval-after-load 'org-gnus - '(progn - (add-to-list 'org-store-link-functions 'mde-org-gnus-save-by-mid) - (org-add-link-type "mid" 'mde-org-gnus-open-message-link))) - -(provide 'jao-org-gnus) diff --git a/lib/org/jao-org-popup.el b/lib/org/jao-org-popup.el deleted file mode 100644 index eb5b24d..0000000 --- a/lib/org/jao-org-popup.el +++ /dev/null @@ -1,31 +0,0 @@ -;;; frame popups -;; http://metajack.im/2008/12/30/gtd-capture-with-emacs-orgmode/ -(defsubst jao-remember--frame-p () - (equal "*Remember*" (frame-parameter nil 'name))) - -(defadvice remember-finalize (after delete-remember-frame activate) - "Advise remember-finalize to close the frame if it is the remember frame" - (when (jao-remember--frame-p) (delete-frame))) - -(defadvice remember-destroy (after delete-remember-frame activate) - "Advise remember-destroy to close the frame if it is the remember frame" - (when (jao-remember--frame-p) (delete-frame))) - -;; make the frame contain a single window. by default org-remember -;; splits the window. -(defun jao-remember--delete-other-windows () - (when (jao-remember--frame-p) (delete-other-windows))) - -(add-hook 'remember-mode-hook 'jao-remember--delete-other-windows) - -(defun make-remember-frame () - "Create a new frame and run org-remember" - (interactive) - (make-frame-on-display (getenv "DISPLAY") - '((name . "*Remember*") - (width . 80) - (height . 10))) - (select-frame-by-name "*Remember*") - (org-remember nil ?x)) - -(provide 'jao-org-popup)
\ No newline at end of file diff --git a/lib/org/jao-org-utils.el b/lib/org/jao-org-utils.el deleted file mode 100644 index 8d65ed7..0000000 --- a/lib/org/jao-org-utils.el +++ /dev/null @@ -1,43 +0,0 @@ -(require 'org) - -;;; links -(defun jao-org-link-at-point (&optional copy) - (when (thing-at-point-looking-at "\\[\\[\\([^]]+\\)\\]\\[[^]]+\\]\\]") - (when copy (kill-ring-save (match-beginning 1) (match-end 1))) - (match-string-no-properties 1))) - -(defun jao-org-copy-link-at-point () - (interactive) - (message "%s" (or (jao-org-link-at-point t) "No link at point"))) - -(defun jao-org-insert-link (url title) - (insert (format "[[%s][%s]]" url title))) - -;;; eldoc -(defun jao-org-eldoc--hook () - (set (make-local-variable 'eldoc-documentation-function) - 'jao-org-link-at-point) - (eldoc-mode)) - -;;;###autoload -(defun jao-org-utils-eldoc-setup () - (add-hook 'org-mode-hook 'jao-org-eldoc--hook)) - -;;; play fair with saveplace -(defun jao-org--show-if-hidden () - (when (outline-invisible-p) - (save-excursion - (outline-previous-visible-heading 1) - (org-show-subtree)))) - -;;; verifying org refile targets -(defun jao-org--refile-target-verify () - (not (looking-at-p ".*\\[\\[.+$"))) - -;;;###autoload -(defun jao-org-utils-setup () - (setq org-refile-target-verify-function 'jao-org--refile-target-verify) - (add-hook 'org-mode-hook 'jao-org--show-if-hidden t)) - - -(provide 'jao-org-utils) @@ -234,6 +234,18 @@ (require 'ol-info nil t) (setq org-link-abbrev-alist '(("jao.io" "https://jao.io/"))) + (defun jao-org-link-at-point (&optional copy) + (when (thing-at-point-looking-at "\\[\\[\\([^]]+\\)\\]\\[[^]]+\\]\\]") + (when copy (kill-ring-save (match-beginning 1) (match-end 1))) + (match-string-no-properties 1))) + + (defun jao-org-copy-link-at-point () + (interactive) + (message "%s" (or (jao-org-link-at-point t) "No link at point"))) + + (defun jao-org-insert-link (url title) + (insert (format "[[%s][%s]]" url title))) + (defun jao-insert-eww-link () "Look for last eww buffer and insert an org link to it." (interactive) @@ -241,22 +253,34 @@ (let ((lnk (with-current-buffer b (format "[[%s][%s]]" (eww-current-url) (jao-eww--title))))) (insert lnk)))) - #+end_src -* jao-org - #+begin_src emacs-lisp - (use-package jao-org-utils) (use-package jao-org-links :commands jao-org-links-setup :bind (("C-c T" . jao-org-insert-doc))) - (jao-org-utils-setup) - (jao-org-utils-eldoc-setup) (jao-org-links-setup jao-sink-dir) (with-eval-after-load "pdf-view" (define-key pdf-view-mode-map (kbd "C-c o") #'jao-org-pdf-goto-org) (define-key pdf-view-mode-map (kbd "C-c O") #'jao-org-pdf-goto-org*)) + + #+end_src +* Eldoc + #+begin_src emacs-lisp + (defun jao-org-eldoc--hook () + (set (make-local-variable 'eldoc-documentation-function) + 'jao-org-link-at-point) + (eldoc-mode)) + (add-hook 'org-mode-hook 'jao-org-eldoc--hook) + #+end_src +* Savedoc + #+begin_src emacs-lisp + (defun jao-org--show-if-hidden () + (when (outline-invisible-p) + (save-excursion + (outline-previous-visible-heading 1) + (org-show-subtree)))) + (add-hook 'org-mode-hook 'jao-org--show-if-hidden t) #+end_src * Geiser and org #+begin_src emacs-lisp |