tags:

views:

70

answers:

2

I have a Mac Laptop and I am connecting to server running Linux. As Alt+3 is already bound in EMACS to a command, so I cannot insert the hash symbol in a file. I have tried the following solution I found online:

(global-unset-key (kbd "C-3"))
(global-set-key (kbd "C-3") '(lambda() (interactive) (insert-string
"#")))      //I know that C is for CTRL not Alt - I have tried with
M-3 instead as well

and some others as well, but none seem to work. Can you tell me any other way in which I might be able to enter the hash sign (#) in a file.

Aso tried (did not work):

(fset 'insertPound "#")
(global-set-key (kbd "M-3") 'insertPound)

Thank you!

A: 

As S.Lott said, it's S-3 to insert a number sign (or hash, pound, octothrope).

Why do you want to use the meta modifier to insert it? Also, what is M-3 bound to on your setup? You can get it by doing an C-h-k and then hitting the key combination.


Assuming you are referring to Alt properly and that it's setting the Meta modification bit you can shove

(global-unset-key (kbd "M-3"))

into your .emacs and eval it to disable this from happening.

All "normal" keys are bound to self-insert-command. The shift modifier simply upcases the 'key' which is used to call this function so you get a # instead of 3 when you do a S-3.

Also, I still don't understand why you're using Alt rather than shift to display the # symbol. What do you do when you want to type a @?

Noufal Ibrahim
It is Alt+3 on my machine. In EMACS this is bound to split-windows-horizontaly.
Andrei Iulian Dvornic
I've updated my answer.
Noufal Ibrahim
Shift+2 for @. I have got a MacBook pro with european style keyboard.
Andrei Iulian Dvornic
It didn't work. Now M-3 still splits my display into two windows.
Andrei Iulian Dvornic
+3  A: 

I assume that you have a Mac UK keyboard so Shift-3 is £. On most other keyboards Shift-3 is # as others have said.

The way I get round it is to change the input source to Australian the only difference is that Shift-3 is now # and Alt-3 is £ (or leave as the emacs binding)

Input Source setting is System Preferences->Language&text->Input Source

Mark
Fantastic! It worked.
Andrei Iulian Dvornic
Thank you so much!
Andrei Iulian Dvornic
+1. I need to become more culturally sensitive and realise that there are keyboards different from my own. :)
Noufal Ibrahim