From 6baf69ba88998595940daab8896724ba430a4d2a Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Fri, 6 Mar 2015 02:03:21 -0500 Subject: Remove bog-goto-citekey-heading-in-buffer This command wasn't too useful because, within a buffer, a citekey heading can easily be jumped to with the standard org-goto interface. Also, bog-goto-citekey-heading-in-notes will check the current file first, so it behaves the same as bog-goto-citekey-heading-in-buffer, except that it prompts with all citekeys instead of just those in the current buffer. Because a prompt limited to citekeys from the current buffer can be useful, make this prompt available with a double C-u. --- NEWS | 10 ++++++---- bog.el | 43 ++++++++++--------------------------------- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/NEWS b/NEWS index a19df0e..d3f851e 100644 --- a/NEWS +++ b/NEWS @@ -47,8 +47,7 @@ - =bog-create-combined-bib= now supports collecting citekeys from marked files in a Dired buffer. -- =bog-goto-citekey-heading-in-buffer= and - =bog-goto-citekey-heading-in-notes= now work when citekeys are +- =bog-goto-citekey-heading-in-notes= now works when citekeys are stored are stored as property values. - New command =bog-list-duplicate-heading-citekeys= finds citekeys @@ -66,8 +65,11 @@ ** Other changes -- =bog-goto-citekey-heading-in-buffer= and - =bog-goto-citekey-heading-in-notes= will now widen the buffer if the +- The command =bog-goto-citekey-heading-in-buffer= has been removed. + Similar behavior is now available when a double C-u is used as the + prefix argument to =bog-goto-citekey-heading-in-notes=. + +- =bog-goto-citekey-heading-in-notes= now widens the buffer if the heading is outside of the narrowed region. - The format for citekeys is now restricted to letters, digits, diff --git a/bog.el b/bog.el index c6fc564..adfe25c 100644 --- a/bog.el +++ b/bog.el @@ -873,31 +873,6 @@ Groups are specified by `bog-citekey-web-search-groups'." ;;; Notes-related -(defun bog-goto-citekey-heading-in-buffer (&optional no-context) - "Find citekey heading in this buffer. - -The citekey is taken from the text under point if it matches -`bog-citekey-format'. - -With prefix argument NO-CONTEXT, prompt with citekeys that have a -heading in the current buffer. Do the same if locating a citekey -from context fails. - -If the heading is found outside any current narrowing of the -buffer, the narrowing is removed." - (interactive "P") - (let* ((citekey (bog-citekey-from-point-or-buffer-headings no-context)) - (pos (bog--find-citekey-heading-in-buffer citekey))) - (if pos - (progn - (when (or (< pos (point-min)) - (> pos (point-max))) - (widen)) - (org-mark-ring-push) - (goto-char pos) - (org-show-context)) - (message "Heading for %s not found in buffer" citekey)))) - (defun bog--find-citekey-heading-in-buffer (citekey &optional pos-only) "Return the marker of heading for CITEKEY. CITEKEY can either be the heading title or the property value of @@ -934,9 +909,11 @@ is non-nil, return the position instead of a marker." The citekey is taken from the text under point if it matches `bog-citekey-format'. -With prefix argument NO-CONTEXT, prompt with citekeys that have a -heading in any note file. Do the same if locating a citekey from -context fails. +When the prefix argument NO-CONTEXT is given by a single +\\[universal-argument], prompt with citekeys that have a heading +in any note file. Do the same if locating a citekey from context +fails. With a double \\[universal-argument], restrict the prompt +to citekeys that have a heading in the current buffer. If the citekey prompt is slow to appear, consider enabling the `heading' category in `bog-use-citekey-cache'. @@ -944,7 +921,9 @@ If the citekey prompt is slow to appear, consider enabling the If the heading is found outside any current narrowing of the buffer, the narrowing is removed." (interactive "P") - (let* ((citekey (bog-citekey-from-point-or-all-headings no-context)) + (let* ((citekey (if (equal no-context '(16)) + (bog-citekey-from-point-or-buffer-headings no-context) + (bog-citekey-from-point-or-all-headings no-context))) (marker (bog--find-citekey-heading-in-notes citekey))) (if marker (progn @@ -1324,8 +1303,7 @@ chosen." (define-key prefix-map "c" 'bog-search-notes-for-citekey) (define-key prefix-map "f" 'bog-find-citekey-file) (define-key prefix-map "g" 'bog-search-citekey-on-web) - (define-key prefix-map "h" 'bog-goto-citekey-heading-in-buffer) - (define-key prefix-map "H" 'bog-goto-citekey-heading-in-notes) + (define-key prefix-map "h" 'bog-goto-citekey-heading-in-notes) (define-key prefix-map "i" 'bog-citekey-tree-to-indirect-buffer) (define-key prefix-map "j" 'bog-jump-to-topic-heading) (define-key prefix-map "l" 'bog-open-citekey-link) @@ -1372,8 +1350,7 @@ if ARG is omitted or nil. (define-key map "c" 'bog-search-notes-for-citekey) (define-key map "f" 'bog-find-citekey-file) (define-key map "g" 'bog-search-citekey-on-web) - (define-key map "h" 'bog-goto-citekey-heading-in-buffer) - (define-key map "H" 'bog-goto-citekey-heading-in-notes) + (define-key map "h" 'bog-goto-citekey-heading-in-notes) (define-key map "i" 'bog-citekey-tree-to-indirect-buffer) (define-key map "j" 'bog-jump-to-topic-heading) (define-key map "l" 'bog-open-citekey-link) -- cgit v1.2.3 From 4724604e72396d6cdf4371f0263ed55b2a646d40 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Fri, 6 Mar 2015 02:06:45 -0500 Subject: Move bog-goto-citekey-heading-in-notes Join helper functions that used to be positioned near bog-goto-citekey-heading-in-buffer [1] with bog-goto-citekey-heading-in-notes helper functions. [1] 6baf69ba88998595940daab8896724ba430a4d2a --- bog.el | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/bog.el b/bog.el index adfe25c..6bd526d 100644 --- a/bog.el +++ b/bog.el @@ -873,36 +873,6 @@ Groups are specified by `bog-citekey-web-search-groups'." ;;; Notes-related -(defun bog--find-citekey-heading-in-buffer (citekey &optional pos-only) - "Return the marker of heading for CITEKEY. -CITEKEY can either be the heading title or the property value of -the key `bog-citekey-property'. If POS-ONLY is non-nil, return -the position instead of a marker." - (or (org-find-exact-headline-in-buffer citekey nil pos-only) - (bog--find-citekey-property-in-buffer citekey nil pos-only))) - -(defun bog--find-citekey-property-in-buffer (citekey &optional buffer pos-only) - "Return marker in BUFFER for heading with CITEKEY as a property value. -The property key must match `bog-citekey-property'. If POS-ONLY -is non-nil, return the position instead of a marker." - (with-current-buffer (or buffer (current-buffer)) - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (catch 'found - (while (re-search-forward (concat "\\b" citekey "\\b") nil t) - (save-excursion - (beginning-of-line) - (when (and (looking-at org-property-re) - (equal (downcase (match-string 2)) - (downcase bog-citekey-property))) - (org-back-to-heading t) - (throw 'found - (if pos-only - (point) - (move-marker (make-marker) (point)))))))))))) - (defun bog-goto-citekey-heading-in-notes (&optional no-context) "Find citekey heading in notes. @@ -935,6 +905,36 @@ buffer, the narrowing is removed." (org-show-context)) (message "Heading for %s not found in notes" citekey)))) +(defun bog--find-citekey-heading-in-buffer (citekey &optional pos-only) + "Return the marker of heading for CITEKEY. +CITEKEY can either be the heading title or the property value of +the key `bog-citekey-property'. If POS-ONLY is non-nil, return +the position instead of a marker." + (or (org-find-exact-headline-in-buffer citekey nil pos-only) + (bog--find-citekey-property-in-buffer citekey nil pos-only))) + +(defun bog--find-citekey-property-in-buffer (citekey &optional buffer pos-only) + "Return marker in BUFFER for heading with CITEKEY as a property value. +The property key must match `bog-citekey-property'. If POS-ONLY +is non-nil, return the position instead of a marker." + (with-current-buffer (or buffer (current-buffer)) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (catch 'found + (while (re-search-forward (concat "\\b" citekey "\\b") nil t) + (save-excursion + (beginning-of-line) + (when (and (looking-at org-property-re) + (equal (downcase (match-string 2)) + (downcase bog-citekey-property))) + (org-back-to-heading t) + (throw 'found + (if pos-only + (point) + (move-marker (make-marker) (point)))))))))))) + (defun bog--find-citekey-heading-in-notes (citekey) "Return the marker of heading for CITEKEY in notes. CITEKEY can either be the heading title or the property value of -- cgit v1.2.3