Subject: bug#2532: NS: ns-expand-space / slider in Preferences dialog not functional

From: David Reitter <[email-masked]>
Date: Wed, 4 Mar 2009 22:39:15 -0500

On 4 Mar 2009, at 16:35, Adrian Robert wrote:

>> Setting `ns-expand-space' doesn't work, and neither does changing its
>> value via the slider the the preferences panel.
>>
>> Also, the doc string of the above variable says that one shouldn't  
>> set
>> it directly - if so, how is one supposed to (programmatically) set  
>> this?
>> Studying the source code (nsterm.m:setValuesFromPanel), it seems to  
>> me
>> that setting the value should work just fine (I even tried calling  
>> ns-
>> save-preferences).
>
> Emacs must be restarted, unfortunately.  It mentions this in the  
> manual.  The variable doc string should be updated.
>

The UI does not reflect that.  Users need some indication that they  
need to restart Emacs for this to work.

The `ns-set-resource' Elisp interface is better than none on the Elisp  
side, but what happened to Emacs customization variables?

As said before on this list, introducing another way (beyond .emacs  
and customization/custom-file) creates a new failure point for  
people's configurations.  This is bad in two respects: they won't be  
able to reset Emacs to a vanilla state, or troubleshoot a faulty  
configuration.  And, second, it is going to be harder on us to  
troubleshoot people's problems.  Right now, with GNU Emacs 22, we have  
~/.emacs and ~/.emacs.d (IIRC), and maybe a few site-lisp files.  I  
speak from experience - in Aquamacs, youthful optimism led me to add  
eight further locations for a version of .emacs called Preferences.el  
- two would have done the job to satisfy my goal of Mac  
compatibility.  In addition to that, we split custom-file from .emacs  
(a good choice, per se).  All of these things make it harder to  
support users.  "emacs -q" is helpful, but at the end of the day,  
people want to run "emacs".  Especially seasoned users will complain  
that they have to find and delete ~/Library/Preferences/ 
org.gnu.emacs.plist.

In anticipation of one pro-resource argument: X Resources are much  
more limited than the NS parameters system.  Why recreate it on NS?

What follows is an excerpt from ns-win.el that shows how many of these  
"NS resources" are set.

   (ns-set-resource nil "AlternateModifier" (symbol-name ns-alternate- 
modifier))
   (ns-set-resource nil "CommandModifier" (symbol-name ns-command- 
modifier))
   (ns-set-resource nil "ControlModifier" (symbol-name ns-control- 
modifier))
   (ns-set-resource nil "FunctionModifier" (symbol-name ns-function- 
modifier))
   (ns-set-resource nil "ExpandSpace"
                    (if ns-expand-space
                        (number-to-string ns-expand-space)
                      "NO"))
   (ns-set-resource nil "GSFontAntiAlias" (if ns-antialias-text "YES"  
"NO"))
   (ns-set-resource nil "UseQuickdrawSmoothing"
		   (if ns-use-qd-smoothing "YES" "NO"))
   (ns-set-resource nil "UseSystemHighlightColor"
		   (if ns-use-system-highlight-color "YES" "NO"))
   (ns-set-resource nil "ConfirmQuit"
		   (if ns-confirm-quit "YES" "NO"))
   ;; Default frame parameters
   (let ((p (frame-parameters))
	v)
     (if (setq v (assq 'font p))
	(ns-set-resource nil "Font" (ns-font-name (cdr v))))
     (if (setq v (assq 'fontsize p))

...

  (let ((fl (face-list)))
     (while (consp fl)
       (or (eq 'default (car fl))
           ;; dont save Default* since it causes all created faces to
           ;; inherit its values.  The properties of the default face
           ;; have already been saved from the frame-parameters anyway.
           (let* ((name (symbol-name (car fl)))
                  (font (face-font (car fl)))
                  ;; (fontsize (face-fontsize (car fl)))
                  (foreground (face-foreground (car fl)))
                  (background (face-background (car fl)))
                  (underline (face-underline-p (car fl)))
                  (italic (face-italic-p (car fl)))
                  (bold (face-bold-p (car fl)))
                  (stipple (face-stipple (car fl))))
             ;; (ns-set-resource nil (concat name ".attributeFont")
             ;;                  (if font font nil))
             ;; (ns-set-resource nil (concat name ".attributeFontSize")
             ;;                  (if fontsize (number-to-string  
fontsize) nil))
             (ns-set-resource nil (concat name ".attributeForeground")
                              (if foreground foreground nil))
             (ns-set-resource nil (concat name ".attributeBackground")
                              (if background background nil))
             (ns-set-resource nil (concat name ".attributeUnderline")

...