Update maintainer email address.
[bpt/emacs.git] / lisp / calendar / cal-move.el
index f0dca00..3091822 100644 (file)
@@ -1,8 +1,9 @@
 ;;; cal-move.el --- calendar functions for movement in the calendar
 
-;; Copyright (C) 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2005  Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
+;; Maintainer: Glenn Morris <rgm@gnu.org>
 ;; Keywords: calendar
 ;; Human-Keywords: calendar
 
@@ -20,8 +21,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -36,6 +37,9 @@
 
 ;;; Code:
 
+(defvar displayed-month)
+(defvar displayed-year)
+
 (require 'calendar)
 
 (defun calendar-goto-today ()
@@ -266,7 +270,8 @@ Moves forward if ARG is negative."
       (if (and (= arg 1)
                (calendar-date-is-visible-p jan-first))
           (calendar-cursor-to-visible-date jan-first)
-        (calendar-other-month 1 (- year (1- arg))))))
+        (calendar-other-month 1 (- year (1- arg)))
+        (calendar-cursor-to-visible-date (list 1 1 displayed-year)))))
   (run-hooks 'calendar-move-hook))
 
 (defun calendar-end-of-year (arg)
@@ -284,7 +289,7 @@ Moves forward if ARG is negative."
       (if (and (= arg 1)
                (calendar-date-is-visible-p dec-31))
           (calendar-cursor-to-visible-date dec-31)
-        (calendar-other-month 12 (- year (1- arg)))
+        (calendar-other-month 12 (+ year (1- arg)))
         (calendar-cursor-to-visible-date (list 12 31 displayed-year)))))
   (run-hooks 'calendar-move-hook))
 
@@ -324,6 +329,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