Vi is somewhat cool, kate looks even better in places, but none of them had anything nearly as useful, as verilog-mode in emacs. Therefore, I decided to make the switch.
However, making yourself somewhat confortable in emacs requires a bit of effort, so here go my adjustments.
First, let’s get out emacs instances at different places in sync. Git is a very good tool for that. Therefore, I put my custom el scripts in ~/.emacs.d and made that a git repo with origin at my github account. Next step is to tune ~/.emacs to automagically load ~/.emacs.d/autoexec.el via adding
Rest – under the cut.
Done. Now we can make sure, that our code will be in sync. All of the following can safely go to autoexec.el
I also created these convenience shortcuts.
(defun th-emacs-push() (interactive) (shell-command (concat "cd ~/.emacs.d; git commit -a -m \"Autocommit from emacs\"; git push")) ) (defun th-emacs-pull() (interactive) (shell-command "cd ~/.emacs.d; git pull;") ) (defun th-reload() (interactive) (message "Rerunning autoexec") (load-file "~/.emacs.d/autoexec.el"); ) (defalias 'epush 'th-emacs-push) (defalias 'epull 'th-emacs-pull) (defalias 'reload 'th-reload)
Basically that allows me to reload my profile via M-x reload, use M-x epush to automatically commit my changes to files in emacs.d, and push them to github via M-x epush, as well as quickly pulling them via M-x epull. Just the way I like it.
Next, the hotkeys. I don’t mind switching to emacs’ weird delete/yank (cut/copy/paste) sequences, but since I use a shitload of other programs that expect ‘traditional Ctrl+C/Ctrl+V/CTRL+X’ behaviour, I decided to avoid the mess. Luckily – we have cua-mode, so let’s enable that by default.
(cua-mode t) (setq cua-auto-tabify-rectangles nil) ;; Don't tabify after rectangle commands (transient-mark-mode 1) ;; No region when it is not highlighted (setq cua-keep-region-after-copy t) ;; Standard Windows behaviour
Next. I use KDE, so I prefer the KDE file selection dialog. I found the integration on the web, and just added a few blows and whistles, like remembering the last visited directory.
Here goes the magic:
(setq th-ffk-path '"~") (defun th-find-file-kio () (interactive) (let ((file-name (replace-regexp-in-string "[\n]+" "" (shell-command-to-string (concat "kdialog --getopenurl " th-ffk-path " 2> /dev/null"))))) (message file-name) (cond ((string-match "^file://" file-name) ;; Work arround a bug in kioexec, which causes it to delete local ;; files. (See bugs.kde.org, Bug 127894.) Because of this we open the ;; file with `find-file' instead of emacsclient. (let ((local-file-name (substring file-name 7))) (message "Opening local file '%s'" local-file-name) (setq th-ffk-path local-file-name ) (find-file local-file-name))) ((string-match "^[:space:]*$" file-name) (message "Empty file name given, doing nothing...")) (t (message "Opening remote file '%s'" file-name) (save-window-excursion (shell-command (concat "kioexec emacsclient " file-name "&")))))) ) (defalias 'ffk 'th-find-file-kio )
Just M-x ffk – and the KDE file dialog appears.
And the final touch – I use my laptop in several locations, and would like to load additional stuff quickly, sometimes with some custom setup. Therefore, I made up this shit:
(defun th-prof (prof) (interactive "sProfile, plz: ") (load-file (concat "~/.emacs.d/profiles/" prof ".el")) ) (defalias 'prof 'th-prof )
M-x prof prompts me the profile name and loads additional hotkeys and code.
Looks like that’s the basic setup for me.