Add arch taglines
[bpt/emacs.git] / lisp / calendar / cal-move.el
index c7d1639..045c11b 100644 (file)
@@ -36,6 +36,9 @@
 
 ;;; Code:
 
+(defvar displayed-month)
+(defvar displayed-year)
+
 (require 'calendar)
 
 (defun calendar-goto-today ()
@@ -86,11 +89,12 @@ Movement is forward is ARG is negative."
   (interactive "p")
   (calendar-forward-month (* -12 arg)))
 
-(defun scroll-calendar-left (arg)
+(defun scroll-calendar-left (&optional arg)
   "Scroll the displayed calendar left by ARG months.
 If ARG is negative the calendar is scrolled right.  Maintains the relative
 position of the cursor with respect to the calendar as well as possible."
   (interactive "p")
+  (unless arg (setq arg 1))
   (calendar-cursor-to-nearest-date)
   (let ((old-date (calendar-cursor-to-date))
         (today (calendar-current-date)))
@@ -106,12 +110,12 @@ position of the cursor with respect to the calendar as well as possible."
             (t (list month 1 year)))))))
   (run-hooks 'calendar-move-hook))
 
-(defun scroll-calendar-right (arg)
+(defun scroll-calendar-right (&optional arg)
   "Scroll the displayed calendar window right by ARG months.
 If ARG is negative the calendar is scrolled left.  Maintains the relative
 position of the cursor with respect to the calendar as well as possible."
   (interactive "p")
-  (scroll-calendar-left (- arg)))
+  (scroll-calendar-left (- (or arg 1))))
 
 (defun scroll-calendar-left-three-months (arg)
   "Scroll the displayed calendar window left by 3*ARG months.
@@ -323,6 +327,28 @@ Moves forward if ARG is negative."
   (calendar-cursor-to-visible-date date)
   (run-hooks 'calendar-move-hook))
 
+(defun calendar-goto-day-of-year (year day &optional noecho)
+  "Move cursor to YEAR, DAY number; echo DAY/YEAR unless NOECHO is t.
+Negative DAY counts backward from end of year."
+  (interactive
+   (let* ((year (calendar-read
+                 "Year (>0): "
+                 (lambda (x) (> x 0))
+                 (int-to-string (extract-calendar-year
+                                 (calendar-current-date)))))
+          (last (if (calendar-leap-year-p year) 366 365))
+          (day (calendar-read
+                (format "Day number (+/- 1-%d): " last)
+                '(lambda (x) (and (<= 1 (abs x)) (<= (abs x) last))))))
+     (list year day)))
+  (calendar-goto-date
+   (calendar-gregorian-from-absolute
+    (if (< 0 day)
+        (+ -1 day (calendar-absolute-from-gregorian (list 1 1 year)))
+      (+ 1 day (calendar-absolute-from-gregorian (list 12 31 year))))))
+  (or noecho (calendar-print-day-of-year)))
+
 (provide 'cal-move)
 
+;;; arch-tag: d0883c46-7e16-4914-8ff8-8f67e699b781
 ;;; cal-move.el ends here