tag:blogger.com,1999:blog-3992530807750384868.post7380396645565037070..comments2022-03-28T08:42:20.497+03:00Comments on emacs-fu: dot-emacs trickeryUnknownnoreply@blogger.comBlogger33125tag:blogger.com,1999:blog-3992530807750384868.post-64522372285126153522011-11-12T16:54:55.216+02:002011-11-12T16:54:55.216+02:00'(recentf-mode 1)
(global-set-key "\C-x\...'(recentf-mode 1)<br /><br />(global-set-key "\C-x\C-r" 'recentf-open-most-recent-file)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-55929914127860460912009-08-17T16:18:30.171+03:002009-08-17T16:18:30.171+03:00@shardul: That last one is not necessary in Emacs ...<b>@shardul</b>: That last one is not necessary in Emacs 23. C-l is now bound to <i>recenter-top-bottom</i>. One press gets to the old behaviour; two take the current line to the top and three to the bottom.Erichttps://www.blogger.com/profile/03789079032968275865noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-25926970369795027742009-08-17T10:00:56.094+03:002009-08-17T10:00:56.094+03:00Not particularly intelligent ones, but I find thes...Not particularly intelligent ones, but I find these helpful <br /><br />1. in case of vertically split window.<br /><br />;; enlarge frame height by 10 lines.<br />(global-set-key [f8] "\C-u\ 10\ \C-x\ ^")<br /><br />2. <br />;; get current line to the top of window.<br />(global-set-key "\C-t" "\C-u\ 1\ \C-l")Shardulhttps://www.blogger.com/profile/02205190778239719943noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-73178137469206952942009-06-15T16:29:38.181+03:002009-06-15T16:29:38.181+03:00Pertinent to the last suggestion by yoosblog about...Pertinent to the last suggestion by yoosblog about turning word wrap on, consider also adding:<br /><b>(setq truncate-partial-width-windows nil)</b>, Setting this the toggle-truncate trick will be possible in buffers into a split of windows. It overrides truncate functionality, which otherwise wouldn't work in a buffer contained in a frame split with two or more windows.Unknownhttps://www.blogger.com/profile/12943251008085959126noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-28995222859696167702009-05-14T13:30:00.000+03:002009-05-14T13:30:00.000+03:00TIP: How to paste these stuff to your dotemacs fil...TIP: How to paste these stuff to your dotemacs file,<br /><br />1. select the part of code (with mouse) in your browser.<br />2. middle click somewhere (probabily at the end) in your dotemacs buffer or C-y<br />3. C-M-\ to properly indent the code. (you don't want to rely on parenthesis much, you rely on indentation to read the code)<br />4. M-x eval-region (to check the code actually works. some blog automatically changes quote and double quotes symbols.)<br /><br />And try C-h f, C-h F and C-h v at various points to see what all those functions, variables, modes and hooks mean.<br /><br /><br />Here's my share.<br /><br />;; [usage-memo] [umemo] (integration of memo and help) ;; put it before all minor mode. ;; you write memo at the end of Help buffer and press C-x C-s to save it.<br />(require 'usage-memo)<br />(umemo-initialize)<br />(setq umemo-base-directory "~/em/umemo/") ; need not create the dir by hand.<br /><br /><br />;; [parenface] for hiding (or toning down) parenthesis in lisp modes<br />(require 'parenface)<br /><br /><br />;; [truncate] soft word wrapping mode on and off in emacs. ;; This does not change the content of the buffer.<br />;; (setq-default truncate-lines t) ; truncate lines by default, i.e. put soft word wrapping mode off by default. You need truncate-lines mode to easily read a big ascii table and a deeply indented code with many very long lines.<br />(global-set-key (kbd "\C-c w") 'toggle-truncate-lines)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-28958155537248894332009-05-05T20:46:00.000+03:002009-05-05T20:46:00.000+03:00wow, what a neat web site.
One trick I use a lot ...wow, what a neat web site.<br /><br />One trick I use a lot is when I'm looking at a lengthy debug log over and over. Typically, there will be certain changes that will help me decipher what's going on: maybe I'm stripping off the timestamp because I don't care, or I'm highlighting a key variable. It all depends on the project.<br /><br />The <I>emacs</I> trick is that I wrap my edits into one routine, changing it as needed. Automagically, the debug logs are closer to what I need.<br /><br />Here's two examples: <br /><br />(defun fix-frames ()<br /> "Make assorted edits to output of FieldCell debug statements"<br /> (interactive)<br /><br /> (goto-char (point-min))<br /> (save-excursion (replace-regexp "x=20, y=1" "NORMAL_LHS_ORIGIN" nil nil nil))<br /> (save-excursion (replace-regexp "x=100, y=1" "NORMAL_RHS_ORIGIN" nil nil nil))<br /> (save-excursion (replace-regexp "w=100, h=18" "SINGLE_LINE" nil nil nil))<br /> (save-excursion (replace-regexp "icon.frame = {x=[0-9]+, y=[0-9]+; w=0, h=0}" "NO_ICON" nil nil nil))<br /> (save-excursion (replace-regexp "x=0, y=0; w=0, h=0}" "{ZERO_FRAME}" nil nil nil))<br /> )<br /><br /><br />(defun fix-order ()<br /> "Make assorted sorts to narrowed output of ItineraryViewController debug statements. <br /> if you aren't set up with the right narrowed, timestamped buffer, this command will arbitrarily scramble everything. <br /> <br /> NB: this command is idempotent. <br /> "<br /> (interactive)<br /><br /><br /> (mark-whole-buffer)<br /> (save-excursion (replace-regexp "^.*?[ ]" "sorting " nil nil nil))<br /> (shell-command-on-region (region-beginning) (region-end) "sort|uniq" (quote (4)) (quote (4)) nil t)<br /> (sort-fields 7 (region-beginning) (region-end))<br /> (sort-fields 6 (region-beginning) (region-end))<br /> )Travishttp://tripit.comnoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-5211623722940118962009-05-04T10:28:00.000+03:002009-05-04T10:28:00.000+03:00Prevent clumsy fingers from stopping a long sequen...Prevent clumsy fingers from stopping a long sequence of "undo" commands:<br /><br />(global-set-key "\C-x\C-u" 'advertised-undo)<br /><br />Disable other annoying keybindings:<br /><br />(global-unset-key "\C-x3")<br />(if window-system<br /> (progn<br /> (global-unset-key "\C-x\C-z")<br /> (global-unset-key "\C-z")))Bill Nighthttps://www.blogger.com/profile/09202318621724165312noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-29496746201921593062009-05-01T03:31:00.000+03:002009-05-01T03:31:00.000+03:00Some bits I haven't seen posted yet:
;; Make scri...Some bits I haven't seen posted yet:<br /><br />;; Make scripts executable on save<br />(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)<br /><br />;; disable C-z on X11 sessions<br />(when window-system<br /> (global-unset-key "\C-z")) <br /><br />;; Remember position in files between sessions<br />(when (require 'saveplace)<br /> (setq-default save-place t))<br /><br />;; copy/paste with accentuation intact<br />(setq selection-coding-system 'compound-text-with-extensions)<br /><br />(autoload 'longlines-mode<br /> "longlines.el"<br /> "Minor mode for automatically wrapping long lines." t)<br /><br />;; display current time in the modeline<br />(display-time)<br /><br />I guess everyone knows this, but just in case: type M-x eval-buffer after adding stuff to your init file to have emacs use your new settings (and yell at you if you botched something).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-13361473405101895312009-04-29T17:08:00.000+03:002009-04-29T17:08:00.000+03:00;; show-paren-mode
(setq show-paren-delay 0
...;; show-paren-mode<br />(setq show-paren-delay 0<br /> show-paren-style 'expression)<br />(show-paren-mode 1)<br />(set-face-background 'show-paren-match-face "#efedd2")<br /><br />;; Initial *scratch* message<br />(setq initial-scratch-message (purecopy "\<br />;; Lisp Interaction Buffer:<br /><br />")) <br /><br />;; Show calendar after start<br />(add-hook 'desktop-after-read-hook 'calendar)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-17045838970984936742009-04-29T03:15:00.000+03:002009-04-29T03:15:00.000+03:00Follow learnemacs on TwitterHere are a few things ...<A HREF="http://twitter.com/learnemacs" REL="nofollow">Follow learnemacs on Twitter</A>Here are a few things from my .emacs<br /><br /><br /><br /><br />;; display preferences<br />(global-font-lock-mode 1) <br />(show-paren-mode t)<br />(setq show-paren-style 'expression)<br />(tool-bar-mode -1)<br />(menu-bar-mode nil)<br />(scroll-bar-mode nil)<br />(setq inhibit-splash-screen t)<br />(transient-mark-mode t)<br />(setq-default truncate-lines t)<br />(and (fboundp 'blink-cursor-mode) (blink-cursor-mode (- (*) (*) (*))))<br />(column-number-mode 1)<br /><br />;; shortcuts <br />(defalias 'eb 'eval-buffer)<br />(defalias 'er 'eval-region)<br />(defalias 'ee 'eval-expression)<br />(defalias 'elm 'emacs-lisp-mode)<br />(defalias 'eis 'elisp-index-search)<br /><br />;; Inserts the date in the format <br />(defun insert-date ()<br /> "Insert date at point."<br /> (interactive)<br /> (insert (format-time-string "%d.%m.%Y %H:%M")))<br /><br /><br />;; open table of contents<br />(defun toc ()<br /> (interactive)<br /> (find-file "~/NOTES/TOC.org")<br />)<br /> <br />;; dotemacs<br />(defun dotemacs ()<br /> (interactive)<br /> (find-file "~/.emacs")<br />)<br /><br />(require 'twit)<br />(require 'nav)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-43919324159479813932009-04-29T01:48:00.000+03:002009-04-29T01:48:00.000+03:00To go with the original post's blink cursor mode, ...To go with the original post's blink cursor mode, I like <br /><br />(bar-cursor-mode t)<br /><br />as I think a vertical line between two characters is more in line (no pun intended) with what point means in Emacs.Erichttps://www.blogger.com/profile/03789079032968275865noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-23246421432076887102009-04-28T18:37:00.000+03:002009-04-28T18:37:00.000+03:00;; Striping ^M from files, Stolen from BradfordHol...;; Striping ^M from files, Stolen from <A HREF="http://www.dotemacs.de/dotfiles/BradfordHolcombe.emacs.html" REL="nofollow">BradfordHolcombe.emacs</A> (its tiny, yet handy): <br /><br />(fset 'dem [?\M-< ?\M-% ?\C-q ?\C-m return return ?! ?\M-<])<br /><br />;; <A HREF="http://www.emacswiki.org/emacs/ElDoc" REL="nofollow">eldoc</A> for quick reference<br />(require 'eldoc)<br />(autoload 'turn-on-eldoc-mode "eldoc" nil t)<br />(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)<br />(add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)<br /><br />;; Delete the selected region when something is typed or with DEL<br />(delete-selection-mode 1)<br /><br />;; <A HREF="http://www.emacswiki.org/emacs/BlankMode" REL="nofollow">blank-mode</A> visualization<br />(autoload 'blank-mode "blank-mode" "Toggle blank visualization." t)<br /><br />;; IBuffer management<br />(global-set-key "\C-x\C-b" 'ibuffer)<br /><br />;; Use system trash (for emacs 23)<br />(setq delete-by-moving-to-trash t)<br /><br />;; <A HREF="http://www.anc.ed.ac.uk/~stephen/emacs/fm.el" REL="nofollow">fm</A> package that highlights corresponding line in source buffer as one moves through the output (occur, compilation, ...) buffer.<br />(require 'fm)<br />(add-hook 'occur-mode-hook 'fm-start)<br />(add-hook 'compilation-mode-hook 'fm-start)<br />;; Once following is activated in a buffer, it can be toggled with the "f" key in that buffer.Ashutoshhttp://ashutoshmehra.net/blog/noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-80361574477953970242009-04-28T18:09:00.000+03:002009-04-28T18:09:00.000+03:00Remap capslock to execute-extended-command and the...Remap capslock to execute-extended-command and then defalias some infrequently used commands. Got the xmodmap trick from Sacha Chua :)<br /><br />(if (eq window-system 'x)<br /> (progn<br /> (shell-command "xmodmap -e 'clear Lock' -e 'keycode 66 = F13'")<br /> (global-set-key [f13] 'execute-extended-command))<br /> (when win32<br /> (setq w32-enable-caps-lock nil)<br /> (global-set-key [f13] 'execute-extended-command)))<br /><br />(defalias 'eb 'ediff-buffers)<br />(defalias 'ef 'ediff-files)erbo5212https://www.blogger.com/profile/01023664219225037118noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-91893514067265946972009-04-28T15:48:00.000+03:002009-04-28T15:48:00.000+03:00Here are a few obscure but handy settings (lots mo...Here are a few obscure but handy settings (<A HREF="http://github.com/purcell/emacs.d/tree/master" REL="nofollow">lots more here</A>):<br /><br />;; Show a marker in the left fringe for lines not in the buffer<br />(setq default-indicate-empty-lines t)<br /><br /><br />;; Undo/redo window layouts with "C-c <left>" and "C-c <right>"<br />(winner-mode 1)<br /><br />;; Show approx buffer size in modeline<br />(size-indication-mode)<br /><br />;; Make URLs in comments/strings clickable<br />;(add-hook 'find-file-hooks 'goto-address-prog-mode)Steve Purcellhttp://www.sanityinc.com/noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-50617101968786838062009-04-28T15:34:00.000+03:002009-04-28T15:34:00.000+03:00My small contribution
;; no yes-or-no
(defalias &...My small contribution<br /><br />;; no yes-or-no<br />(defalias 'yes-or-no-p 'y-or-n-p)<br /><br /><br />;; Use control-arrow keys for window resizing<br />(global-set-key (kbd "<C-right>") 'enlarge-window-horizontally)<br />(global-set-key (kbd "<C-left>") 'shrink-window-horizontally)<br /><br />;;; Drive out the mouse when it's too near to the cursor.<br />(mouse-avoidance-mode 'animate):Rajahttps://www.blogger.com/profile/17138871434315349022noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-66902842853761702972009-04-28T15:31:00.000+03:002009-04-28T15:31:00.000+03:00This comment has been removed by the author.Rajahttps://www.blogger.com/profile/17138871434315349022noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-10329709517208807922009-04-28T13:06:00.000+03:002009-04-28T13:06:00.000+03:00@Steve Purcell: you rocks!
This post is gonna be ...@Steve Purcell: you rocks!<br /><br />This post is gonna be an Emacs Tricks Bible :-pp4bl0http://pablo.rauzy.name/noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-13762285186683535262009-04-28T12:07:00.000+03:002009-04-28T12:07:00.000+03:00@p4bl0 - just rename your ~/.emacs.d/dotemacs.el t...@p4bl0 - just rename your ~/.emacs.d/dotemacs.el to ~/.emacs.d/init.el, then you won't need your ~/.emacs any more.Steve Purcellhttp://www.sanityinc.com/noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-74885430206323797972009-04-28T11:52:00.000+03:002009-04-28T11:52:00.000+03:00I just read today about uniquify, and it's rea...I just read today about uniquify, and it's really great : see http://curiousprogrammer.wordpress.com/2009/04/28/emacs-hacks/<br /><br />It allows to have for instance "Makefile|proj" and "Makefile|otherProj" as buffer name instead of "Makefile" and "Makefile<2>", and it is activated only if there are multiple files with the same name!<br /><br />;; uniquify!<br />(require 'uniquify)<br />(setq uniquify-buffer-name-style 'reverse)<br />(setq uniquify-separator "|")<br />(setq uniquify-after-kill-buffer-p t)<br />(setq uniquify-ignore-buffers-re "^\\*")p4bl0http://pablo.rauzy.name/noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-28640619068703027412009-04-28T10:03:00.000+03:002009-04-28T10:03:00.000+03:00;; Don't start the server unless we can verify tha...;; Don't start the server unless we can verify that it isn't running.<br />(require 'server)<br />(when (and (functionp 'server-running-p) (not (server-running-p)))<br /> (server-start))<br /><br />;; Minibuffer bindings<br />(define-key minibuffer-local-map "\C-c\C-u" 'backward-kill-sentence)<br /><br />;; Make M-z stop minimizing frames<br />(defun iconify-or-deiconify-frame nil)<br /><br />;; Always add a final newline<br />(setq require-trailing-newline t)<br /><br />;; Menu bars are free on OS X – the space is used whether they're<br />;; enabled or not – but a waste anywhere else.<br />(menu-bar-mode (if (eq 'ns window-system) 1 -1))Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-74908669037102532392009-04-28T10:01:00.000+03:002009-04-28T10:01:00.000+03:00Here are some of my favorites:
;; Easy buffer swi...Here are some of my favorites:<br /><br />;; Easy buffer switching by holding down shift and press any arrow key.<br />(windmove-default-keybindings 'shift)<br /><br />;; Show unfinished keystrokes early.<br />(setq echo-keystrokes 0.1)<br /><br />(defun nuke-all-buffers ()<br /> "Kill all buffers, leaving *scratch* only."<br /> (interactive)<br /> (mapcar (lambda (x) (kill-buffer x)) (buffer-list)) (delete-other-windows))rejeephttps://www.blogger.com/profile/17082054872459712455noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-63360176117415839422009-04-28T09:49:00.000+03:002009-04-28T09:49:00.000+03:00My 2 cents:
;; mark current line:
(global-hl-line...My 2 cents:<br /><br />;; mark current line:<br />(global-hl-line-mode 1)<br />;; color for current line:<br />(set-face-background 'hl-line "#e0f8ff")Dmitryhttps://www.blogger.com/profile/06537387509952609756noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-31262379463661517752009-04-28T08:30:00.000+03:002009-04-28T08:30:00.000+03:00Yeah, in my dotemacs I have (savehist-mode t), I f...Yeah, in my dotemacs I have (savehist-mode t), I forgot to type t ;) (I didn't use drag&drop :P)Anonymoushttps://www.blogger.com/profile/03334809676508902320noreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-16316232003869983202009-04-28T04:58:00.000+03:002009-04-28T04:58:00.000+03:00valvo,
It may be safer to use
(savehist-mode 1)...valvo, <br /><br />It may be safer to use<br /><br />(savehist-mode 1)xwlhttp://xwl.appspot.comnoreply@blogger.comtag:blogger.com,1999:blog-3992530807750384868.post-45201414459178753222009-04-28T02:04:00.000+03:002009-04-28T02:04:00.000+03:00A few of my favs:
;; clean out buffers except she...A few of my favs:<br /><br />;; clean out buffers except shell, agenda and org<br />(defun restart ()<br /> (interactive)<br /> (let ((list (buffer-list)))<br /> (while list<br /> (let* ((buffer (car list))<br /> (name (buffer-name buffer)))<br /> (and (not (string-equal name "*shell*"))<br /> (not (string-equal name "*Org Agenda*"))<br /> (not (string-equal name "greg.org"))<br /> (kill-buffer buffer)))<br /> (setq list (cdr list)))))<br /><br />;; allow shift + arrow for selections<br />(pc-selection-mode)<br /><br />;; bury the buffer<br />(global-set-key [f8] 'bury-buffer)<br /><br />;; titlebar = buffer unless filename<br />(setq frame-title-format '(buffer-file-name "%f" ("%b")))<br /><br />;; no splash screen<br />(setq inhibit-startup-message t)<br /><br />my configs are at http://github.com/gregnewman/20seven-emacs and constantly evolvingAnonymousnoreply@blogger.com