Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Faster navigation, fix interactive numeric arguments, allow customization of go-to-date #15

Merged
merged 2 commits into from

2 participants

@haselwarter

Hi,

I made the navigation functions accept numeric prefixes and bound "0" through "9" to `digit-argument', so that you can simply type "7 n" to jump forward by seven weeks.

Also I replaced "" in calfw-org with "RET", so that the return key and control-m have the same effect.

The last part allows for customization of the function prompting for the date in cfw:navi-goto-date-command': The original (default) read-"YYYY/MM/DD" and one usingorg-read-date' are available.

Philipp Hase... added some commits
Philipp Haselwarter Make navigation commands accept numeric arguments, bind keys 0-9 to run
`digit-argument', bind "." to go to today, use (kbd "RET") instead
of (kbd "<return>") to additionally make (kbd "C-m") work
2375195
Philipp Haselwarter Make the command used to read the date in `cfw:navi-goto-date-command…
…' customizable and provide two possible functions
81bbea8
@kiwanami kiwanami merged commit a9b6615 into from
@kiwanami
Owner

Hi,
Thank you for your nice patches!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 8, 2011
  1. Make navigation commands accept numeric arguments, bind keys 0-9 to run

    Philipp Haselwarter authored
    `digit-argument', bind "." to go to today, use (kbd "RET") instead
    of (kbd "<return>") to additionally make (kbd "C-m") work
  2. Make the command used to read the date in `cfw:navi-goto-date-command…

    Philipp Haselwarter authored
    …' customizable and provide two possible functions
This page is out of date. Refresh to see the latest.
Showing with 41 additions and 12 deletions.
  1. +6 −1 calfw-org.el
  2. +35 −11 calfw.el
View
7 calfw-org.el
@@ -69,7 +69,7 @@
(defvar cfw:org-text-keymap
(let ((map (make-sparse-keymap)))
(define-key map [mouse-1] 'cfw:org-onclick)
- (define-key map (kbd "<return>") 'cfw:org-onclick)
+ (define-key map (kbd "RET") 'cfw:org-onclick)
map)
"key map on the calendar item text.")
@@ -217,6 +217,11 @@ TEXT1 < TEXT2. This function makes no-time items in front of timed-items."
;; exec org-remember here?
))
+(defun cfw:org-read-date-command ()
+ "Move the cursor to the specified date."
+ (interactive)
+ (cfw:emacs-to-calendar (org-read-date nil 'to-time)))
+
;; (progn (eval-current-buffer) (cfw:open-org-calendar))
;; (setq org-agenda-files '("./org-samples/complex.org"))
View
46 calfw.el
@@ -110,6 +110,12 @@
:group 'cfw
:type 'character)
+(defcustom cfw:read-date-command 'cfw:read-date-command-simple
+ "The command used to read the date in `cfw:navi-goto-date-command',
+for example `cfw:read-date-command-simple' or `cfw:org-read-date-command'."
+ :group 'cfw
+ :type 'function)
+
;;; Faces
(defface cfw:face-title
@@ -347,6 +353,11 @@ ones of DATE2. Otherwise is `nil'."
"Transform the string format YYYY/MM/DD to a calendar date value."
(cfw:emacs-to-calendar (cfw:parsetime-emacs str)))
+(defun cfw:read-date-command-simple (string-date)
+ "Move the cursor to the specified date."
+ (interactive "sInput Date (YYYY/MM/DD): ")
+ (cfw:parsetime string-date))
+
(defun cfw:enumerate-days (begin end)
"Enumerate date objects between BEGIN and END."
(when (> (calendar-absolute-from-gregorian begin)
@@ -2157,6 +2168,7 @@ calendar view."
("g" . cfw:navi-goto-date-command)
("t" . cfw:navi-goto-today-command)
+ ("." . cfw:navi-goto-today-command)
("TAB" . cfw:navi-next-item-command)
@@ -2171,6 +2183,18 @@ calendar view."
([mouse-1] . cfw:navi-on-click)
("q" . bury-buffer)
+
+ ("0" . digit-argument)
+ ("1" . digit-argument)
+ ("2" . digit-argument)
+ ("3" . digit-argument)
+ ("4" . digit-argument)
+ ("5" . digit-argument)
+ ("6" . digit-argument)
+ ("7" . digit-argument)
+ ("8" . digit-argument)
+ ("9" . digit-argument)
+
)) "Default key map of calendar views.")
(defun cfw:calendar-mode-map (&optional custom-map)
@@ -2275,10 +2299,10 @@ With prefix arg NO-RESIZE, don't fit calendar to window size."
(cfw:week-end-date
(cfw:cp-get-selected-date (cfw:cp-get-component))))))
-(defun cfw:navi-goto-date-command (string-date)
+(defun cfw:navi-goto-date-command ()
"Move the cursor to the specified date."
- (interactive "sInput Date (YYYY/MM/DD): ")
- (cfw:navi-goto-date (cfw:parsetime string-date)))
+ (interactive)
+ (cfw:navi-goto-date (call-interactively cfw:read-date-command)))
(defun cfw:navi-goto-today-command ()
"Move the cursor to today."
@@ -2288,7 +2312,7 @@ With prefix arg NO-RESIZE, don't fit calendar to window size."
(defun cfw:navi-next-day-command (&optional num)
"Move the cursor forward NUM days. If NUM is nil, 1 is used.
Moves backward if NUM is negative."
- (interactive)
+ (interactive "p")
(when (cfw:cp-get-component)
(unless num (setq num 1))
(let* ((cursor-date (cfw:cp-get-selected-date (cfw:cp-get-component)))
@@ -2298,7 +2322,7 @@ Moves backward if NUM is negative."
(defun cfw:navi-previous-day-command (&optional num)
"Move the cursor back NUM days. If NUM is nil, 1 is used.
Moves forward if NUM is negative."
- (interactive)
+ (interactive "p")
(cfw:navi-next-day-command (- (or num 1))))
(defun cfw:navi-goto-first-date-command ()
@@ -2318,19 +2342,19 @@ Moves forward if NUM is negative."
(defun cfw:navi-next-week-command (&optional num)
"Move the cursor forward NUM weeks. If NUM is nil, 1 is used.
Moves backward if NUM is negative."
- (interactive)
+ (interactive "p")
(cfw:navi-next-day-command (* cfw:week-days (or num 1))))
(defun cfw:navi-previous-week-command (&optional num)
"Move the cursor back NUM weeks. If NUM is nil, 1 is used.
Moves forward if NUM is negative."
- (interactive)
+ (interactive "p")
(cfw:navi-next-day-command (* (- cfw:week-days) (or num 1))))
(defun cfw:navi-next-month-command (&optional num)
"Move the cursor forward NUM months. If NUM is nil, 1 is used.
Movement is backward if NUM is negative."
- (interactive)
+ (interactive "p")
(when (cfw:cp-get-component)
(unless num (setq num 1))
(let* ((cursor-date (cfw:cp-get-selected-date (cfw:cp-get-component)))
@@ -2347,7 +2371,7 @@ Movement is backward if NUM is negative."
(defun cfw:navi-previous-month-command (&optional num)
"Move the cursor back NUM months. If NUM is nil, 1 is used.
Movement is forward if NUM is negative."
- (interactive)
+ (interactive "p")
(cfw:navi-next-month-command (- (or num 1))))
;;; Detail popup
@@ -2466,14 +2490,14 @@ DATE is a date to show. MODEL is model object."
(when next-win (select-window next-win))))
(defun cfw:details-navi-next-command (&optional num)
- (interactive)
+ (interactive "p")
(when cfw:main-buf
(with-current-buffer cfw:main-buf
(cfw:navi-next-day-command num)
(cfw:show-details-command))))
(defun cfw:details-navi-prev-command (&optional num)
- (interactive)
+ (interactive "p")
(when cfw:main-buf
(with-current-buffer cfw:main-buf
(cfw:navi-previous-day-command num)
Something went wrong with that request. Please try again.