Suggested initial Emacs config? - configuration

I would like to to try Emacs, and want to give it the best chance possible.
To do this, it seems like having a good .emacs file is important.
I primarily use Mac OS X (so I have looked at Aquamacs), and I mainly do Python programming, so anything specifically for that would be great.

I'd suggest starting with a blank .emacs file. Then go through the tutorials and related blog posts, and grow it as you learn. Using a .emacs file that's borrowed from someone else seems a little like missing the point.

That is a hard question. My theory about Emacs is that you have to give it a real honest try. That means working with it for a few months, not days. It is not for the faint of heart! Ideally emacs would become your one and only text editor, and you do things the emacs way.
Really, to give yourself and emacs the best chance possible, you should learn enough elisp to do your own basic customizations.
In fact, I think your .emacs is probably a read herring with regards to giving emacs the best possible chance. Instead, try out some of the groovier features like flymake with pylint, the inferior python process, python debugging with emacs are all worthwhile. In particular inferior processes are the bomb.
EmacsWiki has some good info on python and emacs.

The most important configuration change that I have found is not one for your .emacs, but for your OS. In the "Keyboard & Mouse" system preferences, in the "Keyboard" tab, click "Modifier Keys..." at the bottom and then change "Caps Lock" to behave like "Control." Then train yourself to use the caps lock key (to the left of the "A") instead of the control key down in the corner. This will make the whole experience both far more productive and far more comfortable.
see: Emacs on Mac OS X Leopard key bindings

See these related questions:
What’s in your .emacs?
Emacs and Python

You can try following extensions:
(require 'smooth-scrolling)
(require 'multiple-cursors)
(require 'ace-jump-mode)
(require 'expand-region)
(require 'inline-string-rectangle)
(require 'mark-more-like-this)
(require 'key-chord)
(require 'browse-kill-ring)
(require 'idle-highlight-mode)
(require 'htmlize)
(require 'icicles)
(require 'highlight-parentheses)
(require 'golden-ratio)
(require 'projectile)
(require 'helm-projectile)
(require 'rainbow-mode)
(require 'anything-config)
(require 'highlight-symbol)
(require 'markerpen)
(require 'flyspell)
also you can distinguish TAB and C-i, then you'll have one more simple short-key.
(define-key input-decode-map (kbd "C-i") (kbd "H-i"))
(define-key input-decode-map (kbd "C-M-i") (kbd "H-M-i"))
(global-set-key (kbd "H-i") 'kill-ring-save)
(global-set-key (kbd "M-i") 'kill-ring-save)
(global-set-key (kbd "H-M-i") 'ace-jump-line-mode)
(global-set-key (kbd "C-c H-i") 'ido-switch-buffer)
find more:
https://github.com/whunmr/dotemacs/blob/master/init.el

To add on to a few others' comments, I currently am running with the following modifier key set up:
Caps-lock = Control
Control = Option
Option = Inactive
Command = Command
Under Emacs (btw, you mentioned Aquamacs, go with Emacs.app instead) I then specify via the preferences to have Option = Command and Command = Option. This places the two most used keys (C and M) just off the home row and just off the space bar, which I've found to be very comfortable to use.
To go with Emacs.app, just use MacPorts to install it
sudo port install emacs-app
Also, I'm going to put my encouragement in there with everyone else; You have to try this for an extended period of time or you will not stick with it. Go through the tutorial multiple times (C-h t), browse through the Info manual (C-h r), if you don't know how to use Info, go through the Info manual (C-h i h) (it's really an incredible documentation system), and for about 30 of the best tips I've ever heard written in a really concise manner, visit Yegge's old effective Emacs post. Beyond all that, really turn off everything else and just go for it. When you come up against something you don't know how to do, take the opportunity to research it, repeat it a few times, and then move on. You'll slow down a lot at first but afterwards you will be much more efficient at editing any sort of text out there.

I've created a modular emacs config for myself. Feel free to take a look here.

Please check out emacs starter kit for some of the best defaults for emacs.
You might also want to checkout this screencast

For emacs 24 you might like to have a look at emacs-prelude.

You can look to my emacs configs, located on my site. Aquamacs-specific configuration you can find in separate file

Related

Is it possible to change the default comment string in Octave GUI?

In Octave GUI Editor the Ctrl+R shortcut comments the selected lines out with the Octave default string ##. But I share my code with other colleagues who use MATLAB. I was wondering if I could change the above keyboard shortcut and the Ctrl+Shift+R to use the MATLAB commenting character % by default? I'm aware of the Ctrl+Alt+R shortcut where one can choose the string, but that is not very handy given the muscle memory and the extra step.
P.S. I posted this question also here on the unofficial Octave Discord channel.
OK, I think I found the solution, and it was way easier than what I had anticipated. Basically, the Octave GUI team had already thought of that. Just go to Edit > Preference, and then in the Comments (Octave) section, select the % option:

Setting `sql-mysql-program` in emacs

There are at least three major overviews that come up when searching for information on using sql with emacs (due to my insufficient reputation I can't 'afford' to link to them here).
I can find no mention in any of them of the need to set the variable sql-mysql-program when working with mysql servers. Yet I could not get M-x sql-mysql to work without following the advice from this SO question to set this variable as follows:
(setq sql-mysql-program "/path/to/your/mysql")
In fact, the only tutorials/documentation I've seen highlighting this variable are in the above SO question and another SO question about "emacs-how-to-use-ssh-tunnel-to-connect-to-remote-mysql" (which again I can't link to because of insufficient reputation.)
An alternate solution seems to be suggested here How to work with emacs and mysql, which suggests changing the value of the emacs exec-path.
The question is, which of these options is preferable, or is it simply a matter of taste?
And what is the significance of the fact that none of the above-linked overviews of sql/emacs mentions the need to get emacs to recognize the binary? Is there something wrong with my emacs?
I spent a long time combing the sql.el source to try to understand what was going on and I do see a (defcustom sql-mysql-program "mysql"…)but in my case at least that did not seem to do the trick (perhaps because I'm starting emacs up with -q option?).
PS. In case it matters, my M-x emacs-version is GNU Emacs 24.5.1 (x86_64-apple-darwin12.5.0, NS apple-appkit-1187.40) of 2015-05-01, which I am running on an older Mac (10.8.5)
Note that this can be generalised to a question of:
What do I do if Emacs can't find an executable?
which is where the exec-path list comes into play.
As noted in C-hig (emacs) Shell RET, the exec-path list is initialised from the environment variable PATH when Emacs is started (see also (emacs) General Variables), so there are multiple ways to populate that list with the values you need.
Using an absolute path to sql-mysql-program is also fine, but potentially less portable. It's up to you, really.

how to create applications with Clozure Common Lisp (on Microsoft Windows)

I am a new one to Common Lisp (using Clozure Common Lisp under Microsoft Windows), who is familiar with c and python before. So maybe the questions are stupid here, but be patient to give me some help.
1) What's is the usual way to run a common lisp script?
Now, I wrote a bat file under windows to call ccl exe(wx86cl.exe) and evaluate (progn (load "my_script_full_path") (ccl:quit)) every time when I want to "run" my script. Is this a standard way to "run" a script for common lisp?
Any other suggestion about this?
2) What's the difference between (require 'cxml) and (asdf:operate 'asdf:load-op :cxml)?
They are seems to be the same for my script, which one should I use?
3) ignore it, not a clear question
4) When I want to load some library (such as require 'cxml), it always takes time(3s or even 5s) to load cxml every time when I "run" my script, there is also much log to standard output I show below, it seems like checking something internal. Does it means I have to spent 3-5s to load cxml every time when I want to run a simple test? It seems like a little inefficient and the output is noisy. Any suggestion?
My Script
(require 'cxml) (some-code-using-cxml)
And the output
; Loading system definition from D:/_play_/lispbox-0.7/quicklisp/dists/quicklisp/software/cxml-20101107-git/cxml.asd into #<Package "ASDF0">
;;; Checking for wide character support... yes, using code points.
; Registering #<SYSTEM "cxml-xml">
......
some my script output
---EDIT TO ADD MORE----
5) I must say that I almost forget the way of dumping image to accelerate the loading speed of lisp library. So, what is the normal process for us to develop a (maybe very simple) lisp script?
Base on the answer of what I got now, I guess maybe
a) edit your script
b) test it via a REPL environment, SLIME is a really good choice, and there should be many loop between a <==> b
c) dump the image to distribute it?( I am no sure about this)
6) Furthermore, what is the common way/form for us to release/distribute the final program?
For a lisp library, we just release our source code, and let someone else can "load/require" them.
For a lisp program, we dump a image to distribute it when we confirm that all functions go well.
Am I right?
What form do we use in a real product? Do we always dump all the thing into a image at final to speed up the loading speed?
1) Yes, the normal way to run a whole programme is to use a launcher script. However, windows has much, much better scripting support these days than just the bat interpreter. Windows Scripting Host and PowerShell ship as standard.
1a) During development, it is usual to simply type things in a the REPL (Read-Eval-Print-Loop, i.e. the lisp command line), or to use something like SLIME (for emacs or xemacs) as a development environment. If you don't know what they are, look them up. You may wish to use Cygwin to install xemacs, which will give you access to a range of linux-ish tools.
2) Require is, IIRC, a part of the standard. ASDF is technically not, it is a library that operates to make libraries work more conveniently. ASDF has a bunch of features that you will eventually want if you really get into writing large Lisp programmes.
3) Question unclear, pass.
4) See 1a) - do your tests and modifications in a running instance, thus avoiding the need to load the library more than once (just as you would in Python - you found the python repl, right?). In addition, when your programme is complete, you can probably dump an image which has all of your libraries pre-loaded.
Edit: additional answers:
5) Yes
6) Once you have dumped the image, you will still need to distribute the lisp binary to load the memory image. To make this transparent to the user, you will also have to have a loader script (or binary) to run the lisp binary with the image.
You don't have to start the lisp from scratch and load everything over again each time you want to run a simple test. For more efficient development, interactively evaluate code in the listener (REPL) of a running lisp environment.
For distribution, I use Zachary Beane's Buildapp tool. Very easy to install and use.
Regarding distribution -
I wrote a routine (it's at home and unavailable at the moment) that will write out the current image as a standard executable and quit. It works for both CLISP and SBCL.
I can rummage it up if you like.

Find and Replace in Files - UTF8

Searching for a free application for commercial usage that allows find/replace in multiple files (regular expressions are nice but not a must), that supports opening and saving in UTF-8.
Tried a few like BKReplaceEm but the application ends up saving all the files as ASCII which causes some problems with web-rendering.
Please advise.
[UPDATE] To further clarify, I am searching for a windows utility.
[UPDATE #2] This is going to be used to run through our 450 page site and replace all french characters with the much needed HTML entities.
Notepad++ supports this feature, and is a great little editor in it's own regard.
Edit : Actually, Notepad++ does support replace in files. Click Search -> Find in Files, then select "Replace in files" in the dialog.
In the spirit of previous answer, you can use Perl (which has seamless native Unicode support and whose RegEx capablity are unparalleled). There are Windows perl versions avialable (ActivePerl, Strawberry, or you can use CygWin), and you can even slap GUIs on top of it -= for the latter, you can see what answers are given to my very recent So question :)
Plus, Perl can grab pretty much unlimitedly powerful collection of files, by using globs for simple things, File::Find for more complicated, and using grep on resulting file list to refine further if you need more fancy stuff, e.g. by content of modification time.
UPDATE For a Windows Editor, you can use UltraEdit. It has free evaluation period, and to be perfectly honest, I find the purchase price to be WELL worth paying for this very nice and powerful editor. Among its other features, it supports Unicode, and has pretty fancy search/replace ablities, including Perl RegEx support and S/R in multiple files.
Use sed.
jEdit has a feature called "HyperSearch" (just open the find dialog). You can specify a directory, a file name pattern and jEdit (being based on Java) does support lots of different encodings (and is often smart enough to figure out the correct one).
You could try my editor, Code Trowel
If it doesn't do what you want I'd probably fix it :-)
For windows, Notepad++ is awesome. It's licensed under the GPL. It does search and replace in files and does support regular expressions.

Which Mercurial plugin should I use for IntelliJ

Which of the hg plug-ins has:
the least hassles
causes the least trouble
is prettiest
Can't claim to have tried a wide variety, but, what's wrong with hg4idea...?
In regards to the "don't use one" response - this is hardly adequate. What if I use my IDE to do a refactoring that renames a file? Without IDE/source control integration, the file rename is made without regards to source control, and then Mercurial (or whatever else) thinks a file went missing and a new one appeared. Then you have to go back to wrangle with the source control to sort things out.
JetBrains seems to have chosen hg4idea-luciad for its upcoming Python editor (PyCharm) and it is now more active than hg4idea
It looks like a leader is on the way :-)
To answer your question: The best IDE PlugIn is don't use on.
I think IDE integration is not necessary when working with a DVCS. When working in a centralized System, it is reasonable for the purpose of automatic check out on edit. However, I like keeping things separate. I don't want my IDE cluttered up. I don't see any benefits in using a plug-in compared to a standalone solution (that I keep running on a second monitor etc. ).
I am fine with TortoiseHG and the command line for more complicated tasks.