emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104133: Add diary comments feature.


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104133: Add diary comments feature.
Date: Thu, 05 May 2011 21:28:53 -0700
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104133
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Thu 2011-05-05 21:28:53 -0700
message:
  Add diary comments feature.
  
  * lisp/calendar/diary-lib.el (diary-comment-start, diary-comment-end):
  New options.
  (diary-add-to-list): Strip comments from the displayed string.
  (diary-mode): Set comment-start and comment-end.
  
  * doc/emacs/cal-xtra.texi (Fancy Diary Display): Mention diary comments.
  
  * etc/NEWS: Mention this.
modified:
  doc/emacs/ChangeLog
  doc/emacs/cal-xtra.texi
  etc/NEWS
  lisp/ChangeLog
  lisp/calendar/diary-lib.el
=== modified file 'doc/emacs/ChangeLog'
--- a/doc/emacs/ChangeLog       2011-05-02 02:06:53 +0000
+++ b/doc/emacs/ChangeLog       2011-05-06 04:28:53 +0000
@@ -1,3 +1,7 @@
+2011-05-06  Glenn Morris  <address@hidden>
+
+       * cal-xtra.texi (Fancy Diary Display): Mention diary comments.
+
 2011-05-02  Lars Magne Ingebrigtsen  <address@hidden>
 
        * misc.texi (Emacs Server): Document `server-eval-at'.

=== modified file 'doc/emacs/cal-xtra.texi'
--- a/doc/emacs/cal-xtra.texi   2011-01-26 08:36:39 +0000
+++ b/doc/emacs/cal-xtra.texi   2011-05-06 04:28:53 +0000
@@ -616,6 +616,20 @@
 of the hook list, in case earlier members of the list change the order
 of the diary entries, or add items.
 
address@hidden diary-comment-start
+  You can write @samp{comments} in diary entries, by setting the
+variables @code{diary-comment-start} and @code{diary-comment-end} to
+strings that delimit comments.  The fancy display does not print
+comments.  You might want to put meta-data for the use of other packages
+(e.g. the appointment package,
address@hidden
address@hidden,,,emacs, the Emacs Manual})
address@hidden iftex
address@hidden
address@hidden)
address@hidden ifnottex
+inside comments.
+
 @vindex diary-include-string
   Your main diary file can include other files.  This permits a group of
 people to share a diary file for events that apply to all of them.

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2011-05-03 03:34:26 +0000
+++ b/etc/NEWS  2011-05-06 04:28:53 +0000
@@ -447,6 +447,10 @@
 
 ** Calendar, Diary, and Appt
 
++++
+*** Diary entries can contain non-printing `comments'.
+See the variable `diary-comment-start'.
+
 *** New function `diary-hebrew-birthday'.
 
 ---

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-05-06 04:07:47 +0000
+++ b/lisp/ChangeLog    2011-05-06 04:28:53 +0000
@@ -1,5 +1,10 @@
 2011-05-06  Glenn Morris  <address@hidden>
 
+       * calendar/diary-lib.el (diary-comment-start, diary-comment-end):
+       New options.
+       (diary-add-to-list): Strip comments from the displayed string.
+       (diary-mode): Set comment-start and comment-end.
+
        * vc/diff-mode.el (smerge-refine-subst): Declare.
        (diff-refine-hunk): Don't require smerge-mode when compiling.
 

=== modified file 'lisp/calendar/diary-lib.el'
--- a/lisp/calendar/diary-lib.el        2011-05-04 02:06:28 +0000
+++ b/lisp/calendar/diary-lib.el        2011-05-06 04:28:53 +0000
@@ -142,6 +142,25 @@
   :type 'string
   :group 'diary)
 
+(defcustom diary-comment-start nil
+  "String marking the start of a comment in the diary, or nil.
+Nil means there are no comments.  The diary does not display
+parts of entries that are inside comments.  You can use comments
+for whatever you like, e.g. for meta-data that packages such as
+`appt.el' can use.
+See also `diary-comment-end'."
+  :version "24.1"
+  :type '(choice (const :tag "No comment" nil) string)
+  :group 'diary)
+
+(defcustom diary-comment-end ""
+  "String marking the end of a comment in the diary.
+The empty string means comments finish at the end of a line.
+See also `diary-comment-start'."
+  :version "24.1"
+  :type 'string
+  :group 'diary)
+
 (defcustom diary-hook nil
   "List of functions called after the display of the diary.
 Used for example by the appointment package - see `appt-activate'."
@@ -610,10 +629,15 @@
 
 The entry is added to the list as (DATE STRING SPECIFIER LOCATOR
 GLOBCOLOR), where LOCATOR has the form (MARKER FILENAME LITERAL),
-FILENAME being the file containing the diary entry."
+FILENAME being the file containing the diary entry.
+
+Modifies STRING using `diary-modify-entry-list-string-function', if non-nil.
+Also removes the region between `diary-comment-start' and
+`diary-comment-end', if the former is non-nil."
   (when (and date string)
     ;; b-f-n is nil if we are visiting an include file in a temp-buffer.
-    (let ((dfile (or (buffer-file-name) diary-file)))
+    (let ((dfile (or (buffer-file-name) diary-file))
+          cstart)
       (if diary-file-name-prefix
           (let ((prefix (funcall diary-file-name-prefix-function dfile)))
             (or (string-equal prefix "")
@@ -621,6 +645,16 @@
       (and diary-modify-entry-list-string-function
            (setq string (funcall diary-modify-entry-list-string-function
                                  string)))
+      (when (and diary-comment-start
+                 (string-match (setq cstart (regexp-quote diary-comment-start))
+                               string))
+        ;; Preserve the value with the comments.
+        (or literal (setq literal string))
+        (setq string (replace-regexp-in-string
+                      (format "%s.*%s" cstart
+                              (if (zerop (length diary-comment-end)) "$"
+                                (regexp-quote diary-comment-end)))
+                      "" string)))
       (setq diary-entries-list
             (append diary-entries-list
                     (list (list date string specifier
@@ -2353,6 +2387,8 @@
   "Major mode for editing the diary file."
   (set (make-local-variable 'font-lock-defaults)
        '(diary-font-lock-keywords t))
+  (set (make-local-variable 'comment-start) diary-comment-start)
+  (set (make-local-variable 'comment-end) diary-comment-end)
   (add-to-invisibility-spec '(diary . nil))
   (add-hook 'after-save-hook 'diary-redraw-calendar nil t)
   ;; In case the file was modified externally, refresh the calendar


reply via email to

[Prev in Thread] Current Thread [Next in Thread]