From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: function to wrap a string for calendar-modify-diary-entry-string Date: Thu, 05 Oct 2006 09:55:14 -0600 Organization: IHS Message-ID: References: <452502D0.8080000@speakeasy.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1160065866 16453 80.91.229.2 (5 Oct 2006 16:31:06 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 5 Oct 2006 16:31:06 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 05 18:31:05 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GVVtX-0002ak-E7 for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Oct 2006 18:16:24 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GVVtW-0006ra-Tg for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Oct 2006 12:16:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GVVtF-0006nY-KE for help-gnu-emacs@gnu.org; Thu, 05 Oct 2006 12:16:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GVVtB-0006hw-EZ for help-gnu-emacs@gnu.org; Thu, 05 Oct 2006 12:16:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GVVtB-0006hZ-5v for help-gnu-emacs@gnu.org; Thu, 05 Oct 2006 12:16:01 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GVVzr-0003BR-8Z for help-gnu-emacs@gnu.org; Thu, 05 Oct 2006 12:22:55 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1GVVcN-0005oM-5H for help-gnu-emacs@gnu.org; Thu, 05 Oct 2006 17:58:39 +0200 Original-Received: from 207.167.42.206 ([207.167.42.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 05 Oct 2006 17:58:39 +0200 Original-Received: from ihs_4664 by 207.167.42.206 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 05 Oct 2006 17:58:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 57 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.206 User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) In-Reply-To: <452502D0.8080000@speakeasy.net> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:37824 Archived-At: 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