diff options
author | Glenn Morris <rgm@gnu.org> | 2008-03-07 05:18:39 +0000 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2008-03-07 05:18:39 +0000 |
commit | e85393d4fff7497fbe79ce6fb7ede8bcf9daaaa5 (patch) | |
tree | cb7b4112ecd934ad4aef4f8b74b7fd1c6bc3eff7 /lisp/calendar/solar.el | |
parent | ec1ee609ae6e8668b3e242ed646d6016368eac4d (diff) | |
download | emacs-e85393d4fff7497fbe79ce6fb7ede8bcf9daaaa5.tar.gz |
Remove leading `*' from defcustom doc-strings.
(calendar-time-display-form, calendar-latitude)
(calendar-longitude, solar-equinoxes-solstices): Remove autoload cookies.
(calendar-latitude, calendar-longitude): Move functions after
variables.
(diary-sabbath-candles-minutes): Move to start.
(solar-setup): Use or rather than if.
(solar-sin-degrees, solar-cosine-degrees, solar-tangent-degrees):
Remove condition-case.
(solar-atn2): Use zerop.
(solar-equinoxes-solstices): Doc fix.
Diffstat (limited to 'lisp/calendar/solar.el')
-rw-r--r-- | lisp/calendar/solar.el | 117 |
1 files changed, 56 insertions, 61 deletions
diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el index a08aa8e64ec..31d331163e6 100644 --- a/lisp/calendar/solar.el +++ b/lisp/calendar/solar.el @@ -61,16 +61,16 @@ (if (fboundp 'atan) (require 'lisp-float-type) - (error "Solar/lunar calculations impossible since floating point is unavailable")) + (error "Solar calculations impossible since floating point is unavailable")) (require 'cal-dst) (require 'cal-julian) -;;;###autoload + (defcustom calendar-time-display-form '(12-hours ":" minutes am-pm (if time-zone " (") time-zone (if time-zone ")")) - "*The pseudo-pattern that governs the way a time of day is formatted. + "The pseudo-pattern that governs the way a time of day is formatted. A pseudo-pattern is a list of expressions that can involve the keywords `12-hours', `24-hours', and `minutes', all numbers in string form, @@ -85,9 +85,8 @@ would give military-style times like `21:07 (UTC)'." :type 'sexp :group 'calendar) -;;;###autoload (defcustom calendar-latitude nil - "*Latitude of `calendar-location-name' in degrees. + "Latitude of `calendar-location-name' in degrees. The value can be either a decimal fraction (one place of accuracy is sufficient), + north, - south, such as 40.7 for New York City, or the value @@ -105,9 +104,8 @@ This variable should be set in `site-start'.el." (const south)))) :group 'calendar) -;;;###autoload (defcustom calendar-longitude nil - "*Longitude of `calendar-location-name' in degrees. + "Longitude of `calendar-location-name' in degrees. The value can be either a decimal fraction (one place of accuracy is sufficient), + east, - west, such as -73.9 for New York City, or the value @@ -125,27 +123,6 @@ This variable should be set in `site-start'.el." (const west)))) :group 'calendar) -(defsubst calendar-latitude () - "Convert calendar-latitude to a signed decimal fraction, if needed." - (if (numberp calendar-latitude) - calendar-latitude - (let ((lat (+ (aref calendar-latitude 0) - (/ (aref calendar-latitude 1) 60.0)))) - (if (equal (aref calendar-latitude 2) 'north) - lat - (- lat))))) - -(defsubst calendar-longitude () - "Convert calendar-longitude to a signed decimal fraction, if needed." - (if (numberp calendar-longitude) - calendar-longitude - (let ((long (+ (aref calendar-longitude 0) - (/ (aref calendar-longitude 1) 60.0)))) - (if (equal (aref calendar-longitude 2) 'east) - long - (- long))))) - -;;;###autoload (defcustom calendar-location-name '(let ((float-output-format "%.1f")) (format "%s%s, %s%s" @@ -163,7 +140,7 @@ This variable should be set in `site-start'.el." (if (numberp calendar-longitude) (if (> calendar-longitude 0) "E" "W") (if (equal (aref calendar-longitude 2) 'east) "E" "W")))) - "*Expression evaluating to name of `calendar-longitude', `calendar-latitude'. + "Expression evaluating to name of `calendar-longitude', `calendar-latitude'. For example, \"New York City\". Default value is just the latitude, longitude pair. @@ -172,7 +149,7 @@ This variable should be set in `site-start'.el." :group 'calendar) (defcustom solar-error 0.5 -"*Tolerance (in minutes) for sunrise/sunset calculations. +"Tolerance (in minutes) for sunrise/sunset calculations. A larger value makes the calculations for sunrise/sunset faster, but less accurate. The default is half a minute (30 seconds), so that sunrise/sunset @@ -186,6 +163,16 @@ delta. At present, delta = 0.01 degrees, so the value of the variable :type 'number :group 'calendar) +(defcustom diary-sabbath-candles-minutes 18 + "Number of minutes before sunset for sabbath candle lighting." + :group 'diary + :type 'integer + :version "21.1") + + +;;; End of user options. + + (defvar solar-n-hemi-seasons '("Vernal Equinox" "Summer Solstice" "Autumnal Equinox" "Winter Solstice") "List of season changes for the northern hemisphere.") @@ -202,21 +189,43 @@ delta. At present, delta = 0.01 degrees, so the value of the variable "Non-nil if northern spring or summer and nil otherwise. Needed for polar areas, in order to know whether the day lasts 0 or 24 hours.") + +(defsubst calendar-latitude () + "Convert calendar-latitude to a signed decimal fraction, if needed." + (if (numberp calendar-latitude) + calendar-latitude + (let ((lat (+ (aref calendar-latitude 0) + (/ (aref calendar-latitude 1) 60.0)))) + (if (equal (aref calendar-latitude 2) 'north) + lat + (- lat))))) + +(defsubst calendar-longitude () + "Convert calendar-longitude to a signed decimal fraction, if needed." + (if (numberp calendar-longitude) + calendar-longitude + (let ((long (+ (aref calendar-longitude 0) + (/ (aref calendar-longitude 1) 60.0)))) + (if (equal (aref calendar-longitude 2) 'east) + long + (- long))))) + (defun solar-setup () "Prompt user for latitude, longitude, and time zone." (beep) - (if (not calendar-longitude) + (or calendar-longitude (setq calendar-longitude (solar-get-number "Enter longitude (decimal fraction; + east, - west): "))) - (if (not calendar-latitude) + (or calendar-latitude (setq calendar-latitude (solar-get-number "Enter latitude (decimal fraction; + north, - south): "))) - (if (not calendar-time-zone) + (or calendar-time-zone (setq calendar-time-zone (solar-get-number - "Enter difference from Coordinated Universal Time (in minutes): ")))) + "Enter difference from Coordinated Universal Time (in \ +minutes): ")))) (defun solar-get-number (prompt) "Return a number from the minibuffer, prompting with PROMPT. @@ -225,20 +234,14 @@ Returns nil if nothing was entered." (if (not (string-equal x "")) (string-to-number x)))) -;; The condition-case stuff is needed to catch bogus arithmetic -;; exceptions that occur on some machines (like Sparcs) (defun solar-sin-degrees (x) - (condition-case nil - (sin (degrees-to-radians (mod x 360.0))) - (solar-sin-degrees x))) + (sin (degrees-to-radians (mod x 360.0)))) + (defun solar-cosine-degrees (x) - (condition-case nil - (cos (degrees-to-radians (mod x 360.0))) - (solar-cosine-degrees x))) + (cos (degrees-to-radians (mod x 360.0)))) + (defun solar-tangent-degrees (x) - (condition-case nil - (tan (degrees-to-radians (mod x 360.0))) - (solar-tangent-degrees x))) + (tan (degrees-to-radians (mod x 360.0)))) (defun solar-xy-to-quadrant (x y) "Determines the quadrant of the point X, Y." @@ -260,20 +263,19 @@ Returns nil if nothing was entered." (defun solar-atn2 (x y) "Arctan of point X, Y." - (if (= x 0) + (if (zerop x) (if (> y 0) 90 270) (solar-arctan (/ y x) (solar-xy-to-quadrant x y)))) (defun solar-arccos (x) - "Arcos of X." - (let ((y (sqrt (- 1 (* x x))))) - (solar-atn2 x y))) + "Arcos of X." + (let ((y (sqrt (- 1 (* x x))))) + (solar-atn2 x y))) (defun solar-arcsin (y) - "Arcsin of Y." - (let ((x (sqrt (- 1 (* y y))))) - (solar-atn2 x y) - )) + "Arcsin of Y." + (let ((x (sqrt (- 1 (* y y))))) + (solar-atn2 x y))) (defsubst solar-degrees-to-hours (degrees) "Convert DEGREES to hours." @@ -914,12 +916,6 @@ Accurate to a few seconds." (solar-setup)) (solar-sunrise-sunset-string date)) -(defcustom diary-sabbath-candles-minutes 18 - "*Number of minutes before sunset for sabbath candle lighting." - :group 'diary - :type 'integer - :version "21.1") - (defun diary-sabbath-candles (&optional mark) "Local time of candle lighting diary entry--applies if date is a Friday. No diary entry if there is no sunset on that date. @@ -1044,9 +1040,8 @@ solstice. These formulas are only to be used between 1000 BC and 3000 AD." (* -0.00823 z z z) (* 0.00032 z z z z))))))) -;;;###autoload (defun solar-equinoxes-solstices () - "*local* date and time of equinoxes and solstices, if visible in the calendar window. + "Local date and time of equinoxes and solstices, if visible in the calendar. Requires floating point." (let ((m displayed-month) (y displayed-year)) |