[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/rec-mode c72ec31 67/98: rec-mode: initial version of th
From: |
Stefan Monnier |
Subject: |
[elpa] externals/rec-mode c72ec31 67/98: rec-mode: initial version of the summary mode |
Date: |
Thu, 12 Nov 2020 13:18:42 -0500 (EST) |
branch: externals/rec-mode
commit c72ec31bcbbeb2a366f093a324108db4648a576c
Author: Jose E. Marchesi <jemarch@gnu.org>
Commit: Antoine Kalmbach <ane@iki.fi>
rec-mode: initial version of the summary mode
---
etc/rec-mode.el | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/etc/rec-mode.el b/etc/rec-mode.el
index 3eee02f..e0d663a 100644
--- a/etc/rec-mode.el
+++ b/etc/rec-mode.el
@@ -152,6 +152,7 @@ hidden by default in navigation mode.")
(define-key map "\C-cc" 'rec-cmd-compile)
(define-key map "\C-csq" 'rec-cmd-select-fast)
(define-key map "\C-css" 'rec-cmd-select-sex)
+ (define-key map "\C-ch" 'rec-cmd-show-summary)
(define-key map "\C-cI" 'rec-cmd-show-info)
(define-key map "\C-cf\C-w" 'rec-cmd-kill-field)
(define-key map "\C-cf\M-w" 'rec-cmd-copy-field)
@@ -185,6 +186,7 @@ hidden by default in navigation mode.")
(define-key map "f\M-w" 'rec-cmd-copy-field)
(define-key map "sq" 'rec-cmd-select-fast)
(define-key map "ss" 'rec-cmd-select-sex)
+ (define-key map "h" 'rec-cmd-show-summary)
(define-key map "\C-ct" 'rec-find-type)
;; (define-key map [remap move-beginning-of-line]
'rec-cmd-beginning-of-line)
(define-key map [remap undo] 'rec-cmd-undo)
@@ -1320,6 +1322,35 @@ Each character should identify only one name."
(throw 'exit t)))))
result)))
+;;;; Summary mode
+
+(defvar rec-summary-mode-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map tabulated-list-mode-map)
+ (define-key map "\C-m" 'foo)
+ map)
+ "Local keymap for `rec-summary-mode' buffers.")
+
+(define-derived-mode rec-summary-mode tabulated-list-mode "Rec Summary"
+ "Major mode for summarizing the contents of a recfile.
+\\<rec-summary-mode-map>
+\\{rec-summary-mode-map}"
+ (setq tabulated-list-format nil)
+ (setq tabulated-list-padding 2)
+ (setq tabulated-list-sort-key nil)
+ (tabulated-list-init-header))
+
+(defun rec-summary-populate (entries)
+ "Populate a rec-mode summary buffer with the data in ENTRIES.
+
+The data has the same structure than `tabulated-list-entries'."
+ (setq tabulated-list-format [("Id" 18 nil) ("Type" 5 nil) ("Need" 5 nil)
("Validation" 10 nil) ("Section" 20 nil) ("ImplV" 5 nil)])
+ (setq tabulated-list-padding 2)
+ (setq tabulated-list-sort-key (cons "Id" nil))
+ (tabulated-list-init-header)
+ (setq tabulated-list-entries entries)
+ (tabulated-list-print nil))
+
;;;; Rec Idle mode
;;
;; This section is heavily inspired in semantic-idle.el
@@ -1504,7 +1535,7 @@ ARGS contains the arguments to pass to the program."
(setq args (cons "-i" args)))
(when uniq
(setq args (cons "-U" args)))
- (when (and (not fex) (not group-by) (not sort-by))
+ (when (and (not group-by) (not sort-by))
(setq args (cons "--print-sexps" args)))
;; Call 'recsel' to perform the query.
(setq status (apply #'call-process-region
@@ -2108,6 +2139,28 @@ This command is especially useful with enumerated types."
(message "record copied to kill ring"))
(message "Not in a record"))))
+(defun rec-cmd-show-summary ()
+ "Show a window with a summary of the contents of the current
+record set."
+ (interactive)
+ (let* ((query (rec-query :fex "Id,Type,Need,Validation,Section,ImplV"))
+ (summary-list (mapcar (lambda (elt)
+ (list nil (vconcat (rec-record-assoc "Id" elt)
+ (rec-record-assoc "Type"
elt)
+ (rec-record-assoc "Need"
elt)
+ (rec-record-assoc
"Validation" elt)
+ (rec-record-assoc
"Section" elt)
+ (rec-record-assoc "ImplV"
elt))))
+ query)))
+ ;; Create the summary window if it does not exist and populate
+ ;; it.
+ (let ((buf (get-buffer-create "Rec Summary")))
+ (switch-to-buffer-other-window buf)
+ (let ((buffer-read-only nil))
+ (delete-region (point-min) (point-max))
+ (rec-summary-mode)
+ (rec-summary-populate summary-list)))))
+
;;;; Interacting with other modes
(defun rec-log-current-defun ()
- [elpa] externals/rec-mode 4413688 38/98: rec-mode: new functions returning properties of the current record set., (continued)
- [elpa] externals/rec-mode 4413688 38/98: rec-mode: new functions returning properties of the current record set., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 1982af5 42/98: rec-mode: allow the user to cancel the edit date operation by quitting the calendar window., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode eba1923 36/98: rec-mode: presentation of continuation lines in navigation modes, and other improvements., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 87abd92 49/98: rec-mode: new command rec-cmd-statistics., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 7b1a375 53/98: rec-mode: provide a sensible log-current-defun for the add-log function., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 33e106f 54/98: rec-mode: improve rec-log-current-defun so it works in all cases., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode da7b8c0 57/98: rec-mode: rec-end-of-field-pos now works properly when a field ends with the end of file mark., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode e20b7dd 63/98: rec-mode: don't hide continuation lines in editing modes after editing a field., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode f39f1a0 66/98: rec-mode: be smart assigning letters to enumerated entries., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode bb07fa5 47/98: rec-mode: support for undo in navigation mode., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode c72ec31 67/98: rec-mode: initial version of the summary mode,
Stefan Monnier <=
- [elpa] externals/rec-mode 99e3e62 68/98: rec-mode: more work in the summary mode., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode b389387 97/98: Escape plus sign in regexp, Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 849edd6 91/98: Move files to the root directory, Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 7ca1168 06/98: rec-mode.el, Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode b77d494 30/98: rec-mode: avoid security problems in calls to message by using %s., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 37e53b6 31/98: rec-mode: complete support for editing fields storing enumerated values., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode debbdd5 19/98: Time-stamp marks removed from the entire codebase and syntax checks fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 0cf9416 22/98: rec-mode: don't use a fixed list of keywords when font-locking special fields and other minor fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode d4ff2b1 32/98: rec-mode: support editing boolean fields as special enum values., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 99c7c8e 37/98: rec-mode: bug affecting the hiding of continuation line markers fixed., Stefan Monnier, 2020/11/12