Question

I currently have this in my .emacs, which worked just fine in Linux:

;; paredit                                                                       
;; this is from somewhere else on Stackoverflow                                  
;; deals with curly brackets matching and stuff                                  
;; I edited the answer a little bit                                              

(defmacro setup-paredit (func-name mode-map)                                     
  `(defun ,func-name ()                                                          
     (define-key ,mode-map                                                       
       (kbd "DEL") 'paredit-backward-delete)                                     
     (define-key ,mode-map                                                       
       (kbd "{") 'paredit-open-curly)                                            
     (define-key ,mode-map                                                       
       (kbd "}") 'paredit-close-curly)                                           
     (modify-syntax-entry ?\{ "(}")                                              
     (modify-syntax-entry ?\} "){")                                              
     (modify-syntax-entry ?\[ "(]")                                              
     (modify-syntax-entry ?\] ")[")                                              
     (modify-syntax-entry ?~ "'   ")                                             
     (modify-syntax-entry ?, "    ")                                             
     (modify-syntax-entry ?^ "'")                                                
     (modify-syntax-entry ?= "'")))                                              

(defmacro setup-paredit-mode (func-name mode-map mode-hook)                      
  `(progn (setup-paredit ,func-name ,mode-map)                                   
          (add-hook ',mode-hook ',func-name)                                     
          (add-hook ',mode-hook 'enable-paredit-mode)))                          

;; probably doing lots of things wrong but at least this seems to work well      
(setup-paredit-mode setup-c++-paredit c++-mode-map c++-mode-hook)               
(setup-paredit-mode setup-slime-repl-paredit slime-repl-mode-map slime-repl-mod\
e-hook)                                                                          
(setup-paredit-mode setup-slime-paredit slime-mode-map slime-mode-hook)         
(setup-paredit-mode setup-clojure-paredit clojure-mode-map clojure-mode-hook)   
(setup-paredit-mode setup-emacs-paredit emacs-lisp-mode-map emacs-lisp-mode-hoo\
k)                                                                               
(setup-paredit-mode setup-css-paredit css-mode-map css-mode-hook)

But the last bit in Mac OS X makes arrow keys produce the following output:

[C [A [D [A [B [D [C [B [D [B [D]]]]]]]]]]]

Another weird thing when hitting C-x C-c:

Symbol's function definition is void: switch-to-buffer-in-tab

I finally killed it with C-x C-z.

These do not happen if I comment out the last part after ;; probably..., so the problem probably lies there. How should I go about fixing this problem?

EDIT:

I found this. Simply copy-pasting the code there didn't work. Hitting the arrow keys gave me this:

# ESC [ ⇧A ESC [ ⇧B ESC [ ⇧C ESC [ ⇧D #

Being the newb I am, I am not sure how to "adjust the code given above appropriately," though. (Also what is that up arrow doing?)

EDIT 2:

The C-c C-x problem, at least, seems to have been solved somehow with this .emacs code:

;; Fix Mac arrow keys                                                            
(if (not window-system);; Only use in tty-sessions.                              
     (progn                                                                      
      (defvar arrow-keys-map (make-sparse-keymap) "Keymap for arrow keys")       
      (define-key esc-map "[" arrow-keys-map)                                    
      (define-key arrow-keys-map "⇧A" 'previous-line)                            
      (define-key arrow-keys-map "⇧B" 'next-line)                                
      (define-key arrow-keys-map "⇧C" 'forward-char)                             
      (define-key arrow-keys-map "⇧D" 'backward-char)))

Arrow keys still not working when paredit is active.

EDIT 3:

I should add that all this is happening inside the Terminal. I am not sure whether it still happens with the GUI, because somehow my .emacs is causing Aquamacs to not display any windows.

Arrow keys work fine in Emacs GUI, but not in -nw mode.

Was it helpful?

Solution

Finally got it working. In Terminal Preferences, under Settings > Advanced > Emulation, I set Declare terminal as: to vt100.

I did try this before, but it turns out that you need to close the Terminal window before starting Emacs up again, otherwise it will still use the current settings.

Now the downside is that Emacs is B&W. Will see if any other emulation settings work.

EDIT:

xterm-256color (the default) works just fine, with color. GRRRRR. All this because some tutorial (I forgot for what) told me to set the Terminal emulation to rxvt. Hahahaha.

At least I hope this helps somebody in the future.

OTHER TIPS

Please try this and i assume you will be able to resolve the same chsh -s /bin/bash

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top