emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/rec-mode 2204ecc 40/98: rec-mode: support for editing d


From: Stefan Monnier
Subject: [elpa] externals/rec-mode 2204ecc 40/98: rec-mode: support for editing date fields using the calendar.
Date: Thu, 12 Nov 2020 13:18:36 -0500 (EST)

branch: externals/rec-mode
commit 2204eccbfef979eb613ae7b90ef3716cd39bf150
Author: Jose E. Marchesi <jemarch@gnu.org>
Commit: Antoine Kalmbach <ane@iki.fi>

    rec-mode: support for editing date fields using the calendar.
---
 etc/rec-mode.el | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/etc/rec-mode.el b/etc/rec-mode.el
index caf73df..ae1cfda 100644
--- a/etc/rec-mode.el
+++ b/etc/rec-mode.el
@@ -32,6 +32,7 @@
 
 (require 'compile)
 (require 'cl)
+(require 'calendar)
 
 ;;;; Customization
 
@@ -46,6 +47,12 @@ Valid values are `edit' and `navigation'.  The default is 
`navigation'"
   :type 'symbol
   :group 'rec-mode)
 
+(defcustom rec-popup-calendar t
+  "Whether to use a popup calendar to select dates when editing field
+values.  The default is `t'."
+  :type 'boolean
+  :group 'rec-mode)
+
 (defvar rec-max-lines-in-fields 15
   "Values of fields having more than the specified lines will be
 hidden by default in navigation mode.")
@@ -1544,6 +1551,28 @@ buffer"
                                           0
                                           field-name
                                           new-value)))))))
+         ((and (equal field-type-kind 'date) rec-popup-calendar)
+          (setq rec-field-name field-name)
+          (setq rec-prev-buffer prev-buffer)
+          (setq rec-pointer pointer)
+          (calendar)
+          (let ((old-map (current-local-map))
+                (map (copy-keymap calendar-mode-map)))
+            (define-key map (kbd "RET")
+              `(lambda () (interactive)
+                 (let* ((date (calendar-cursor-to-date))
+                        (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) 
(nth 2 date))))
+                   (use-local-map (quote ,old-map))
+                   (calendar-exit)
+                   (set-buffer rec-prev-buffer)
+                   (let ((buffer-read-only nil))
+                     (rec-delete-field)
+                     (save-excursion
+                       (rec-insert-field (list 'field
+                                               0
+                                               rec-field-name
+                                               (format-time-string "%Y-%m-%d" 
time))))))))
+            (use-local-map map)))
          (t
           (setq edit-buf (get-buffer-create "Rec Edit"))
           (set-buffer edit-buf)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]