From e90f9ca45f324f59bfabc501e7d65e0bab8a6add Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 9 Dec 2014 00:11:48 -0500 Subject: Replace some when's with and's --- bog.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'bog.el') diff --git a/bog.el b/bog.el index 22178fc..5f7fee0 100644 --- a/bog.el +++ b/bog.el @@ -249,8 +249,8 @@ be preceded by a characters in `bog-allowed-before-citekey'." (unless (bobp) (re-search-backward bog-allowed-before-citekey) (forward-char 1)) - (when (looking-at bog-citekey-format) - (match-string-no-properties 0)))) + (and (looking-at bog-citekey-format) + (match-string-no-properties 0)))) (defun bog-citekey-from-surroundings () "Get the citekey from the context of the Org file." @@ -277,17 +277,19 @@ be preceded by a characters in `bog-allowed-before-citekey'." "Retrieve citekey from heading title." (unless (org-before-first-heading-p) (let ((heading (org-no-properties (org-get-heading t t)))) - (when (bog-citekey-p heading) heading)))) + (and (bog-citekey-p heading) + heading)))) (defun bog-citekey-from-property () "Retrieve citekey from `bog-citekey-property'." (--when-let (org-entry-get (point) bog-citekey-property) - (when (bog-citekey-p it) it))) + (and (bog-citekey-p it) + it))) (defun bog-citekey-p (text) "Does TEXT match `bog-citekey-format'?" - (when (string-match-p (format "^%s$" bog-citekey-format) text) - t)) + (and (string-match-p (format "^%s$" bog-citekey-format) text) + t)) (defvar bog--all-citekeys nil) (defun bog-all-citekeys () @@ -446,8 +448,8 @@ used to control the default string used in the prompt." (defun bog-file-citekey (file) "Return leading citekey part from base name of FILE." (let ((fname (file-name-base file))) - (when (string-match (concat "^" bog-citekey-format) fname) - (match-string 0 fname)))) + (and (string-match (concat "^" bog-citekey-format) fname) + (match-string 0 fname)))) (defun bog-all-citekey-files () "Return list of all files in `bog-file-directory'." -- cgit v1.2.3