One liner to load m3u into mpd
mpc clear;ln -s ~/Music/all.m3u ~/.mpd/playlists/all.m3u;mpc load all;mpc update;mpc shuffle;mpc play;
Toggle full view of window in Emacs
Add below code into your ~/.emacs:
(defun toggle-full-window() "Toggle the full view of selected window" (interactive) ;; @see http://www.gnu.org/software/emacs/manual/html_node/elisp/Splitting-Windows.html (if (window-parent) (delete-other-windows) (winner-undo) ))
I use evil, so I assign hot key ",ff" to `toggle-full-window`.
The minimum packages to install for front end development on Linux
sudo apt-get install ack git emacs24-nox feh i3 xsel ctags vim scrot xbindkeys dunst unclutter parcellite gimp
Use Gnus to apply patch sent by `git send-email`
Setup git-send-email
On Debian run sudo apt-get install git-email
to install git command line tools.
Then run cpan Authen::SASL MIME::Base64 Net::SMTP::SSL
to install perl packages (check cpan howto).
Modify ~/.gitconfig
to use Gmail SMTP:
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
smtpuser = username@gmail.com
smtpserverport = 587
Send the latest commit
# send one commit
git send-email -1 --annotate
Apply patch
Select one mail. Run command "M-x gnus-summary-save-article-email" whose short key is "O m" in summary buffer.
Emacs will ask for directory to save that patch. Say I save it as ~/News/patch/hello.patch
.
git am ~/News/patch/hello.patch
Syntax highlight patch embedded in mail (OPTIONAL)
Use gnus-article-treat-patch.el.
Add below code to setup:
(require 'gnus-article-treat-patch)
(setq gnus-article-patch-conditions
'( "^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@" ))
香菇生滚牛肉窝蛋粥做法
- 菜谱
- 香菇先用冷水冲洗,然后25度温水浸泡至少1小时,浸泡后的水也要放到粥里
- 小火1到1.5小时后粥基本烂了,不断搅拌粥
- 牛肉最后开大火加入过一下,可能是为了避免把牛肉烧老
- 蛋是用粥捂熟的,据说很经典的技巧,就是要蛋白和粥混在一起,但是蛋黄半熟还是完整的
- 如果粥觉得不够味可以加盐和鲜露(家乐牌鲜露)
Use org2blog to share blog efficiently
org2blog will post items in org-mode
into wordpress blog.
It's the best blog writer in the world.
My only issue that I need share the blog url to social network sites after publishing.
Here is my solution to automatically copy post url into clipboard after publishing:
(defun my-org2blog-post-subtree ()
(interactive)
;; go to the top node which is a blog item
;;(outline-up-heading)
;; post and publish
(org2blog/wp-post-subtree t)
(let* ((postid (or (org-entry-get (point) "POSTID")
(org-entry-get (point) "POST_ID")))
(url org2blog/wp-server-xmlrpc-url))
(if (not postid)
(message "This subtree hasn't been posted, yet.")
(setq url (substring url 0 -10))
(setq url (concat url "?p=" postid ))
(kill-new url)
(with-temp-buffer
(insert url)
(shell-command-on-region (point-min) (point-max)
(cond
((eq system-type 'cygwin) "putclip")
((eq system-type 'darwin) "pbcopy")
(t "xsel -ib"))))
(message (concat url " => clipboard")))))
BTW, please use some clipboard manager to synchronize the X clipboards.
Install gitso v0.6 on Gentoo Linux
Gitso is a frontend to reverse VNC connections. Say you want to access your office pc which is behind firewall. Then you need Gitso.
Here is the commands to install gitso:
sudo mkdir /usr/portage/net-misc/gitso sudo bash -c "curl -L https://github.com/longlene/clx/raw/master/net-misc/gitso/gitso-0.6.ebuild > /usr/portage/net-misc/gitso/gitso-0.6.ebuild" sudo bash -c "curl -L https://github.com/longlene/clx/raw/master/net-misc/gitso/Manifest|sed -e '/gitso[-_]0.5/d' > /usr/portage/net-misc/gitso/Manifest" sudo emerge wxpython iproute2 x11vnc tightvnc sudo ebuild /usr/portage/net-misc/gitso/gitso-0.6.ebuild unpack compile install qmerge clean
There are many howtos on gitso on internet. Google it.
韩国大酱汤做法
- 买酱,见下图
- 倒入白菜,菇,韩国豆芽等等,加冷水,煮开
- 倒入酱,加糖盐调味
How to use expand-region.el in Emacs efficiently
expand-region.el is very useful. I use it to select a code segment and keep press its expand key until the the desired region is selected.
The only issue is its recommended hotkey for "er/expand-region" is "C-=". A little bit hard to press.
After marking a region by pressing "C-", I press "
" to expand the region and "-" to contract.
As you may have noticed, I need move the right hand to press "=" or "-" so it's not quick enough.
The solution is simple, press ",xx" to select the initial region. Keep press "x" to expand. "z" to contract region because "x" "z" is close to left hand fingers.
evil-mode and evil-leader is required to implement this.
Here is the setup:
(require 'evil)
(require 'evil-leader)
(evil-mode 1) ;; enable evil-mode
(with-eval-after-load 'evil
(setq expand-region-contract-fast-key "z"))
(evil-leader/set-key "xx" 'er/expand-region)
Navigate/Select html tags in Emacs
UPDATED:
Navigate/select html tags is kind of difficult. I've not found any plugin which could match Vim's matchit.
The most close one in Emacs is smartparens. You can check this discussion on Google Plus to get general impression.
I use sp-select-next-thing
from smarparens
to select html tags. But I'm not satisfied with this command because it's picky on the location of my cursor and selection of multiple html tags is buggy.
So here is my fix, the new command my-sp-select-next-thing
which fix all these issues.
Screen cast:
Here is the code to insert it into your ~/.emacs
:
;; make sp-select-next-thing works even the cusor is in the open/close tag
;; like matchit in vim
;; @return t => start from open tag; nil start from close tag
(defun my-sp-select-next-thing (&optional NUM)
(interactive "p")
(let* ((b (line-beginning-position))
(e (line-end-position))
(char (following-char))
(p (point))
rbeg
rend
(rlt t))
;; "<" char code is 60
;; search backward
(if (not (= char 60))
(save-excursion
(while (and (<= b (point)) (not (= char 60)))
(setq char (following-char))
(setq p (point))
(backward-char))))
;; search forward
(if (not (= char 60))
(save-excursion
(while (and (>= e (point)) (not (= char 60)))
(setq char (following-char))
(setq p (point))
(forward-char))))
;; do the real thing
(when (and (= char 60) (< p e))
(goto-char p)
(forward-char)
(if (= (following-char) 47)
(progn
;; </
(backward-char)
(setq rlt nil))
(progn
;; < , looks fine
(backward-char)
(setq rlt t)))
(sp-select-next-thing)
(setq rbeg (region-beginning))
(setq rend (region-end))
(while (> NUM 1)
;; well, sp-select-next-thing is kind of wierd
(re-search-forward "<[^!]")
(backward-char 2)
(sp-select-next-thing)
(setq rend (region-end))
(setq NUM (1- NUM)))
(push-mark rbeg t t)
(goto-char (1-rend)))
rlt))
Navigation is easy. After selecting the tags, press C-x C-x
to move the focus. That's it.
For evil-mode, I write some code which simulate the famous matchit in vi:
(require 'evil)
;; {{ evil-matchit
(defun my-evil-jump-item-enhanced-for-html ()
(interactive)
(if (or (eq major-mode 'html-mode)
(eq major-mode 'xml-mode)
(eq major-mode 'nxml-mode))
(progn
(if (not (my-sp-select-next-thing 1)) (exchange-point-and-mark))
(deactivate-mark))
(progn
(evil-jump-item))))
(define-key evil-normal-state-map "%" 'my-evil-jump-item-enhanced-for-html)
;; }}
Now you can press %
in evil to jump between tags!
Requirement:
- smartparens-1.5
- evil-1.0.7
- emacs-24.2.1
BTW, I also tried the web-mode-tag-match in web-mode which provided similar tag match feature.
At least now (2nd October,2013) web-mode does not support freemarker syntax. But smartparens is more tolerant to these template syntax.
UPDATE (6th Nov, 2013): I started a new project evil-matchit which is not dependent on smartparens. Please check it out. But you can still use my old code because it support more languages.
UPDATED (13rd Jan, 2014): evil-matchit is now powerful enough to replace my old tricks.