branch: externals/rec-mode
commit cdf4a16bd4aab594351932561aa71bbec840873f
Author: Jose E. Marchesi <[email protected]>
Commit: Antoine Kalmbach <[email protected]>

    rec-mode: rec-cmd-count now suggests a default selection expression when 
invoked with a numeric prefix.
---
 etc/rec-mode.el | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/etc/rec-mode.el b/etc/rec-mode.el
index 3efc644..b77d304 100644
--- a/etc/rec-mode.el
+++ b/etc/rec-mode.el
@@ -1881,9 +1881,18 @@ records of the current type.
 If a numeric argument is used then prompt for a selection
 expression."
   (interactive "P")
-  (let ((sex (and (not (null n)) (read-from-minibuffer "Selection expression: 
"))))
+  (let* ((default-sex (let ((current-field (rec-current-field)))
+                        (when (and current-field
+                                   (not (string-match "\n" (rec-field-value 
current-field)))
+                                   (< (length (rec-field-value current-field)) 
20))
+                          (concat (rec-field-name current-field) " = '" 
(rec-field-value current-field) "'"))))
+         (sex (and (not (null n)) (read-from-minibuffer (concat "Selection 
expression"
+                                                                (if default-sex
+                                                                    (concat " 
(default " default-sex ")")
+                                                                  "")
+                                                                ": ")))))
     (when (equal sex "")
-      (setq sex nil))
+      (setq sex default-sex))
     (message "Counting records...")
     (let ((type (rec-record-type)))
       (message "%s" (concat (number-to-string (rec-count type sex))

Reply via email to