2

The old, reliable (set-cursor-color "#aa88dd") in my .emacs file fails with Aquamacs, unless it is run after Aquamacs has launched. This type of failure is typical of Emacs doing something secretive during launch, but I can't figure out what. I modified and saved Aquamacs setting for cursor( Cursor face: background:), which works for a session, and saves the setting, but does not initialize correctly for the next session. Even after all that, I've got a bright red cursor.

Working Emacs: GNU Emacs 23.2.1 (i686-apple-darwin, NS apple-appkit-1038.29)

Failing Aquamacs: GNU Emacs 23.3.50.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54)

1) Workarounds and fixes appreciated. At the moment I'm using 23.2.1. I don't feel compelled to upgrade, but sooner or later I'll have to.

2) Searching the interwebs turned up nothing. I suspect the issue is a red herring related to some other issue where Aquamacs can't determine some setting and chooses Red as the cursor color. Is there a trick to get Emacs to print the name of every loaded config file into Messages?

3) Related big picture question: Is there in general a way to force a new version of Emacs to behave like the old version? It would fix my current problem, as well as the upheaval that occasionally happens with new versions.

Below is Aquamacs customizations.el which appears to have correctly saved the cursor background. I did not edit this file. Adding the (cursor...) statement to my .emacs custom-set-variable had no effect.

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(cua-mode nil nil (cua-base))
 '(cua-normal-cursor-color "#aa88dd")
 '(cursor-type (quote box))
 '(ess-S-assign "_")
 '(ido-everywhere t)
 '(ido-show-dot-for-dired t)
 '(line-move-visual nil)
 '(term-bind-key-alist (quote (("C-c C-x b" . switch-to-buffer) ("C-c M-x" . execute-extended-command) ("C-c C-c" . term-interrupt-subjob) ("M-`" . other-frame) ("C-m" . term-send-raw))))
 '(term-unbind-key-list (quote ("C-c"))))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "White" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 210 :width normal :foundry "apple" :family "Inconsolata"))))
 '(cua-normal-cursor-color "#aa88dd")
 '(cursor ((t (:background "#AA88DD" :foreground "black" :box nil)))))
Charles Merriam
  • 19,908
  • 6
  • 73
  • 83
infogizmo
  • 431
  • 4
  • 6
  • Do yourself a favor and shun Aquamacs. It is out-dated and receives little maintenance. Instead, use plain GNU Emacs 24.3 pretest from http://emacsformacosx.com/. –  Feb 19 '13 at 15:16
  • That works. My "working" version **is** emacsformacosx, I think. It has the same icon, same installed path, and the cursor settings work. I installed it a long time ago and didn't keep notes. A more complete answer might be interesting, but I've got work to do. Note for lurkers: emacsformacosx is real Emacs, and it is a normal MacOS application that does not require X-Windows. – infogizmo Feb 19 '13 at 22:32

3 Answers3

2

I'm not fully enamored of Aquamacs, but emacsforosx has the very annoying (to me) attribute that window position is not saved across sessions.... it always opens at the top left corner of my main display, not where I positioned it. And there's no way to fix it.

I don't remember where I found/learned that this is the way to set the cursor color, but see this FAQ:

http://www.emacswiki.org/emacs/AquamacsFAQ#toc16

Open a buffer and set things the way you like them. Then choose

Options->Appearance->Adopt Face and Frame Parameters as Frame Default

This will put a default-frame-alist definition in the custom-set-variables section of your customizations.el.

You can then season to taste if you later want a different cursor color.

mep1
  • 21
  • 1
  • I can't see using Aquamacs because it so badly breaks normal Emacs conventions. Once you start down that path, your config isn't portable. Besides, I'm used to moving and resizing new windows that the Mac puts in counter-intuitive locations. – infogizmo Mar 15 '13 at 02:25
0

If you suspect that your version of Emacs is doing something during startup that us overriding your preferences, you can try to set your preferences after init time by putting a function in after-init-hook:

(add-hook 'after-init-hook (lambda () (set-cursor-color "#aa88dd")) 'append)

Maybe this will cause your customization to be evaluated late enough to override the default. (Edit: With the "append" argument, this function will be added to the end of the hook list, hopefully overriding any other stuff that Aquamacs puts there.)

Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
  • It doesn't work. Aquamacs adds custom settings to after-init-hook, essentially breaking this feature too. You end up with this: `(lambda nil (set-cursor-color "#aa88dd")) aquamacs-turn-on-buffer-offer-save-in-scratch aquamacs-notice-user-settings aquamacs-update-new-file-menu aquamacs-create-customization-fontsets (lambda nil (if tabbar-mode (add-to-list ... ...)) (quote append)) aquamacs-setup-echo-areas smart-fp--load-frame-positions-from-file check-for-aquamacs-crashes aquamacs-check-for-updates-if-necessary display-startup-echo-area-message-2)` – infogizmo Mar 15 '13 at 02:27
0

Try putting a message at the bottom of your .emacs file (message "Hello -- this message came from the bottom of your .emacs file.") and a different message at the bottom of your customizations.el file (message "Hello -- this message came from the bottom of your customizations.el file."). The one that loads last will determine your cursor color settings if you have conflicting settings in each configuration file. If there is only one setting for the cursor color in either of those files, then you need to do a word search in the source files of Aquamacs to find out where else that cursor color is being set. For example, the following are the results of a word search for set-cursor-color in the source files for the most recent version of the Aquamacs24 branch on Github: https://github.com/davidswelt/aquamacs-emacs

The source files in the packaged application of Aquamacs are probably going to be compressed in a *.gz format. Depending upon the word search file utility you are using, you may need to perform a search on source files that are not compressed -- it may be easier to just download the source from Github since those source files will all be in an uncompressed format. There is zip download button once you select the branch you want.

Searching 9317 files for "set-cursor-color"

/Users/HOME/Desktop/aquamacs-emacs-aquamacs24/lisp/aquamacs/oneonone/oneonone.el:
 1453    "Set cursor type depending on whether an input method is used or not."
 1454    (when 1on1-change-cursor-on-input-method-flag
 1455:     (set-cursor-color
 1456       (if current-input-method
 1457           1on1-default-frame-cursor-color-input-method

/Users/HOME/Desktop/aquamacs-emacs-aquamacs24/lisp/emulation/cua-base.el:
 1141        (stringp color)
 1142        (not (equal color (frame-parameter nil 'cursor-color))))
 1143:  (set-cursor-color color))
 1144      (if (and type
 1145        (symbolp type)

/Users/HOME/Desktop/aquamacs-emacs-aquamacs24/lisp/emulation/viper-util.el:
  156  ;; This was equally true before the advent of viper-frame-value.
  157  ;; Now it could be changed by passing frame to v-f-v.
  158: (defun viper-set-cursor-color-according-to-state (&optional frame)
  159    (cond ((eq viper-current-state 'replace-state)
  160    (viper-change-cursor-color

/Users/HOME/Desktop/aquamacs-emacs-aquamacs24/lisp/emulation/viper.el:
  946        ))
  947  
  948:   (defadvice set-cursor-color (after viper-set-cursor-color-ad activate)
  949      "Change cursor color in VI state."
  950      (modify-frame-parameters

/Users/HOME/Desktop/aquamacs-emacs-aquamacs24/lisp/frame.el:
 1208        (face-set-after-frame-default (selected-frame))))
 1209  
 1210: (defun set-cursor-color (color-name)
 1211    "Set the text cursor color of the selected frame to COLOR-NAME.
 1212  When called interactively, prompt for the name of the color to use.

/Users/HOME/Desktop/aquamacs-emacs-aquamacs24/lisp/term/pc-win.el:
  349  (fset 'set-default-font 'ignore)
  350  (fset 'set-mouse-color 'ignore)      ; We cannot, I think.
  351: (fset 'set-cursor-color 'ignore) ; Hardware determined by char under.
  352  (fset 'set-border-color 'ignore) ; Not useful.
  353  
lawlist
  • 13,099
  • 3
  • 49
  • 158