* function to wrap a string for calendar-modify-diary-entry-string
@ 2006-10-05 13:04 ken
2006-10-05 15:55 ` Kevin Rodgers
0 siblings, 1 reply; 3+ messages in thread
From: ken @ 2006-10-05 13:04 UTC (permalink / raw)
I found
(defvar diary-modify-entry-list-string-function nil
"Function applied to entry string before putting it into the entries list.
Can be used by programs integrating a diary list into other buffers (e.g.
org.el and planner.el) to modify the string or add properties to it.
The function takes a string argument and must return a string.")
So created this ~/emacs.d/calendar-display-alter.el:
(defun calendar-modify-diary-entry-string (instring outstring)
"Function to wrap ``\t* '' and ``. \n'' around a diary entry."
(defvar outstring (concat "\t* " instring ". \n"))
)
Then put this in my ~/.emacs and eval'd it:
(defvar diary-modify-entry-list-string-function calendar-display-alter.el)
Ran M-x diary, but no difference in the output.
Frankly, I was doubtful it would work because there's nothing telling
anything that the variable "outstring" is what should be output. What
would accomplish that. (Also, of course, if there's anything else goofy
about the function above, please let me know.)
Thanks.
--
In a time of universal deceit, telling the truth becomes an act of
rebellion.
--George Orwell
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: function to wrap a string for calendar-modify-diary-entry-string
2006-10-05 13:04 function to wrap a string for calendar-modify-diary-entry-string ken
@ 2006-10-05 15:55 ` Kevin Rodgers
2006-10-05 19:56 ` ken
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2006-10-05 15:55 UTC (permalink / raw)
ken wrote:
> I found
>
> (defvar diary-modify-entry-list-string-function nil
> "Function applied to entry string before putting it into the entries list.
> Can be used by programs integrating a diary list into other buffers (e.g.
> org.el and planner.el) to modify the string or add properties to it.
> The function takes a string argument and must return a string.")
>
> So created this ~/emacs.d/calendar-display-alter.el:
>
> (defun calendar-modify-diary-entry-string (instring outstring)
> "Function to wrap ``\t* '' and ``. \n'' around a diary entry."
> (defvar outstring (concat "\t* " instring ". \n"))
> )
>
> Then put this in my ~/.emacs and eval'd it:
>
> (defvar diary-modify-entry-list-string-function calendar-display-alter.el)
>
> Ran M-x diary, but no difference in the output.
>
> Frankly, I was doubtful it would work because there's nothing telling
> anything that the variable "outstring" is what should be output. What
> would accomplish that. (Also, of course, if there's anything else goofy
> about the function above, please let me know.)
Quite a bit :-)
First, your function must take only 1 string argument, but it takes 2.
Second, it attempts to return the result via defvar, but (a) defvar
won't even evaluate the INITVALUE form if the SYMBOL is already bound,
which outstring surely is, and (b) defvar returns SYMBOL, not its value.
Third, using defvar to set a variable (in this case
diary-modify-entry-list-string-function) is ineffective if the variable
is already bound, as it may very well be. Fourth, you set it to a
symbol whose name happens to be the file name where the function is
defined -- you need to set it to the function itself, and separately
arrange for the file to be loaded.
So:
;; ~/emacs.d/calendar-display-alter.el:
(defun calendar-modify-diary-entry-string (entry-string)
"Prepend \"TAB *\" and append \". SPC LFD\" to ENTRY-STRING."
(concat "\t* " entry-string ". \n"))
;; ~/.emacs:
(autoload 'calendar-modify-diary-entry-string
"~/emacs.d/calendar-display-alter") ; or just "calendar-display-alter"
; if "~/emacs.d" is in load-path
(setq diary-modify-entry-list-string-function
'calendar-modify-diary-entry-string)
--
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: function to wrap a string for calendar-modify-diary-entry-string
2006-10-05 15:55 ` Kevin Rodgers
@ 2006-10-05 19:56 ` ken
0 siblings, 0 replies; 3+ messages in thread
From: ken @ 2006-10-05 19:56 UTC (permalink / raw)
Kevin Rodgers wrote:
> ken wrote:
>> ....
>
> ;; ~/emacs.d/calendar-display-alter.el:
> (defun calendar-modify-diary-entry-string (entry-string)
> "Prepend \"TAB *\" and append \". SPC LFD\" to ENTRY-STRING."
> (concat "\t* " entry-string ". \n"))
>
> ;; ~/.emacs:
> (autoload 'calendar-modify-diary-entry-string
> "~/emacs.d/calendar-display-alter") ; or just "calendar-display-alter"
> ; if "~/emacs.d" is in load-path
> (setq diary-modify-entry-list-string-function
> 'calendar-modify-diary-entry-string)
>
Thanks much... even for the criticism... wish I understood it. But
that's okay. It's easier to learn from observing the ways that work
than from the ways that don't. And your code works.
Thanks again.
--
In a time of universal deceit, telling the truth becomes an act of
rebellion.
--George Orwell
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-05 19:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-05 13:04 function to wrap a string for calendar-modify-diary-entry-string ken
2006-10-05 15:55 ` Kevin Rodgers
2006-10-05 19:56 ` ken
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).