[O] [PATCH] New version of org-velocity

2014-10-27 Thread Paul Rodriguez
This is a new version of org-velocity. Principally it differs in using
cl-lib and lexical binding, but there are also some minor bugfixes for
presenting results on very large screens and compatibility with evil-mode.

Also, for anyone interested in org-velocity: there is now a development
repository on GitHub: <https://github.com/ruricolist/org-velocity>.

Paul Rodriguez
From 5cac25a0d21867bce9c6a24e10dff190ed92b566 Mon Sep 17 00:00:00 2001
From: "Paul M. Rodriguez" 
Date: Sun, 26 Oct 2014 17:13:18 -0500
Subject: [PATCH] New version of Org-Velocity

---
 contrib/lisp/org-velocity.el |  309 ++
 1 file changed, 163 insertions(+), 146 deletions(-)

diff --git a/contrib/lisp/org-velocity.el b/contrib/lisp/org-velocity.el
index e6788c6..a7820f1 100644
--- a/contrib/lisp/org-velocity.el
+++ b/contrib/lisp/org-velocity.el
@@ -1,10 +1,10 @@
-;;; org-velocity.el --- something like Notational Velocity for Org.
+;;; org-velocity.el --- something like Notational Velocity for Org. -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2010-2014 Paul M. Rodriguez
 
 ;; Author: Paul M. Rodriguez 
 ;; Created: 2010-05-05
-;; Version: 3.0
+;; Version: 4.0
 
 ;; This file is not part of GNU Emacs.
 
@@ -64,7 +64,7 @@
 (require 'button)
 (require 'electric)
 (require 'dabbrev)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (defgroup org-velocity nil
   "Notational Velocity-style interface for Org."
@@ -133,9 +133,9 @@ file."
   "Match on whole phrase, any word, or all words?"
   :group 'org-velocity
   :type '(choice
-	  (const :tag "Match whole phrase" phrase)
-	  (const :tag "Match any word" any)
-	  (const :tag "Match all words" all)
+  (const :tag "Match whole phrase" phrase)
+  (const :tag "Match any word" any)
+  (const :tag "Match all words" all)
   (const :tag "Match a regular expression" regexp))
   :safe (lambda (v) (memq v '(phrase any all regexp
 
@@ -152,6 +152,17 @@ See the documentation for `org-capture-templates'."
   :group 'org-velocity
   :type (or (get 'org-capture-templates 'custom-type) 'list))
 
+(defcustom org-velocity-heading-level 1
+  "Only match headings at this level or higher.
+0 means to match headings at any level."
+  :group 'org-velocity
+  :type 'integer
+  :safe (lambda (x)
+  (and (integerp x)
+   (>= x 0
+
+(defvar crm-separator)  ;Ensure dynamic binding.
+
 (defsubst org-velocity-grab-preview ()
   "Grab preview of a subtree.
 The length of the preview is determined by `window-width'.
@@ -172,14 +183,14 @@ Replace all contiguous whitespace with single spaces."
 (point-max
  " ")))
 
-(defstruct org-velocity-heading buffer position name level preview)
+(cl-defstruct org-velocity-heading buffer position name level preview)
 
 (defsubst org-velocity-nearest-heading (position)
   "Return last heading at POSITION.
 If there is no last heading, return nil."
   (save-excursion
 (goto-char position)
-(re-search-backward org-velocity-heading-regexp)
+(re-search-backward (org-velocity-heading-regexp))
 (let ((components (org-heading-components)))
   (make-org-velocity-heading
:buffer (current-buffer)
@@ -191,15 +202,18 @@ If there is no last heading, return nil."
 
 (defconst org-velocity-index
   (eval-when-compile
-(nconc (number-sequence 49 57) 	;numbers
+(nconc (number-sequence 49 57)  ;numbers
(number-sequence 97 122)	;lowercase letters
(number-sequence 65 90)))	;uppercase letters
   "List of chars for indexing results.")
 
 (defconst org-velocity-match-buffer-name "*Velocity matches*")
 
-(defconst org-velocity-heading-regexp "^\\* "
-  "Regexp to match only top-level headings.")
+(cl-defun org-velocity-heading-regexp (&optional (level org-velocity-heading-level))
+  "Regexp to match headings at LEVEL or deeper."
+  (if (zerop level)
+  "^\\*+ "
+(format "^\\*\\{1,%d\\} " level)))
 
 (defvar org-velocity-search nil
   "Variable to bind to current search.")
@@ -223,12 +237,6 @@ of the base buffer; in the latter, return the file name of
   (with-current-buffer (window-buffer (active-minibuffer-window))
 (minibuffer-contents
 
-(defsubst org-velocity-singlep (object)
-  "Return t when OBJECT is a list or sequence of one element."
-  (if (consp object)
-  (null (cdr object))
-(= (length object) 1)))
-
 (defun org-velocity-bucket-file ()
   "Return the proper file for Org-Velocity to search.
 If `org-velocity-always-use-bucket' is t, use bucket file;
@@ -260,17 +268,22 @@ use it."
   "Return the proper buffer for O

Re: [O] [PATCH] New version of org-velocity

2014-11-02 Thread Paul Rodriguez
I'm afraid I don't understand the question. Is there a problem with the
patch?

Paul Rodriguez.


On Thu, Oct 30, 2014 at 2:18 PM, Marco Wahl  wrote:

> Hello Paul,
>
> Paul Rodriguez  writes:
>
> > This is a new version of org-velocity. Principally it differs in using
> > cl-lib and lexical binding, but there are also some minor bugfixes for
> > presenting results on very large screens and compatibility with
> > evil-mode.
>
> Thanks for sharing.
>
> Is there any reason not bringing your new version into the master
> branch?
>
>
> Best regards,  Marco
> --
> http://www.wahlzone.de
> GPG: 0x0A3AE6F2
>


Re: [O] [PATCH] New version of org-velocity

2014-11-02 Thread Paul Rodriguez
I am not a committer. Previously I've always sent in new versions of
org-velocity as patches, following the procedure on the Org wiki. I don't
usually follow the mailing list, so perhaps the procedure for handling
contributions has changed without my noticing. If so I'm happy to adjust.

Paul Rodriguez.

On Fri, Oct 31, 2014 at 2:58 AM, Marco Wahl  wrote:

> Paul Rodriguez  writes:
>
> > I'm afraid I don't understand the question. Is there a problem with the
> > patch?
>
> AFAICS there is no problem with your patch.
>
> I just wonder about how your patch could be applied to the repository.
> Can you do this?
>
>
> Best regards,  Marco
> --
> http://www.wahlzone.de
> GPG: 0x0A3AE6F2
>


[O] [PATCH] New version of org-velocity

2015-12-14 Thread Paul Rodriguez
This updates the version of org-velocity in contrib to the latest version.

The new version supports an Ido-like style of refining searches
interactively, and changes the default behavior to better accommodate users
who use org-velocity for navigation instead of note-taking.

Paul Rodriguez
From 6b073644a65a6a145c2b916c258fe05b68ac3e48 Mon Sep 17 00:00:00 2001
From: "Paul M. Rodriguez" 
Date: Mon, 14 Dec 2015 17:51:40 -0600
Subject: [PATCH] org-velocity: New version of org-velocity.

* contrib/lisp/org-velocity.el: New version.
---
 contrib/lisp/org-velocity.el | 387 ++-
 1 file changed, 233 insertions(+), 154 deletions(-)

diff --git a/contrib/lisp/org-velocity.el b/contrib/lisp/org-velocity.el
index a7820f1..bfc4d6c 100644
--- a/contrib/lisp/org-velocity.el
+++ b/contrib/lisp/org-velocity.el
@@ -4,7 +4,7 @@
 
 ;; Author: Paul M. Rodriguez 
 ;; Created: 2010-05-05
-;; Version: 4.0
+;; Version: 4.1
 
 ;; This file is not part of GNU Emacs.
 
@@ -78,12 +78,6 @@
   :group 'org-velocity
   :type 'file)
 
-(defcustom org-velocity-search-is-incremental t
-  "Show results incrementally when possible?"
-  :group 'org-velocity
-  :type 'boolean
-  :safe 'booleanp)
-
 (defcustom org-velocity-show-previews t
   "Show previews of the text of each heading?"
   :group 'velocity
@@ -168,20 +162,27 @@ See the documentation for `org-capture-templates'."
 The length of the preview is determined by `window-width'.
 
 Replace all contiguous whitespace with single spaces."
-  (let ((start (progn
- (forward-line 1)
- (if (looking-at org-property-start-re)
- (re-search-forward org-property-end-re)
-   (1- (point))
-(mapconcat
- #'identity
- (split-string
-  (buffer-substring-no-properties
-   start
-   (min
-(+ start (window-width))
-(point-max
- " ")))
+  (let* ((start (progn
+  (forward-line 1)
+  (if (looking-at org-property-start-re)
+  (re-search-forward org-property-end-re)
+(1- (point)
+ (string+props (buffer-substring
+start
+(min
+ (+ start (window-width))
+ (point-max)
+;; We want to preserve the text properties so that, for example,
+;; we don't end up with the raw text of links in the preview.
+(with-temp-buffer
+  (insert string+props)
+  (goto-char (point-min))
+  (save-match-data
+(while (re-search-forward split-string-default-separators
+  (point-max)
+  t)
+  (replace-match " ")))
+  (buffer-string
 
 (cl-defstruct org-velocity-heading buffer position name level preview)
 
@@ -233,9 +234,16 @@ of the base buffer; in the latter, return the file name of
 
 (defun org-velocity-minibuffer-contents ()
   "Return the contents of the minibuffer when it is active."
-  (if (active-minibuffer-window)
-  (with-current-buffer (window-buffer (active-minibuffer-window))
-(minibuffer-contents
+  (when (active-minibuffer-window)
+(with-current-buffer (window-buffer (active-minibuffer-window))
+  (minibuffer-contents
+
+(defun org-velocity-nix-minibuffer ()
+  "Return the contents of the minibuffer and clear it."
+  (when (active-minibuffer-window)
+(with-current-buffer (window-buffer (active-minibuffer-window))
+  (prog1 (minibuffer-contents)
+(delete-minibuffer-contents)
 
 (defun org-velocity-bucket-file ()
   "Return the proper file for Org-Velocity to search.
@@ -259,6 +267,7 @@ use it."
 (error "No bucket and not an Org file"))
 
 (defvar org-velocity-bucket-buffer nil)
+(defvar org-velocity-navigating nil)
 
 (defsubst org-velocity-bucket-buffer ()
   (or org-velocity-bucket-buffer
@@ -271,9 +280,6 @@ use it."
 (defsubst org-velocity-match-window ()
   (get-buffer-window (org-velocity-match-buffer)))
 
-(defsubst org-velocity-match-staging-buffer ()
-  (get-buffer-create " Velocity matches"))
-
 (defun org-velocity-beginning-of-headings ()
   "Goto the start of the first heading."
   (goto-char (point-min))
@@ -310,29 +316,47 @@ use it."
 (make-variable-buffer-local 'org-velocity-saved-winconf)
 
 (defun org-velocity-edit-entry (heading)
+  (if org-velocity-navigating
+  (org-velocity-edit-entry/inline heading)
+(org-velocity-edit-entry/indirect heading)))
+
+(cl-defun org-velocity-goto-entry (heading &key narrow)
+  (goto-char (org-velocity-heading-position heading))
+  (save-excursion
+(when narrow
+  (org-narrow-to-subtree))
+(outline-show-all)))
+
+(defun org-velocity-edit-entry/inline (heading)
+  &q