unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Sendmail/Mac: initialize correctly [patch]
@ 2005-12-26 11:26 David Reitter
  2005-12-26 19:24 ` Luc Teirlinck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Reitter @ 2005-12-26 11:26 UTC (permalink / raw)


The current implementation of the defcustom `send-mail-function'  
doesn't initialize the value correctly because it looks at `window- 
system', which has a different value at compile time, and the initial  
value of the defcustoms is stored at that point (ldefs, I think)  
because it's an autoload.

The below patch fixes that; I'm not aware of a more elegant solution  
(I asked in an earlier thread on Nov 24).

-- D




Index: lisp/mail/sendmail.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/mail/sendmail.el,v
retrieving revision 1.299
diff -c -r1.299 sendmail.el
*** lisp/mail/sendmail.el	9 Dec 2005 16:44:16 -0000	1.299
--- lisp/mail/sendmail.el	20 Dec 2005 12:39:35 -0000
***************
*** 126,134 ****
   ;; Useful to set in site-init.el
   ;;;###autoload
   (defcustom send-mail-function
!   (if (and window-system (memq system-type '(darwin windows-nt)))
!       'mailclient-send-it
!     'sendmail-send-it)
     "Function to call to send the current buffer as mail.
   The headers should be delimited by a line which is
   not a valid RFC822 header or continuation line,
--- 126,146 ----
   ;; Useful to set in site-init.el
   ;;;###autoload
   (defcustom send-mail-function
!   (progn ;; init value will be included in autoloads
!     (defun send-mail-function-default ()
!       "Initial value for `send-mail-function'"
!       (if (and window-system
! 	       (memq system-type '(darwin windows-nt)))
! 	  'mailclient-send-it
! 	'sendmail-send-it))
!     (add-hook 'before-init-hook	
! 	      ;; evaluate at runtime when window-system is known
! 	      (lambda ()
! 		"Initialize `send-mail-function'"
! 		(set-default 'send-mail-function
! 			     (send-mail-function-default))))
!     ;; initialize defcustom to the current default
!     (send-mail-function-default))
     "Function to call to send the current buffer as mail.
   The headers should be delimited by a line which is
   not a valid RFC822 header or continuation line,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sendmail/Mac: initialize correctly [patch]
  2005-12-26 11:26 Sendmail/Mac: initialize correctly [patch] David Reitter
@ 2005-12-26 19:24 ` Luc Teirlinck
  2005-12-26 19:34 ` Luc Teirlinck
  2005-12-27  0:00 ` Luc Teirlinck
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Teirlinck @ 2005-12-26 19:24 UTC (permalink / raw)
  Cc: emacs-devel

David Reitter wrote:

   The below patch fixes that; I'm not aware of a more elegant solution  
   (I asked in an earlier thread on Nov 24).

Was using custom-reevaluate-setting discussed in that thread?  Does
it work in your situation?  I believe it should work, because the
defcustom has no :set function.  I do not immediately know what we
will have to do in similar situations when there is a :set function,
short of pre-loading the file, which might not be desirable.

:custom-initialize-reset was supposed to take care of problems with
autoloaded defcustoms, but apparently, it does not.

Concretely:

===File ~/startup-diff======================================
*** startup.el	12 Dec 2005 20:44:32 -0600	1.391
--- startup.el	26 Dec 2005 12:19:17 -0600	
***************
*** 776,781 ****
--- 776,782 ----
    (custom-reevaluate-setting 'mouse-wheel-down-event)
    (custom-reevaluate-setting 'mouse-wheel-up-event)
    (custom-reevaluate-setting 'file-name-shadow-mode)
+   (custom-reevaluate-setting 'send-mail-function)
  
    ;; Register default TTY colors for the case the terminal hasn't a
    ;; terminal init file.
============================================================

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sendmail/Mac: initialize correctly [patch]
  2005-12-26 11:26 Sendmail/Mac: initialize correctly [patch] David Reitter
  2005-12-26 19:24 ` Luc Teirlinck
@ 2005-12-26 19:34 ` Luc Teirlinck
  2005-12-27  0:00 ` Luc Teirlinck
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Teirlinck @ 2005-12-26 19:34 UTC (permalink / raw)
  Cc: emacs-devel

Sorry, I responded too quickly again.  I should have reread the prior
thread.  Second time I fell into the same trap.
`custom-reevaluate-setting' will not work, for reasons given in the
earlier thread.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sendmail/Mac: initialize correctly [patch]
  2005-12-26 11:26 Sendmail/Mac: initialize correctly [patch] David Reitter
  2005-12-26 19:24 ` Luc Teirlinck
  2005-12-26 19:34 ` Luc Teirlinck
@ 2005-12-27  0:00 ` Luc Teirlinck
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Teirlinck @ 2005-12-27  0:00 UTC (permalink / raw)
  Cc: emacs-devel

I believe that the alternative solution given by the two patches below
should work.  It autoloads the standard-value property, which then
becomes available for `custom-reevaluate-setting'.

It has the advantage of not making the standard-value expression,
which is user visible through "Show initial Lisp expression", more
complex.  It has the disadvantage of duplicating this expression in the
source code, but the two occurrences are close together in the same
file, so it would be easy to update both at once should it be changed.
It would probably be possible to write a macro that writes the two
autoloads at once, so that there would be only one expression to
update.  However, if send-mail-function is the only instance, that is
probably not worth the trouble.

Of course, if you try out the patch, you have to make sure to update
your loaddefs properly.

Note that tex-dvi-view-command solves the same problem by allowing
the value to be any Lisp expression.  Then it evaluates that
expression at run time.  But that seems to make things more complex
for the user in the Custom buffer.

Here are the patches:

===File ~/sendmail-diff=====================================
*** sendmail.el	09 Dec 2005 17:35:30 -0600	1.299
--- sendmail.el	26 Dec 2005 17:08:01 -0600	
***************
*** 123,128 ****
--- 123,137 ----
    :type 'regexp
    :group 'sendmail)
  
+ ;; Prevent problems with `window-system' not having the correct value
+ ;; when loaddefs.el is loaded. `custom-reevaluate-setting' needs the
+ ;; standard value.
+ ;;;###autoload
+ (put 'send-mail-function 'standard-value
+      '((if (and window-system (memq system-type '(darwin windows-nt)))
+ 	   'mailclient-send-it
+ 	 'sendmail-send-it)))
+ 
  ;; Useful to set in site-init.el
  ;;;###autoload
  (defcustom send-mail-function
============================================================

===File ~/startup-diff======================================
*** startup.el	12 Dec 2005 20:44:32 -0600	1.391
--- startup.el	26 Dec 2005 17:13:52 -0600	
***************
*** 776,781 ****
--- 776,782 ----
    (custom-reevaluate-setting 'mouse-wheel-down-event)
    (custom-reevaluate-setting 'mouse-wheel-up-event)
    (custom-reevaluate-setting 'file-name-shadow-mode)
+   (custom-reevaluate-setting 'send-mail-function)
  
    ;; Register default TTY colors for the case the terminal hasn't a
    ;; terminal init file.
============================================================

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-12-27  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-26 11:26 Sendmail/Mac: initialize correctly [patch] David Reitter
2005-12-26 19:24 ` Luc Teirlinck
2005-12-26 19:34 ` Luc Teirlinck
2005-12-27  0:00 ` Luc Teirlinck

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).