Basically, I installed the latest Emacs 24.3 on my MAC OSX. I am completely new to Emacs.
Is there an equivalent of .vimrc in emacs? What is it called because I want to change the key bindings?
Problem 1: Instead of having Ctrl as C- key, I want to have CMD as C-. What is the code for this?
Problem 2: I notice that traditionally we have C- right arrow key as Slurp and C-left arrow key as barf. But on my mac, they don't work anymore and they are replaced by C-M-j and C-M-e. It took me a while to find out about this. I want to know why is it that a lot of the key bindings are so much different from Emacs on Windows? If I want the key bindings to be consistent with the ones on the Windows computer, is there a convenient way to do this or do I have to remap every single key manually?
The emacs equivalent of the .vimrc is the so called init file which can either be ~/.emacs, ~/_emacs, or ~/.emacs.d/init.el.
You can change keybindings using the define-key, local-set-key, and global-set-key commands, check the blog post Mastering Key Bindings in Emacs for a more complete introduction.
Basically, if you want to change the key Ctrl + f to open a file, you have to add
(global-set-key (kbd "C-f") 'find-file)
to your config.
You might want to check the SO question "Emacs on Mac OS X Leopard key bindings" for help on Problem 1 (using Command as Ctrl).
I'm not completely sure what your second problem is, but as far as I know, there is no way to tell emacs to gather system global keybindings and use them internally. Hence, if you OS has some set of keybindings which you'd like to mirror in emacs, you need to remap them manually.
Problem 2: I notice that traditionally we have C- right arrow key as Slurp and C-left arrow key as barf. But on my mac, they
don't work anymore
With emacsformacosx on OSX 10.10.5, I can slurp and barf with these key sequences:
C-) (slurp)
C-} (barf)
M-( (wrap)
Here's an example from "Clojure for the Brave and True":
Suppose you have this:
(+ 1 2 3 4)
and you want to get this:
(+ 1 (* 2 3) 4)
First, place the cursor("the point") here:
(+ 1 |2 3 4)
(The 2 will be highlighted.)
Then hit M-( (that's Option+Shift+9) to wrap the 2 in parentheses:
(+ 1 (|2) 3 4)
Then type the * and a space:
(+ 1 (* |2) 3 4)
To slurp the 3, hit C-) (that's Control+Shift+0):
(+ 1 (* |2 3) 4)
To barf the 3, place the cursor anywhere inside the inner parentheses and hit C-} (that's Control+Shift+] ):
(+ 1 (* 2) 3 4)
Related
i will get custom block in a .dwg file from a list of blocks which I will parse programmatically in Java.
You can use the command INSERT with the option ?
cd C:\Program Files\Autodesk\AutoCAD 2016
accoreconsole.exe /i "Sample\Database Connectivity\Floor Plan Sample.dwg"
Command: _INSERT
Enter block name or [?]: ?
Enter block(s) to list <*>:
Defined blocks.
"CHAIR7"
"COMPUTER"
"DESK2"
"DESK3"
"DOOR"
"DR-36"
"DR-69P"
"DR-72P"
"FC15X27A"
"FC42X18D"
"FNPHONE"
"IBMAT"
"KEYBOARD"
"NCL-HL"
"RECTANG"
"RMNUM"
"SOFA2"
User Unnamed
Blocks Blocks
17 0
I am not familiar with Core Console but for listing all block in a DWG file, you need to use LISPs. Something like axBlock from jtbworld . You may also mock around with LISP code and call it via a SCRIPT.
Edit:
Copy and paste following code in Notepad and save it as axBlock.lsp in the root fo your C drive (for instance):
(defun c:axblocks (/ b bn tl)
(vlax-for b (vla-get-blocks
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(if (= (vla-get-islayout b) :vlax-false)
(setq tl (cons (vla-get-name b) tl))
)
)
(reverse tl)
)
I just tweaked jtbworld's code a little bit to make it easier for you.
Now you have your LISP code ready and you only need to load it into AutoCAD. You have couple of options for that:
Use APPLOAD command in AutoCAD and browse for axBlock.lsp which
you just created
Drag axBlock.lsp over your AutoCAD window.
Call axBlock.lsp via a script file. And scripts are nothing
really
but a simple textual file with *.scr extension. For that you just
need this line of code to be in your script file:
(load "C:\\axBlock.lsp")
After doing any of above three methods, as long as you type axBlock in AutoCAD and hit Enter, you will see the list of existing blocks.
Moreover, if you followed approach no.3 from above list, you can make a shortcut and call axBlock within the script file as well i.e. you load and call the function in one hit. If you want to do so, just add axBlock in the second line of your script code. Note there an extra SPACE after axBlock
I'm currently sshing from my mac to a CentOS box, where I run emacs. For whatever reason, the shift key doesn't seem to work when issuing a keyboard sequence. I suspect the wrong key code is being sent.
For example, I've remapped my help command to the following:
(global-set-key (kbd "C-?") 'help-command)
Executing this keyboard sequence in a typescript file reveals that it's invoking the delete-backward-char command, which is a compiled Lisp function from simple.el. (In order to even check what command the keyboard sequence was executing, I had to temporarily remap help to C-o.)
Similarly, I have the following key binding set up for typescript mode
(setq tss-popup-help-key "C-:")
Likewise, it looks like the SHIFT key hasn't registered because I get the following definition in the help manual when I reverse lookup the sequence:
; runs the command typescript-insert-and-indent, which is an
interactive compiled Lisp function in `typescript.el'.
It is bound to ,, ;, ), (, }, {.
(typescript-insert-and-indent KEY)
In other words, emacs registers the colon as a semi-colon.
This is a recurring problem with keyboard sequences that require me to use a SHIFT key. How do I get the SHIFT key to work properly when working on emacs through a mac?
For the record, when I use Emacs for OSX, the shift key works great.
I tried to override it by putting (:lt.objs.editor/tab-settings false 2 2) in the editor section of my user.behaviors, but it doesn't change anything. Everytime I press enter within for example <head> tag of my html file, I get 4 spaces indent. I've been googling it for about half an hour now. Do you know what am I doing wrong?
I'm on the OS X version. Here's my whole user.behaviors:
{:+ {
;; The app tag is kind of like global scope. You assign behaviors that affect
;; all of Light Table here
:app [(:lt.objs.style/set-skin "dark")]
;; The editor tag is applied to all editors
:editor [:lt.objs.editor/no-wrap
(:lt.objs.style/set-theme "default")
(:lt.plugins.vim/activate-vim)
(:lt.objs.editor/tab-settings false 2 2)]
;; Here we can add behaviors to just clojure editors
:editor.clojure [(:lt.plugins.clojure/print-length 1000)]}
;; You can use the subtract key to remove behavior that may get added by
;; another diff
:- {:app []}}
I got the answer from Chris Ganger:
set it for editor.html
So the right way is
:editor.html [(:lt.objs.editor/tab-settings false 2 2)]
Edit: For newer versions of Lighttable the correct syntax is
[:editor.html :lt.objs.editor/tab-settings false 2 2]
As of April 2015, the accepted answer didn't work for me, but the LightTable FAQ's incantation took effect right away:
;; 2 2 is tab size in spaces and spaces per indent
[:editor :lt.objs.editor/tab-settings false 2 2]
LightTable 0.7.2 (binary 0.8.4) on OS X 10.10.3.
I lost my configuration or never had it.
I need to send shift+F1 and ctrl+F1, shift+F2 and ctrl+F2 and so on to the terminal since I'm connecting to a linux machine via ssh.
well, my current config is missing these string mappings as you can see in the image.
do you know what are the string mappings for those key combinations ?
thanks.
UPDATE:
in some stackexchange i found this command:
$>for x in {1..12}; do echo -n "F$x "; tput kf$x | cat -A; echo; done
can you help me to print the strings for shift + f1 ?
First: From this page http://invisible-island.net/xterm/xterm.faq.html, you will understand that shift-F1 maps to F11, shift-F2 maps to F12 and so on.(Search the page 'a summary of the keyboard mapping' without ', you will see the list).
Second: From this page http://aperiodic.net/phil/archives/Geekery/term-function-keys.html, you will know F1 or F11 or F20 maps to what string(at the bottom).
More to say:
If you want to send Shift-F1 to a program through Terminal, these will happen:
You hit Shift-F1, the Terminal will translate the Shift-F1 to a string sequence
The string sequence will be sent to the program
For example, you send a Shift-F1 to emacs through the Terminal,the Terminal translate it into string sequence and send the string sequence to emacs, emacs will recognise it as a key strokes then do something.
I'm not quite familiar about this, so this answer may be not right.
I have Ruby Electric mode installed via ELPA.
I have visited a ruby file ~/test.rb
C-h m reveals that ruby electric mode is enabled as is font lock, see output below
Enabled minor modes: Auto-Compression Auto-Encryption Blink-Cursor Column-Number
Delete-Selection File-Name-Shadow Global-Font-Lock Global-Linum Iswitchb Line-Number
Menu-Bar Mouse-Wheel Shell-Dirtrack Tooltip Transient-Mark
However when I enter code like;
class Test
def foo()
I don't get any end auto inserted on hitting RET
UPDATE
I installed via package-list as that was recommended on the page I found, which I thought belonged to the author. Looking at the source of ~/emacs.d/elpa/ruby-electric-1.1/ruby-electric.el I see the following;
;; FIXME: it should be available in next versions of ruby-mode.el
(defun ruby-insert-end ()
(interactive)
(insert "end")
(ruby-indent-line t)
(end-of-line))
So it looks like I might have a bad file, will try another.
UPDATE
I used ruby-electric.el downloaded from http://svn.ruby-lang.org/repos/ruby/tags/v1_9_2_0/misc/ruby-electric.el
Linked to from this article http://appsintheopen.com/articles/1-setting-up-emacs-for-rails-development/part/7-emacs-ruby-foo
Then took this gist https://gist.github.com/1213051 adding this to ruby-electric.el
(defun ruby-insert-end ()
"Insert \"end\" at point and reindent current line."
(interactive)
(insert "end")
(ruby-indent-line t)
(end-of-line))
And this hook into my .emacs, it also appears to work without the hook
(add-hook 'ruby-mode-hook
(lambda ()
(require 'ruby-electric)
(ruby-electric-mode t)))
As discussed in this google groups thread; https://groups.google.com/forum/?fromgroups#!msg/emacs-on-rails/Cuh_x5eCK_M/KDwjY4K6X1YJ
Make sure it says REl in your emacs status bar.
I downloaded ruby-electric from here:
http://shylock.uw.hu/Emacs/ruby-electric.el
I then loaded the library into emacs, and went into a ruby file and activated
ruby electric with:
M-x ruby-electric-mode
When I type class and hit space it fills in the end automatically (running emacs 23). Maybe you want to give that version of ruby-electric.el a try, if you can't get the one from ELPA to work.
You need to include 'ruby-additional' to use 'ruby-electric':
https://github.com/ruby/ruby/blob/trunk/misc/ruby-additional.el
Should be merged in emacs some day.