Skip to content

Commit

Permalink
add functions for previous item navigation command #104
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwanami committed Jul 14, 2017
1 parent bcfc0c5 commit 3415d86
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion calfw.el
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,10 @@ calendar view."
("t" . cfw:navi-goto-today-command)
("." . cfw:navi-goto-today-command)

("TAB" . cfw:navi-next-item-command)
("TAB" . cfw:navi-next-item-command)
("C-i" . cfw:navi-next-item-command)
("<backtab>" . cfw:navi-prev-item-command)
("S-TAB" . cfw:navi-prev-item-command)

("r" . cfw:refresh-calendar-buffer)
("SPC" . cfw:show-details-command)
Expand Down Expand Up @@ -2484,6 +2487,17 @@ calendar view."
(if next (goto-char next)
(cfw:navi-goto-date date))))))

(defun cfw:navi-prev-item-command ()
"Move the cursor to the previous item."
(interactive)
(let ((cp (cfw:cp-get-component))
(date (cfw:cursor-to-date))
(count (or (get-text-property (point) 'cfw:row-count) -1)))
(when (and cp date)
(let ((next (cfw:find-item (cfw:component-dest cp) date (1- count))))
(if next (goto-char next)
(cfw:navi-goto-date date))))))

(defun cfw:navi-on-click ()
"click"
(interactive)
Expand Down Expand Up @@ -2688,6 +2702,9 @@ DATE is a date to show. MODEL is model object."
("b" . cfw:details-navi-prev-command)
("<left>" . cfw:details-navi-prev-command)
("TAB" . cfw:details-navi-next-item-command)
("C-i" . cfw:details-navi-next-item-command)
("<backtab>" . cfw:details-navi-prev-item-command)
("S-TAB" . cfw:details-navi-prev-item-command)
))
"Default key map for the details buffer.")

Expand Down Expand Up @@ -2737,6 +2754,12 @@ DATE is a date to show. MODEL is model object."
(next (cfw:details-find-item (1+ count))))
(goto-char (or next (point-min)))))

(defun cfw:details-navi-prev-item-command ()
(interactive)
(let* ((count (or (get-text-property (point) 'cfw:row-count) -1))
(next (cfw:details-find-item (1- count))))
(goto-char (or next (point-min)))))

(defun cfw:details-find-item (row-count)
"[internal] Find the schedule item which has the text
properties as `cfw:row-count' = ROW-COUNT. If no item is found,
Expand Down

0 comments on commit 3415d86

Please sign in to comment.