<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;D0MNRH8zfSp7ImA9WhBbGEo.&quot;"><id>tag:blogger.com,1999:blog-33528550</id><updated>2013-05-18T04:11:35.185-07:00</updated><category term="linux" /><category term="math" /><category term="arts" /><category term="emacs" /><category term="Xah Lee" /><category term="linguistics" /><category term="american" /><category term="politics" /><category term="functional programing" /><category term="keyboarding" /><category term="music" /><category term="lisp" /><category term="gaming" /><category term="misc" /><category term="pop" /><category term="literature" /><category term="seo" /><category term="sex" /><category term="second life" /><category term="software" /><category term="society" /><category term="web dev" /><category term="mac" /><category term="internet" /><category term="religion" /><category term="windows" /><category term="tech geekers" /><category term="programing" /><category term="china" /><category term="xahlee.org" /><category term="juggling" /><category term="computer languages" /><category term="computing" /><category term="humor" /><title>Xah at Blogger</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://xahlee.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>1670</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/XahLeeAtBlogger" /><feedburner:info uri="xahleeatblogger" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>XahLeeAtBlogger</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;D0YHQX89fyp7ImA9WhBbGE4.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-7654087058554340674</id><published>2013-05-17T14:24:00.001-07:00</published><updated>2013-05-17T16:58:50.167-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-17T16:58:50.167-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="lisp" /><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>emacs: open file path under cursor fast</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://ergoemacs.org/emacs/emacs_open_file_path_fast.html"&gt;http://ergoemacs.org/emacs/emacs_open_file_path_fast.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Emacs has a command &lt;code class="elisp-ƒ"&gt;ffap&lt;/code&gt;. When your cursor is on a file path or URL, it'll open the file. This is extremely useful in shell ouputs or in HTML file.&lt;/p&gt;

&lt;p&gt;One problem is that it'll prompt to confirm. This is annoying. Also, the command itself doesn't have a key.&lt;/p&gt;

&lt;p&gt;You can write a similar command that doesn't need confirmation. Here's the code.&lt;/p&gt;

&lt;pre class="emacs-lisp"&gt;(&lt;span class="keyword"&gt;defun&lt;/span&gt; open-file-at-cursor ()
  &lt;span class="string"&gt;"Open the file path under cursor.
If there is text selection, uses the text selection for path.
If the path is starts with “http://”, open the URL in browser.
Input path can be {relative, full path, URL}.
This command is similar to `find-file-at-point' but without prompting for confirmation.
"&lt;/span&gt;
  (&lt;span class="function-name"&gt;interactive&lt;/span&gt;)
  (&lt;span class="keyword"&gt;let&lt;/span&gt; ( (path (&lt;span class="function-name"&gt;thing-at-point&lt;/span&gt; 'filename)))
    (&lt;span class="keyword"&gt;if&lt;/span&gt; (&lt;span class="keyword"&gt;string-match-p&lt;/span&gt; &lt;span class="string"&gt;"\\`https*://"&lt;/span&gt; path)
        (&lt;span class="keyword"&gt;progn&lt;/span&gt; (browse-url path))
      (&lt;span class="keyword"&gt;progn&lt;/span&gt; &lt;span class="comment-delimiter"&gt;; &lt;/span&gt;&lt;span class="comment"&gt;not starting “http://”
&lt;/span&gt;        (&lt;span class="keyword"&gt;if&lt;/span&gt; (&lt;span class="function-name"&gt;file-exists-p&lt;/span&gt; path)
              (&lt;span class="keyword"&gt;progn&lt;/span&gt; (&lt;span class="function-name"&gt;find-file&lt;/span&gt; path))
            (&lt;span class="keyword"&gt;if&lt;/span&gt; (&lt;span class="function-name"&gt;file-exists-p&lt;/span&gt; (&lt;span class="keyword"&gt;concat&lt;/span&gt; path &lt;span class="string"&gt;".el"&lt;/span&gt;))
                (&lt;span class="keyword"&gt;progn&lt;/span&gt; (&lt;span class="function-name"&gt;find-file&lt;/span&gt; (&lt;span class="keyword"&gt;concat&lt;/span&gt; path &lt;span class="string"&gt;".el"&lt;/span&gt;)))
              (&lt;span class="keyword"&gt;progn&lt;/span&gt;
                (&lt;span class="keyword"&gt;when&lt;/span&gt; (&lt;span class="function-name"&gt;y-or-n-p&lt;/span&gt; (&lt;span class="keyword"&gt;format&lt;/span&gt; &lt;span class="string"&gt;"file doesn't exist: 「%s」. Create?"&lt;/span&gt; path) )
                  (&lt;span class="keyword"&gt;progn&lt;/span&gt; (&lt;span class="function-name"&gt;find-file&lt;/span&gt; path ))) ) ) ) ) ) ))&lt;/pre&gt;

&lt;p&gt;Be sure to give it a easy key. 〔☛ &lt;a href="http://ergoemacs.org/emacs/keyboard_shortcuts.html"&gt;Emacs: How to Define Keys&lt;/a&gt;〕&lt;/p&gt;

&lt;div class="rltd"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_hotkey_open_file_fast.html"&gt;Emacs Lisp: Hotkeys to Open File Fast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_useful_user_keybinding.html"&gt;Emacs: Add Custom Keys to Enhance Productivity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_make_modern.html"&gt;How to Set Emacs's User Interface to Modern Conventions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_alias.html"&gt;Emacs: Defining Alias to Increase Productivity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_macro_example.html"&gt;Emacs Keyboard Macro Examples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/Ps3jCfM8SYM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/7654087058554340674/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/emacs-open-file-path-under-cursor-fast.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/7654087058554340674?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/7654087058554340674?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/Ps3jCfM8SYM/emacs-open-file-path-under-cursor-fast.html" title="emacs: open file path under cursor fast" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/emacs-open-file-path-under-cursor-fast.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUAFRH4-cSp7ImA9WhBbGEs.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-1858767637521494400</id><published>2013-05-17T13:10:00.002-07:00</published><updated>2013-05-18T02:01:55.059-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-18T02:01:55.059-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programing" /><title>set git output non-interactive, set git date iso format</title><content type="html">
&lt;p class="q"&gt;How to set git output non-interactive?&lt;/p&gt;
&lt;div class="a"&gt;
&lt;p&gt;there's no way. Just send it to a file then view that file.&lt;/p&gt;
&lt;pre class="bash"&gt;git log &amp;gt; 888888&lt;/pre&gt;

&lt;p&gt;If you are using emacs, you can place cursor on the file path then call &lt;code class="elisp-ƒ"&gt;ffap&lt;/code&gt; (see: &lt;a href="http://ergoemacs.org/emacs/emacs_open_file_path_fast.html"&gt;Emacs: Open File Path Under Cursor Fast&lt;/a&gt;), or install “magit” package for git. It's in MELPA repository. See
&lt;a href="http://ergoemacs.org/emacs/emacs_package_system.html"&gt;A Guide on Emacs 24 Package System&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

&lt;p class="q"&gt;How to make git display date in ISO format?&lt;/p&gt;
&lt;div class="a"&gt;
&lt;p&gt;Use &lt;code&gt;--date=iso&lt;/code&gt;.&lt;/p&gt;
&lt;pre class="bash"&gt;git log --date=iso &amp;gt; z&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;See also: &lt;a href="../linux/git.html"&gt;git Tutorial&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/1XCJt6rFUHM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/1858767637521494400/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/set-git-output-non-interactive-set-git.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1858767637521494400?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1858767637521494400?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/1XCJt6rFUHM/set-git-output-non-interactive-set-git.html" title="set git output non-interactive, set git date iso format" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/set-git-output-non-interactive-set-git.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcCSHc6eCp7ImA9WhBbGE0.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-5216756246992755454</id><published>2013-05-17T06:36:00.002-07:00</published><updated>2013-05-17T08:21:09.910-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-17T08:21:09.910-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="web dev" /><title>Google Plus new interface: Claustrophob Box</title><content type="html">&lt;figure&gt;
&lt;img src="http://xahlee.info/comp/i/ui/Google_Plus_UI_tiny_comment_box_2013-05-17.png" alt="Google Plus UI tiny comment box 2013-05-17" width="1059" height="967" /&gt;
&lt;figcaption&gt;&lt;time&gt;2013-05-17&lt;/time&gt; new Google Plus interface, featuring the claustrophob box.
〔☛ &lt;a href="http://xahlee.info/comp/ui_design_peepshow_window.html"&gt;User Interface Design: Peepshow Windows&lt;/a&gt;〕
&lt;/figcaption&gt;
&lt;/figure&gt;&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/WSAqzVqFBts" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/5216756246992755454/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/google-plus-new-interface-claustrophob.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/5216756246992755454?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/5216756246992755454?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/WSAqzVqFBts/google-plus-new-interface-claustrophob.html" title="Google Plus new interface: Claustrophob Box" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/google-plus-new-interface-claustrophob.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYER3c4cCp7ImA9WhBbFk0.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-5386936827106981295</id><published>2013-05-15T00:12:00.001-07:00</published><updated>2013-05-15T01:38:26.938-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-15T01:38:26.938-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="keyboarding" /><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>video review of the Truly Ergonomic keyboard</title><content type="html">

&lt;figure&gt;
&lt;iframe title="YouTube video player" class="youtube-player" width="640" height="385" src="http://www.youtube.com/embed/tkjm1xSF4g0?rel=0"&gt;&lt;/iframe&gt;
&lt;figcaption&gt;video review of the Truly Ergonomic keyboard.
More info at &lt;a href="http://xahlee.info/kbd/Truly_Ergonomic_keyboard.html"&gt;Truly Ergonomic Computer Keyboard Review&lt;/a&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Note: for those of you who know me, i got the keyboards free, but my opinion isn't bought, judge for yourself.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/t8b6IlRniqs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/5386936827106981295/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/video-review-of-truly-ergonomic-keyboard.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/5386936827106981295?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/5386936827106981295?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/t8b6IlRniqs/video-review-of-truly-ergonomic-keyboard.html" title="video review of the Truly Ergonomic keyboard" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/tkjm1xSF4g0/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/video-review-of-truly-ergonomic-keyboard.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUQFRX08fip7ImA9WhBbFUQ.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-82524931725107341</id><published>2013-05-14T22:55:00.002-07:00</published><updated>2013-05-14T22:55:14.376-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-14T22:55:14.376-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="lisp" /><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>emacs: open your own files FAST</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://ergoemacs.org/emacs/emacs_hotkey_open_file_fast.html"&gt;http://ergoemacs.org/emacs/emacs_hotkey_open_file_fast.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's command that lets you open file fast, by typing a letter or digit:&lt;/p&gt;

&lt;pre class="emacs-lisp"&gt;(&lt;span class="function-name"&gt;defvar&lt;/span&gt; xah-filelist &lt;span class="keyword"&gt;nil&lt;/span&gt; &lt;span class="string"&gt;"alist for files i need to open frequently. Key is a short abbrev, Value is file path."&lt;/span&gt;)
(&lt;span class="keyword"&gt;setq&lt;/span&gt; xah-filelist
      '(
        (&lt;span class="string"&gt;"3emacs"&lt;/span&gt; . &lt;span class="string"&gt;"~/web/ergoemacs_org/emacs/blog.html"&lt;/span&gt; )
        (&lt;span class="string"&gt;"4code"&lt;/span&gt; . &lt;span class="string"&gt;"~/web/xahlee_info/comp/blog.html"&lt;/span&gt; )
        (&lt;span class="string"&gt;"js"&lt;/span&gt; . &lt;span class="string"&gt;"~/web/xahlee_info/js/blog.html"&lt;/span&gt; )
        (&lt;span class="string"&gt;"math"&lt;/span&gt; . &lt;span class="string"&gt;"~/web/xahlee_info/math/blog.html"&lt;/span&gt; )
        (&lt;span class="string"&gt;"linguistics"&lt;/span&gt; . &lt;span class="string"&gt;"~/web/wordyenglish_com/lit/blog.html"&lt;/span&gt; )
        (&lt;span class="string"&gt;"chinese"&lt;/span&gt; . &lt;span class="string"&gt;"~/web/wordyenglish_com/chinese/blog.html"&lt;/span&gt; )
        (&lt;span class="string"&gt;"music"&lt;/span&gt; . &lt;span class="string"&gt;"~/web/xahmusic_org/music/blog.html"&lt;/span&gt; )
        (&lt;span class="string"&gt;"arts"&lt;/span&gt; . &lt;span class="string"&gt;"~/web/xaharts_org/arts/blog.html"&lt;/span&gt; )
        (&lt;span class="string"&gt;"sl"&lt;/span&gt; . &lt;span class="string"&gt;"~/web/xahsl_org/sl/blog.html"&lt;/span&gt; )
        (&lt;span class="string"&gt;"keys"&lt;/span&gt; . &lt;span class="string"&gt;"~/git/xah_emacs_init/xah_emacs_keybinding.el"&lt;/span&gt; )
        (&lt;span class="string"&gt;"ahk"&lt;/span&gt; . &lt;span class="string"&gt;"~/git/xah_autohotkey_scripts/xah autohotkeys.ahk"&lt;/span&gt; )
        (&lt;span class="string"&gt;"download"&lt;/span&gt; . &lt;span class="string"&gt;"~/Downloads/"&lt;/span&gt; )
        ) )

(&lt;span class="keyword"&gt;defun&lt;/span&gt; xah-open-file-fast (openCode)
  &lt;span class="string"&gt;"Prompt to open a file from a pre-defined set."&lt;/span&gt;
  (&lt;span class="function-name"&gt;interactive&lt;/span&gt;
   (&lt;span class="keyword"&gt;list&lt;/span&gt; (ido-completing-read &lt;span class="string"&gt;"Open:"&lt;/span&gt; (&lt;span class="keyword"&gt;mapcar&lt;/span&gt; (&lt;span class="keyword"&gt;lambda&lt;/span&gt; (x) (&lt;span class="keyword"&gt;car&lt;/span&gt; x)) xah-filelist)))
   )
  (&lt;span class="function-name"&gt;find-file&lt;/span&gt; (&lt;span class="keyword"&gt;cdr&lt;/span&gt; (&lt;span class="keyword"&gt;assoc&lt;/span&gt; openCode xah-filelist)) ) )&lt;/pre&gt;

&lt;p&gt;When called, it will prompt in the same way as &lt;code class="elisp-ƒ"&gt;ido-mode&lt;/code&gt;, with automatic name completion.&lt;/p&gt;

&lt;p&gt;You type a key, then press &lt;kbd&gt;Enter ↵&lt;/kbd&gt;, then the file will be opened.&lt;/p&gt;

&lt;p&gt;You need to modify the file path for your own use. You can also easily modify the code above so that one letter opens several files at once, such as a coding project.&lt;/p&gt;

&lt;p&gt;Note: You should also use the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_buffer_management.html"&gt;ibuffer ＆ ido-switch-buffer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_recentf.html"&gt;recentf-mode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/bookmark.html"&gt;bookmark&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All the above requires eyeball. That is, spending half a second to look at the screen and make a choice.&lt;/p&gt;

&lt;p&gt;The purpose of “xah-open-file-fast” is that you never need to look at the screen, just muscle memory, but you may want to be sure that the first chars of your file name abbrevs are all unique.&lt;/p&gt;

&lt;div class="rltd"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_useful_user_keybinding.html"&gt;Emacs: Add Custom Keys to Enhance Productivity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_make_modern.html"&gt;How to Set Emacs's User Interface to Modern Conventions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_alias.html"&gt;Emacs: Defining Alias to Increase Productivity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_macro_example.html"&gt;Emacs Keyboard Macro Examples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/vW-0a1TWgjI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/82524931725107341/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/emacs-open-your-own-files-fast.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/82524931725107341?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/82524931725107341?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/vW-0a1TWgjI/emacs-open-your-own-files-fast.html" title="emacs: open your own files FAST" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/emacs-open-your-own-files-fast.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIGRn4_eip7ImA9WhBbFUQ.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-888484251583992320</id><published>2013-05-14T22:08:00.002-07:00</published><updated>2013-05-14T22:08:47.042-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-14T22:08:47.042-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="lisp" /><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>emacs lisp: use ido completion for your own commands</title><content type="html">

&lt;p&gt;emacs lisp: you can use &lt;code class="elisp-ƒ"&gt;ido-completing-read&lt;/code&gt; for your own cmds. 
It's bundled with emacs 24, at least. Example use:&lt;/p&gt;

&lt;pre class="elisp"&gt;(ido-completing-read &lt;span class="string"&gt;"your prompt str:"&lt;/span&gt; ‹youList› )&lt;/pre&gt;

&lt;p&gt;Full example: &lt;a href="http://ergoemacs.org/emacs/elisp_change_brackets.html"&gt;Emacs: Change Brackets () {} [] in Text&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/3b_kcAzbg-w" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/888484251583992320/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/emacs-lisp-use-ido-completion-for-your.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/888484251583992320?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/888484251583992320?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/3b_kcAzbg-w/emacs-lisp-use-ido-completion-for-your.html" title="emacs lisp: use ido completion for your own commands" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/emacs-lisp-use-ido-completion-for-your.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEECRXw8fyp7ImA9WhBbFUg.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-5604144641119925954</id><published>2013-05-14T11:31:00.003-07:00</published><updated>2013-05-14T11:37:44.277-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-14T11:37:44.277-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>Emacs: how i write blogs</title><content type="html">

&lt;p&gt;A video recording on how i write blogs.&lt;/p&gt;

&lt;figure&gt;
&lt;iframe title="YouTube video player" class="youtube-player" width="640" height="385" src="http://www.youtube.com/embed/1L0ru5bXGjw?rel=0"&gt;&lt;/iframe&gt;
&lt;figcaption&gt;emacs: how i write blogs.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The commands used are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code class="elisp-ƒ"&gt;xah-open-file-fast&lt;/code&gt; 〔☛ &lt;a href="http://ergoemacs.org/emacs/emacs_hotkey_open_file_fast.html"&gt;Emacs Lisp: Hotkeys to Open File Fast&lt;/a&gt;〕&lt;/li&gt;
&lt;li&gt;&lt;code class="elisp-ƒ"&gt;insert-date-tag&lt;/code&gt; 〔☛ &lt;a href="http://ergoemacs.org/emacs/elisp_insert-date-time.html"&gt;Emacs Lisp: Insert Date Time Stamp&lt;/a&gt;〕&lt;/li&gt;
&lt;li&gt;&lt;code class="elisp-ƒ"&gt;xhm-wrap-html-tag&lt;/code&gt; (from &lt;a href="http://ergoemacs.org/emacs/xah-html-mode.html"&gt;Emacs: Xah HTML Mode&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code class="elisp-ƒ"&gt;xhm-pre-source-code&lt;/code&gt; syntax coloring of source code in HTML.&lt;/li&gt;
&lt;li&gt;&lt;code class="elisp-ƒ"&gt;xah-browse-url-of-buffer&lt;/code&gt; 〔☛ &lt;a href="http://ergoemacs.org/emacs/elisp_browse_url.html"&gt;Emacs Lisp: browse-url Function to View URL in a Web Browser&lt;/a&gt;〕&lt;/li&gt;
&lt;li&gt;&lt;code class="elisp-ƒ"&gt;xah-make-atom-entry&lt;/code&gt; 〔☛ &lt;a href="http://ergoemacs.org/emacs/elisp_update_atom.html"&gt;Emacs Lisp: Updating Atom Webfeed&lt;/a&gt;〕&lt;/li&gt;
&lt;li&gt;&lt;code class="elisp-ƒ"&gt;dired-jump&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class="elisp-ƒ"&gt;xah-shell-commands&lt;/code&gt;.  See: 〈Emacs, Shell, Abbrev, and ELISP Power to Bear!〉 &lt;a class="sorc" href="http://www.youtube.com/watch?v=oKS_iIoQ0A4" data-accessed="2013-05-14"&gt;http://www.youtube.com/watch?v=oKS_iIoQ0A4&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The video presentation is pretty bad. I have much to learn, tech and presentation. I was using Google Plus's hangout feature with Hangout On Air to record directly to YouTube. Not sure what's a good solution on Linux yet.&lt;/p&gt;

&lt;p&gt;also, i need to write code so that whatever command i called is displayed in a pane. So viewers can see it without me going over.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/2dlkZ_W76o8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/5604144641119925954/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/emacs-how-i-write-blogs.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/5604144641119925954?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/5604144641119925954?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/2dlkZ_W76o8/emacs-how-i-write-blogs.html" title="Emacs: how i write blogs" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/1L0ru5bXGjw/default.jpg" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/emacs-how-i-write-blogs.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4FQ3szfCp7ImA9WhBbFUw.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-6608919348585467909</id><published>2013-05-14T00:51:00.003-07:00</published><updated>2013-05-14T00:51:52.584-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-14T00:51:52.584-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programing" /><category scheme="http://www.blogger.com/atom/ns#" term="computer languages" /><title>Programing Craft: Intention vs Coolness</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://xahlee.info/comp/programing_craft_intention_vs_coolness.html"&gt;http://xahlee.info/comp/programing_craft_intention_vs_coolness.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you see a hash table, do you think “Ah, it's a flow control”?&lt;/p&gt;

&lt;p&gt;in programing, we often do coolness.&lt;/p&gt;

&lt;p&gt;Python doesn't have {switch, case, cond} construct. Someone asked about it on &lt;a class="sorc" href="http://stackoverflow.com/questions/60208/replacements-for-switch-statement-in-python" data-accessed="2013-05-13"&gt;stackoverflow&lt;/a&gt;, and this is the most upvoted answer:&lt;/p&gt;

&lt;pre class="python3"&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;python 3
&lt;/span&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;emulating “switch” statement in Python.
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;works in both python 2 and 3
&lt;/span&gt;
&lt;span class="keyword"&gt;def&lt;/span&gt; &lt;span class="function-name"&gt;f&lt;/span&gt;(x):
    &lt;span class="keyword"&gt;return&lt;/span&gt; {
        &lt;span class="string"&gt;"a"&lt;/span&gt;: 1,
        &lt;span class="string"&gt;"b"&lt;/span&gt;: 2,
        }.get(x, 9)    &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;9 is default if x not found
&lt;/span&gt;

&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;test
&lt;/span&gt;&lt;span class="variable-name"&gt;y&lt;/span&gt; = &lt;span class="string"&gt;"d"&lt;/span&gt;
&lt;span class="keyword"&gt;print&lt;/span&gt;(f(y)) &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;9&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;you use a hash table (aka dictionary) to emulate switch statement.&lt;/p&gt;

&lt;p&gt;It is cool, but there is a problem: the intention of the programer isn't explicit. Instead, you have to engage your brain to figure out things.&lt;/p&gt;

&lt;p&gt;here's a simpler, more verbose, version, but the programer intention is clear, and much easier to understand.&lt;/p&gt;

&lt;pre class="python3"&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;python 3
&lt;/span&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;chained if, similar to “switch” conditional
&lt;/span&gt;
&lt;span class="keyword"&gt;def&lt;/span&gt; &lt;span class="function-name"&gt;f&lt;/span&gt;(x):
    &lt;span class="keyword"&gt;if&lt;/span&gt; x == &lt;span class="string"&gt;"a"&lt;/span&gt;: &lt;span class="keyword"&gt;return&lt;/span&gt; 1
    &lt;span class="keyword"&gt;if&lt;/span&gt; x == &lt;span class="string"&gt;"b"&lt;/span&gt;: &lt;span class="keyword"&gt;return&lt;/span&gt; 2
    &lt;span class="keyword"&gt;return&lt;/span&gt; 9

y = 2

&lt;span class="keyword"&gt;print&lt;/span&gt;(f(y))&lt;/pre&gt;

&lt;h2&gt;Unix Shell Use of Logical Operator as Flow Control&lt;/h2&gt;

&lt;p&gt;Another example is to use logical operators for program flow control. This is most abused in unix shell, and in fact is a idiom. Here's some example from Ubuntu Linux 〔/etc/init.d/bootlogd〕:&lt;/p&gt;

&lt;pre class="bash"&gt;[ -x &lt;span class="string"&gt;"$DAEMON"&lt;/span&gt; ] || &lt;span class="keyword"&gt;exit&lt;/span&gt; 0&lt;/pre&gt;

&lt;pre class="bash"&gt;[ &lt;span class="string"&gt;"$VERBOSE"&lt;/span&gt; != no ] &amp;amp;&amp;amp; log_end_msg $&lt;span class="variable-name"&gt;ES&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;They are used for flow control.&lt;/p&gt;

&lt;p&gt;It work by a implementation quirk on evaluating boolean expressions. For example, if you have &lt;code&gt;x1 || x2 || x3 || x4&lt;/code&gt;, as soon as “x1” is true, you don't need to evaluate the rest anymore. Similar, if you have &lt;code&gt;x1 &amp;amp;&amp;amp; x2 &amp;amp;&amp;amp; x3 &amp;amp;&amp;amp; x4&lt;/code&gt;, if x1 is false, the whole result is false, no need to go on.&lt;/p&gt;

&lt;div class="rltd"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/math/function_and_operators.html"&gt;What's Function, What's Operator?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/math/logical_operators.html"&gt;Logical Operators, Truth Table, Unicode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/perl-python/why_python_lambda_broke.html"&gt;Why Python's Lambda is Broken and Can't be Fixed&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/comp/unix_pipes_and_functional_lang.html"&gt;Unix Pipe as Functional Language&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/a-1qslbNsbA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/6608919348585467909/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/programing-craft-intention-vs-coolness.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/6608919348585467909?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/6608919348585467909?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/a-1qslbNsbA/programing-craft-intention-vs-coolness.html" title="Programing Craft: Intention vs Coolness" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/programing-craft-intention-vs-coolness.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEGQnY6eyp7ImA9WhBbFUw.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-8133119230019491974</id><published>2013-05-13T23:23:00.001-07:00</published><updated>2013-05-13T23:23:43.813-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-13T23:23:43.813-07:00</app:edited><title>new emacs modes for emacs lisp, php, html, css, and lean elisp manual</title><content type="html">&lt;p&gt;Am doing a pledge for a few new emacs projects. Vote for your emacs project: new html-mode, css-mode, php-mode, elisp-mode, or new lean emacs lisp manual. please see &lt;a class="sorc" href="http://pledgie.com/campaigns/19973" data-accessed="2013-05-13"&gt;http://pledgie.com/campaigns/19973&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/RAWO9OQTyy4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/8133119230019491974/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/new-emacs-modes-for-emacs-lisp-php-html.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/8133119230019491974?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/8133119230019491974?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/RAWO9OQTyy4/new-emacs-modes-for-emacs-lisp-php-html.html" title="new emacs modes for emacs lisp, php, html, css, and lean elisp manual" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/new-emacs-modes-for-emacs-lisp-php-html.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQDSXc9eSp7ImA9WhBbE0o.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-6963123787925326823</id><published>2013-05-12T07:52:00.003-07:00</published><updated>2013-05-12T07:52:58.961-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-12T07:52:58.961-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="web dev" /><category scheme="http://www.blogger.com/atom/ns#" term="computing" /><title>The Unfortunate Fate of Music MIDI File</title><content type="html">
&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/MIDI"&gt;MIDI&lt;/a&gt; is really a great tech, but unfortunately, it never picked up in computer.&lt;/p&gt;

&lt;p&gt;MIDI is tiny in size, especially great for piano music. For example, a 5 minute piano piece is only 11k bytes.&lt;/p&gt;

&lt;p&gt;10 years ago, i'd expect by now that on each computer we have high quality sampled sound library for MIDI, so that perhaps just a 100 mega bytes you'd have entire collection of piano music in history, recorded by professionals. Not so.&lt;/p&gt;

&lt;p&gt;Today, on the web, MIDI isn't supported in html5 audio.
〔☛ &lt;a href="http://xahlee.info/js/html5_audio.html"&gt;HTML5 Audio Tag Example&lt;/a&gt;〕
〔☛ &lt;a href="http://xahlee.info/js/html5_tags.html"&gt;HTML5 Tags&lt;/a&gt;〕
And it won't play on Linux by default.
&lt;/p&gt;

&lt;p&gt;Here's entire collection of Bach's 〈Well Tempered Clavier〉, just 529k. &lt;a href="http://xahmusic.org/ClassicalMusic_dir/mlisting_bach.html"&gt;Music: MIDI Collection of Bach &#x1f3b6;&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/pznBlLEYjKk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/6963123787925326823/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/the-unfortunate-fate-of-music-midi-file.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/6963123787925326823?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/6963123787925326823?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/pznBlLEYjKk/the-unfortunate-fate-of-music-midi-file.html" title="The Unfortunate Fate of Music MIDI File" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/the-unfortunate-fate-of-music-midi-file.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4GQns_fyp7ImA9WhBbE04.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-5213764442320087135</id><published>2013-05-11T21:28:00.001-07:00</published><updated>2013-05-11T21:28:43.547-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-11T21:28:43.547-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programing" /><category scheme="http://www.blogger.com/atom/ns#" term="computer languages" /><title>is XML Syntax Regular?</title><content type="html">&lt;p&gt;Even XML, whose syntax is more regular than lisp, cannot escape irregularities.&lt;/p&gt;

&lt;p&gt;Here's a sample valid XML, from ATOM webfeed.&lt;/p&gt;

&lt;pre class="xml"&gt;&amp;lt;&lt;span class="keyword"&gt;?xml&lt;/span&gt; &lt;span class="variable-name"&gt;version&lt;/span&gt;=&lt;span class="string"&gt;"1.0"&lt;/span&gt; &lt;span class="variable-name"&gt;encoding&lt;/span&gt;=&lt;span class="string"&gt;"utf-8"&lt;/span&gt;?&amp;gt;
&amp;lt;&lt;span class="function-name"&gt;feed&lt;/span&gt; &lt;span class="variable-name"&gt;xmlns&lt;/span&gt;=&lt;span class="string"&gt;"http://www.w3.org/2005/Atom"&lt;/span&gt; &lt;span class="sgml-namespace"&gt;xml&lt;/span&gt;:&lt;span class="variable-name"&gt;base&lt;/span&gt;=&lt;span class="string"&gt;"http://xahlee.info/comp/"&lt;/span&gt;&amp;gt;

  &amp;lt;&lt;span class="function-name"&gt;title&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;title&lt;/span&gt;&amp;gt;
  &amp;lt;&lt;span class="function-name"&gt;subtitle&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;subtitle&lt;/span&gt;&amp;gt;
  &amp;lt;&lt;span class="function-name"&gt;link&lt;/span&gt; &lt;span class="variable-name"&gt;rel&lt;/span&gt;=&lt;span class="string"&gt;"self"&lt;/span&gt; &lt;span class="variable-name"&gt;href&lt;/span&gt;=&lt;span class="string"&gt;"blog.xml"&lt;/span&gt;/&amp;gt;
  &amp;lt;&lt;span class="function-name"&gt;link&lt;/span&gt; &lt;span class="variable-name"&gt;rel&lt;/span&gt;=&lt;span class="string"&gt;"alternate"&lt;/span&gt; &lt;span class="variable-name"&gt;href&lt;/span&gt;=&lt;span class="string"&gt;"blog.html"&lt;/span&gt;/&amp;gt;
  &amp;lt;&lt;span class="function-name"&gt;updated&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;updated&lt;/span&gt;&amp;gt;
  &amp;lt;&lt;span class="function-name"&gt;author&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span class="function-name"&gt;name&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;name&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span class="function-name"&gt;uri&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;uri&lt;/span&gt;&amp;gt;
  &amp;lt;/&lt;span class="function-name"&gt;author&lt;/span&gt;&amp;gt;
  &amp;lt;&lt;span class="function-name"&gt;id&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;id&lt;/span&gt;&amp;gt;
  &amp;lt;&lt;span class="function-name"&gt;icon&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;icon&lt;/span&gt;&amp;gt;
  &amp;lt;&lt;span class="function-name"&gt;rights&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;rights&lt;/span&gt;&amp;gt;

  &amp;lt;&lt;span class="function-name"&gt;entry&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span class="function-name"&gt;title&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;title&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span class="function-name"&gt;id&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;id&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span class="function-name"&gt;updated&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;updated&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span class="function-name"&gt;summary&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;summary&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span class="function-name"&gt;content&lt;/span&gt; &lt;span class="variable-name"&gt;type&lt;/span&gt;=&lt;span class="string"&gt;"xhtml"&lt;/span&gt;&amp;gt;
      &amp;lt;&lt;span class="function-name"&gt;div&lt;/span&gt; &lt;span class="variable-name"&gt;xmlns&lt;/span&gt;=&lt;span class="string"&gt;"http://www.w3.org/1999/xhtml"&lt;/span&gt;&amp;gt;
        &amp;lt;&lt;span class="function-name"&gt;p&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class="function-name"&gt;a&lt;/span&gt; &lt;span class="variable-name"&gt;href&lt;/span&gt;=&lt;span class="string"&gt;"…"&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;a&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span class="function-name"&gt;p&lt;/span&gt;&amp;gt;
        &amp;lt;&lt;span class="function-name"&gt;p&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;p&lt;/span&gt;&amp;gt;
        &amp;lt;&lt;span class="function-name"&gt;p&lt;/span&gt;&amp;gt;…&amp;lt;/&lt;span class="function-name"&gt;p&lt;/span&gt;&amp;gt;
      &amp;lt;/&lt;span class="function-name"&gt;div&lt;/span&gt;&amp;gt;
    &amp;lt;/&lt;span class="function-name"&gt;content&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span class="function-name"&gt;link&lt;/span&gt; &lt;span class="variable-name"&gt;rel&lt;/span&gt;=&lt;span class="string"&gt;"alternate"&lt;/span&gt; &lt;span class="variable-name"&gt;href&lt;/span&gt;=&lt;span class="string"&gt;"…"&lt;/span&gt;/&amp;gt;
  &amp;lt;/&lt;span class="function-name"&gt;entry&lt;/span&gt;&amp;gt;

&amp;lt;/&lt;span class="function-name"&gt;feed&lt;/span&gt;&amp;gt;&lt;/pre&gt;

&lt;p&gt;Can you spot the syntax irregularity?&lt;/p&gt;

&lt;p&gt;for moar, see &lt;a href="http://xahlee.info/comp/syntax_irregularity_vs_convenience.html"&gt;Programing Language Design: Syntax Sugar Problem: Irregularity vs Convenience&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/-GBqZknczcg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/5213764442320087135/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/is-xml-syntax-regular.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/5213764442320087135?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/5213764442320087135?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/-GBqZknczcg/is-xml-syntax-regular.html" title="is XML Syntax Regular?" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/is-xml-syntax-regular.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkUBRn8yfip7ImA9WhBbE04.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-652044410896770934</id><published>2013-05-11T20:44:00.001-07:00</published><updated>2013-05-11T20:44:17.196-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-11T20:44:17.196-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>emacs: convert Unicode chars to ASCII (Zap Gremlins)</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://ergoemacs.org/emacs/emacs_zap_gremlins.html"&gt;http://ergoemacs.org/emacs/emacs_zap_gremlins.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This page shows a emacs lisp command that changes Unicode string into ASCII. For example “passé” becomes “passe”, “voilà” becomes “voila”.&lt;/p&gt;

&lt;h2&gt;Emacs Lisp Solution&lt;/h2&gt;

&lt;p&gt;Here's a solution.&lt;/p&gt;

&lt;pre class="emacs-lisp"&gt;(&lt;span class="keyword"&gt;defun&lt;/span&gt; asciify-text (ξstring &lt;span class="type"&gt;&amp;amp;optional&lt;/span&gt; ξfrom ξto)
&lt;span class="string"&gt;"Change some Unicode characters into equivalent ASCII ones.
For example, “passé” becomes “passe”.

This function works on chars in European languages, and does not transcode arbitrary Unicode chars (such as Greek, math symbols).  Un-transformed unicode char remains in the string.

When called interactively, work on text selection or current block.

When called in lisp code, if ξfrom is nil, returns a changed string, else, change text in the region between positions ξfrom ξto."&lt;/span&gt;
  (&lt;span class="function-name"&gt;interactive&lt;/span&gt;
   (&lt;span class="keyword"&gt;if&lt;/span&gt; (&lt;span class="function-name"&gt;region-active-p&lt;/span&gt;)
       (&lt;span class="keyword"&gt;list&lt;/span&gt; &lt;span class="keyword"&gt;nil&lt;/span&gt; (&lt;span class="function-name"&gt;region-beginning&lt;/span&gt;) (&lt;span class="function-name"&gt;region-end&lt;/span&gt;))
     (&lt;span class="keyword"&gt;let&lt;/span&gt; ((bds (&lt;span class="function-name"&gt;bounds-of-thing-at-point&lt;/span&gt; 'paragraph)) )
       (&lt;span class="keyword"&gt;list&lt;/span&gt; &lt;span class="keyword"&gt;nil&lt;/span&gt; (&lt;span class="keyword"&gt;car&lt;/span&gt; bds) (&lt;span class="keyword"&gt;cdr&lt;/span&gt; bds)) ) ) )

  (&lt;span class="keyword"&gt;require&lt;/span&gt; 'xfrp_find_replace_pairs)

  (&lt;span class="keyword"&gt;let&lt;/span&gt; (workOnStringP
        inputStr
        (charChangeMap [
                        [&lt;span class="string"&gt;"á\\|à\\|â\\|ä\\|ã\\|å"&lt;/span&gt; &lt;span class="string"&gt;"a"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"é\\|è\\|ê\\|ë"&lt;/span&gt; &lt;span class="string"&gt;"e"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"í\\|ì\\|î\\|ï"&lt;/span&gt; &lt;span class="string"&gt;"i"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"ó\\|ò\\|ô\\|ö\\|õ\\|ø"&lt;/span&gt; &lt;span class="string"&gt;"o"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"ú\\|ù\\|û\\|ü"&lt;/span&gt;     &lt;span class="string"&gt;"u"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"Ý\\|ý\\|ÿ"&lt;/span&gt;     &lt;span class="string"&gt;"y"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"ñ"&lt;/span&gt; &lt;span class="string"&gt;"n"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"ç"&lt;/span&gt; &lt;span class="string"&gt;"c"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"ð"&lt;/span&gt; &lt;span class="string"&gt;"d"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"þ"&lt;/span&gt; &lt;span class="string"&gt;"th"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"ß"&lt;/span&gt; &lt;span class="string"&gt;"ss"&lt;/span&gt;]
                        [&lt;span class="string"&gt;"æ"&lt;/span&gt; &lt;span class="string"&gt;"ae"&lt;/span&gt;]
                        ])
        )
    (&lt;span class="keyword"&gt;setq&lt;/span&gt; workOnStringP (&lt;span class="keyword"&gt;if&lt;/span&gt; ξfrom &lt;span class="keyword"&gt;nil&lt;/span&gt; &lt;span class="keyword"&gt;t&lt;/span&gt;))
    (&lt;span class="keyword"&gt;setq&lt;/span&gt; inputStr (&lt;span class="keyword"&gt;if&lt;/span&gt; workOnStringP ξstring (&lt;span class="function-name"&gt;buffer-substring-no-properties&lt;/span&gt; ξfrom ξto)))
    (&lt;span class="keyword"&gt;if&lt;/span&gt; workOnStringP
        (&lt;span class="keyword"&gt;let&lt;/span&gt; ((&lt;span class="variable-name"&gt;case-fold-search&lt;/span&gt; &lt;span class="keyword"&gt;t&lt;/span&gt;)) (replace-regexp-pairs-in-string inputStr charChangeMap) )
      (&lt;span class="keyword"&gt;let&lt;/span&gt; ((&lt;span class="variable-name"&gt;case-fold-search&lt;/span&gt; &lt;span class="keyword"&gt;t&lt;/span&gt;)) (replace-regexp-pairs-region ξfrom ξto charChangeMap) )) ) )&lt;/pre&gt;

&lt;p&gt;You'll need &lt;a href="http://ergoemacs.org/emacs/elisp_replace_string_region.html"&gt;xfrp_find_replace_pairs.el&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;TODO&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Handle common  Unicode symbols: {• → ≥ …}. 〔☛ &lt;a href="http://xahlee.info/comp/unicode_common_symbols.html"&gt;List of Commonly Used Symbols in Unicode&lt;/a&gt;〕&lt;/li&gt;
&lt;li&gt;Delete any non-ASCII chars that are not handled (use the &lt;a href="http://ergoemacs.org/emacs/emacs_regex.html"&gt;emacs regex&lt;/a&gt; &lt;code&gt;[:nonascii:]&lt;/code&gt;) Or, leave untranslated Unicode chars as is.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Accumulator vs Parallel Programing&lt;/h2&gt;

&lt;p&gt;This problem makes a good parallel programing exercise. See: &lt;a href="http://xahlee.info/comp/parallel_programing_exercise_asciify-string.html"&gt;Parallel Programing Exercise: asciify-string&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Alternative Solution with “iconv” or perl&lt;/h2&gt;

&lt;div class="date-α"&gt;&lt;time&gt;2011-03-08&lt;/time&gt;&lt;/div&gt;

&lt;p&gt;Yuri Khan and Teemu Likonen suggested using the “iconv” shell command. Here's Teemu's code.&lt;/p&gt;

&lt;pre class="emacs-lisp"&gt;(&lt;span class="keyword"&gt;defun&lt;/span&gt; asciify-string (&lt;span class="keyword"&gt;string&lt;/span&gt;)
&lt;span class="string"&gt;"Convert STRING to ASCII string.
For example:
“passé” becomes “passe”
Code originally by Teemu Likonen."&lt;/span&gt;
  (&lt;span class="function-name"&gt;with-temp-buffer&lt;/span&gt;
    (&lt;span class="function-name"&gt;insert&lt;/span&gt; &lt;span class="keyword"&gt;string&lt;/span&gt;)
    (call-process-region (&lt;span class="function-name"&gt;point-min&lt;/span&gt;) (&lt;span class="function-name"&gt;point-max&lt;/span&gt;) &lt;span class="string"&gt;"iconv"&lt;/span&gt; &lt;span class="keyword"&gt;t&lt;/span&gt; &lt;span class="keyword"&gt;t&lt;/span&gt; &lt;span class="keyword"&gt;nil&lt;/span&gt; &lt;span class="string"&gt;"--to-code=ASCII//TRANSLIT"&lt;/span&gt;)
    (&lt;span class="function-name"&gt;buffer-substring-no-properties&lt;/span&gt; (&lt;span class="function-name"&gt;point-min&lt;/span&gt;) (&lt;span class="function-name"&gt;point-max&lt;/span&gt;))))&lt;/pre&gt;

&lt;p&gt;Julian Bradfield suggested Perl. Here's his one-liner, it removes just accents.&lt;/p&gt;

&lt;pre class="bash"&gt;
perl -e &lt;span class="string"&gt;'use encoding utf8; use Unicode::Normalize; while ( &amp;lt;&amp;gt; ) { $_ = NFKD($_); s/\pM//g; print; }'&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;&lt;a class="sorc" href="http://groups.google.com/group/comp.emacs/msg/8d58b6e9b2bd07fd" data-accessed="2011-03-08"&gt;Source groups.google.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Though, it would be nice to have a pure elisp solution, because “iconv” is not in Windows or Mac OS X as of &lt;time&gt;2011-03-08&lt;/time&gt;.&lt;/p&gt;

&lt;div class="rltd"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/emacs_n_unicode.html"&gt;Emacs ＆ Unicode Tips&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/t4x3PNMiwMM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/652044410896770934/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/emacs-convert-unicode-chars-to-ascii.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/652044410896770934?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/652044410896770934?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/t4x3PNMiwMM/emacs-convert-unicode-chars-to-ascii.html" title="emacs: convert Unicode chars to ASCII (Zap Gremlins)" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/emacs-convert-unicode-chars-to-ascii.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYCRXs-fip7ImA9WhBbEkU.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-1854747879049910443</id><published>2013-05-11T07:39:00.003-07:00</published><updated>2013-05-11T07:56:04.556-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-11T07:56:04.556-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="lisp" /><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>Emacs: Change {Round, Square, Curly} Brackets in Text</title><content type="html">&lt;p&gt;when you have data in different languages, sometimes you need to convert round brackets to square brackets, or curly brackets.&lt;/p&gt;

&lt;p&gt;When you need to do that, it's often tedious. You have to do replacement twice, once for the left bracket, then right bracket. Here's a command that helps:&lt;/p&gt;

&lt;pre class="emacs-lisp"&gt;(&lt;span class="keyword"&gt;defun&lt;/span&gt; change-bracket-pairs (fromType toType)
  &lt;span class="string"&gt;"Change bracket pairs from one type to another on text selection or text block.
For example, change all parenthesis () to square brackets [].

In lisp code, fromType is a string of a bracket pair. ⁖ \"()\", likewise for toType."&lt;/span&gt;
  (&lt;span class="function-name"&gt;interactive&lt;/span&gt;
   (&lt;span class="keyword"&gt;let&lt;/span&gt; (
         (bracketTypes '(&lt;span class="string"&gt;"[]"&lt;/span&gt; &lt;span class="string"&gt;"()"&lt;/span&gt; &lt;span class="string"&gt;"{}"&lt;/span&gt; &lt;span class="string"&gt;"〈〉"&lt;/span&gt; &lt;span class="string"&gt;"《》"&lt;/span&gt; &lt;span class="string"&gt;"「」"&lt;/span&gt; &lt;span class="string"&gt;"『』"&lt;/span&gt; &lt;span class="string"&gt;"【】"&lt;/span&gt; &lt;span class="string"&gt;"〖〗"&lt;/span&gt;))
         )
     (&lt;span class="keyword"&gt;list&lt;/span&gt;
      (ido-completing-read &lt;span class="string"&gt;"Replace this:"&lt;/span&gt; bracketTypes &lt;span class="string"&gt;"PREDICATE"&lt;/span&gt; )
      (ido-completing-read &lt;span class="string"&gt;"To:"&lt;/span&gt; bracketTypes &lt;span class="string"&gt;"PREDICATE"&lt;/span&gt; ) ) ) )

  (&lt;span class="keyword"&gt;let*&lt;/span&gt; (
         (bds (get-selection-or-unit 'block))
         (p1 (&lt;span class="keyword"&gt;elt&lt;/span&gt; bds 1))
         (p2 (&lt;span class="keyword"&gt;elt&lt;/span&gt; bds 2))
         (changePairs (&lt;span class="keyword"&gt;vector&lt;/span&gt;
                 (&lt;span class="keyword"&gt;vector&lt;/span&gt; (char-to-string (&lt;span class="keyword"&gt;elt&lt;/span&gt; fromType 0)) (char-to-string (&lt;span class="keyword"&gt;elt&lt;/span&gt; toType 0)))
                 (&lt;span class="keyword"&gt;vector&lt;/span&gt; (char-to-string (&lt;span class="keyword"&gt;elt&lt;/span&gt; fromType 1)) (char-to-string (&lt;span class="keyword"&gt;elt&lt;/span&gt; toType 1)))
                 ))
         )
    (replace-pairs-region p1 p2 changePairs) ) )&lt;/pre&gt;

&lt;p&gt;you'll need &lt;a href="http://ergoemacs.org/emacs/elisp_get-selection-or-unit.html"&gt;get-selection-or-unit&lt;/a&gt; and
&lt;a href="http://ergoemacs.org/emacs/elisp_replace_string_region.html"&gt;xfrp_find_replace_pairs.el&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/t9yQmG3jRY0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/1854747879049910443/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/emacs-change-round-square-curly.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1854747879049910443?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1854747879049910443?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/t9yQmG3jRY0/emacs-change-round-square-curly.html" title="Emacs: Change {Round, Square, Curly} Brackets in Text" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/emacs-change-round-square-curly.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMDSHw_eyp7ImA9WhBbEks.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-373224958059300241</id><published>2013-05-11T01:21:00.001-07:00</published><updated>2013-05-11T01:21:19.243-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-11T01:21:19.243-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programing" /><title>Perl: Sort List, Matrix, Object</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://xahlee.info/perl/perl_sort.html"&gt;http://xahlee.info/perl/perl_sort.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This page shows you how to sort in Perl&lt;/p&gt;

&lt;p&gt;here's a example of sort (Perl 5.14):&lt;/p&gt;

&lt;pre class="perl"&gt;&lt;span class="comment-delimiter"&gt;#&lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;perl
&lt;/span&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;sort a list
&lt;/span&gt;
&lt;span class="cperl-array"&gt;@li&lt;/span&gt; = (1,9,2,3);

&lt;span class="cperl-array"&gt;@li2&lt;/span&gt; = &lt;span class="cperl-nonoverridable"&gt;sort&lt;/span&gt; {$a &amp;lt;=&amp;gt; $b} &lt;span class="cperl-array"&gt;@li&lt;/span&gt;; &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;original list is not changed
&lt;/span&gt;
&lt;span class="cperl-nonoverridable"&gt;print&lt;/span&gt; &lt;span class="type"&gt;join&lt;/span&gt;(&lt;span class="string"&gt;' '&lt;/span&gt;, &lt;span class="cperl-array"&gt;@li2&lt;/span&gt;); &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;1 2 3 9&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;In Perl, sort is a function. It returns the sorted result as another list.&lt;/p&gt;

&lt;p&gt;“sort” takes the form &lt;code&gt;sort {…} @myList&lt;/code&gt;. Inside the enclosing braces is the body of the ordering function, where variables 「$a」 and 「$b」 inside are predefined by the language to represent two elements in the list. The operator &lt;code&gt;&amp;lt;=&amp;gt;&lt;/code&gt; returns -1 if left operand is less than the right operand. If equal, it returns 0, else 1. It is equivalent to Python's “cmp” function.&lt;/p&gt;

&lt;p&gt;Another form of sort is &lt;code&gt;sort orderFunctionName @list&lt;/code&gt;, which uses a function name in place of the comparison block. The function should have 2 parameters, and return one of {-1, 0, 1}.&lt;/p&gt;

&lt;h2&gt;Compare as Number or as String&lt;/h2&gt;

&lt;p&gt;Perl has 2 comparison operators.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;‹x› &lt;=&gt; ‹y›&lt;/code&gt; compare ‹x› ‹y› as numbers.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;‹x› cmp ‹y›&lt;/code&gt; compare ‹x› ‹y› as strings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;pre class="perl"&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;perl
&lt;/span&gt;
&lt;span class="cperl-nonoverridable"&gt;print&lt;/span&gt; &lt;span class="string"&gt;"3"&lt;/span&gt; &amp;lt;=&amp;gt; &lt;span class="string"&gt;"20"&lt;/span&gt;; &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;prints -1
&lt;/span&gt;
&lt;span class="cperl-nonoverridable"&gt;print&lt;/span&gt; &lt;span class="string"&gt;"\n"&lt;/span&gt;;

&lt;span class="cperl-nonoverridable"&gt;print&lt;/span&gt; &lt;span class="string"&gt;"3"&lt;/span&gt; &lt;span class="type"&gt;cmp&lt;/span&gt; &lt;span class="string"&gt;"20"&lt;/span&gt;; &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;prints 1&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;In Perl, numbers and strings are mutually automatically converted if needed.&lt;/p&gt;

&lt;h2&gt;Sort Matrix&lt;/h2&gt;

&lt;pre class="perl"&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;perl
&lt;/span&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;sort a matrix
&lt;/span&gt;
&lt;span class="keyword"&gt;use&lt;/span&gt; &lt;span class="function-name"&gt;Data::Dumper&lt;/span&gt;;
&lt;span class="keyword"&gt;use&lt;/span&gt; &lt;span class="function-name"&gt;strict&lt;/span&gt;;

&lt;span class="keyword"&gt;my&lt;/span&gt; &lt;span class="cperl-array"&gt;@li1&lt;/span&gt; = ([2,6],[1,3],[5,4]);

&lt;span class="keyword"&gt;my&lt;/span&gt; &lt;span class="cperl-array"&gt;@li2&lt;/span&gt; = &lt;span class="cperl-nonoverridable"&gt;sort&lt;/span&gt; { $a-&amp;gt;[1] &amp;lt;=&amp;gt; $b-&amp;gt;[1] } &lt;span class="cperl-array"&gt;@li1&lt;/span&gt;;

&lt;span class="cperl-nonoverridable"&gt;print&lt;/span&gt; Dumper(\&lt;span class="cperl-array"&gt;@li2&lt;/span&gt;);            &lt;span class="comment-delimiter"&gt;#  &lt;/span&gt;&lt;span class="comment"&gt;[[1, 3], [5, 4], [2, 6]]&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;([2,6],[1,3],[5,4])&lt;/code&gt; is the syntax for nested list. The square brackets inside creates array references.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;$a-&gt;[1]&lt;/code&gt; is the syntax to get the element of a array reference.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;\@li2&lt;/code&gt; in &lt;code&gt;Dumper(\@li2)&lt;/code&gt; gets the reference to the array &lt;code&gt;@li2&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;Reverse Sort Order&lt;/h2&gt;

&lt;p&gt;To reverse sort order, all you have to do is to reverse the placement of &lt;code&gt;$a&lt;/code&gt; and &lt;code&gt;$b&lt;/code&gt; in your comparison. Example: &lt;code&gt;sort {$b &lt;=&gt; $a} @li&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or, you can use the &lt;code&gt;reverse&lt;/code&gt; function afterward, if you don't mind doing extra computation.&lt;/p&gt;

&lt;pre class="perl"&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;perl
&lt;/span&gt;
&lt;span class="keyword"&gt;use&lt;/span&gt; &lt;span class="function-name"&gt;Data::Dumper&lt;/span&gt;;

&lt;span class="cperl-array"&gt;@aa&lt;/span&gt; = (3, 4, 5);

&lt;span class="cperl-array"&gt;@bb&lt;/span&gt; = &lt;span class="type"&gt;reverse&lt;/span&gt;(&lt;span class="cperl-array"&gt;@aa&lt;/span&gt;);

&lt;span class="cperl-nonoverridable"&gt;print&lt;/span&gt; Dumper(\&lt;span class="cperl-array"&gt;@bb&lt;/span&gt;);&lt;/pre&gt;

&lt;h2&gt;Sort Complex Objects&lt;/h2&gt;

&lt;p&gt;Here's a more complex example of sort.&lt;/p&gt;

&lt;p&gt;Suppose you have a list of strings.&lt;/p&gt;

&lt;pre class="code"&gt;'my283.jpg'
'my23i.jpg'
'web7-s.jpg'
'fris88large.jpg'
…&lt;/pre&gt;

&lt;p&gt;You want to sort them by the number embedded in them.&lt;/p&gt;

&lt;p&gt;You need to define a ordering function, and pass it to sort. The function should takes two strings, and compare the integer inside the string. Here's the solution:&lt;/p&gt;

&lt;pre class="perl"&gt;&lt;span class="comment-delimiter"&gt;#&lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;#  &lt;/span&gt;&lt;span class="comment"&gt;perl
&lt;/span&gt;
&lt;span class="cperl-array"&gt;@li&lt;/span&gt; = (
&lt;span class="string"&gt;'my283.jpg'&lt;/span&gt;,
&lt;span class="string"&gt;'my23i.jpg'&lt;/span&gt;,
&lt;span class="string"&gt;'web7-s.jpg'&lt;/span&gt;,
&lt;span class="string"&gt;'fris88large.jpg'&lt;/span&gt;,
);

&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;sorts a list of strings by their embedded number
&lt;/span&gt;
&lt;span class="cperl-array"&gt;@li2&lt;/span&gt; = &lt;span class="cperl-nonoverridable"&gt;sort&lt;/span&gt; { ($a =~ &lt;span class="cperl-nonoverridable"&gt;m&lt;/span&gt;&lt;span class="constant"&gt;/&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="builtin"&gt;\&lt;/span&gt;&lt;span class="type"&gt;d&lt;/span&gt;&lt;span class="builtin"&gt;+&lt;/span&gt;&lt;span class="keyword"&gt;)&lt;/span&gt;&lt;span class="constant"&gt;/&lt;/span&gt;)[0] &amp;lt;=&amp;gt; ($b =~ &lt;span class="cperl-nonoverridable"&gt;m&lt;/span&gt;&lt;span class="constant"&gt;/&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="builtin"&gt;\&lt;/span&gt;&lt;span class="type"&gt;d&lt;/span&gt;&lt;span class="builtin"&gt;+&lt;/span&gt;&lt;span class="keyword"&gt;)&lt;/span&gt;&lt;span class="constant"&gt;/&lt;/span&gt;)[0]} &lt;span class="cperl-array"&gt;@li&lt;/span&gt;;

&lt;span class="cperl-nonoverridable"&gt;print&lt;/span&gt; &lt;span class="type"&gt;join&lt;/span&gt;(&lt;span class="string"&gt;' '&lt;/span&gt;, &lt;span class="cperl-array"&gt;@li2&lt;/span&gt;);  &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;prints web7-s.jpg my23i.jpg fris88large.jpg my283.jpg&lt;/span&gt;&lt;/pre&gt;

&lt;h3&gt;decorate-sort-dedecorate, Schwartzian transform&lt;/h3&gt;

&lt;p&gt;Normally, the key for comparison is computed 2 or more times for each element.&lt;/p&gt;

&lt;p&gt;Here's a more efficient way, called decorate-sort-dedecorate (aka Schwartzian transform).&lt;/p&gt;

&lt;pre class="perl"&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;perl
&lt;/span&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;sort a array of string, by comparing the number part inside the string
&lt;/span&gt;
&lt;span class="cperl-array"&gt;@li&lt;/span&gt; = (&lt;span class="string"&gt;'my283.jpg'&lt;/span&gt;,&lt;span class="string"&gt;'my23i.jpg'&lt;/span&gt;,&lt;span class="string"&gt;'web7-s.jpg'&lt;/span&gt;,&lt;span class="string"&gt;'fris88large.jpg'&lt;/span&gt;);

&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;this is “decorate-sort-dedecorate”, aka Schwartzian transform
&lt;/span&gt;&lt;span class="cperl-array"&gt;@li2&lt;/span&gt; = &lt;span class="cperl-nonoverridable"&gt;map&lt;/span&gt; { $_-&amp;gt;[0] } &lt;span class="cperl-nonoverridable"&gt;sort&lt;/span&gt; { $a-&amp;gt;[1] &amp;lt;=&amp;gt; $b-&amp;gt;[1] } &lt;span class="cperl-nonoverridable"&gt;map&lt;/span&gt; { [ $_, ($_=~&lt;span class="cperl-nonoverridable"&gt;m&lt;/span&gt;&lt;span class="constant"&gt;/&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="builtin"&gt;\&lt;/span&gt;&lt;span class="type"&gt;d&lt;/span&gt;&lt;span class="builtin"&gt;+&lt;/span&gt;&lt;span class="keyword"&gt;)&lt;/span&gt;&lt;span class="constant"&gt;/&lt;/span&gt;)[0] ] } &lt;span class="cperl-array"&gt;@li&lt;/span&gt;;
&lt;span class="comment-delimiter"&gt;#          &lt;/span&gt;&lt;span class="comment"&gt;↑ take item               ↑ sort            ↑ create list of pairs [item,key]
&lt;/span&gt;
&lt;span class="keyword"&gt;use&lt;/span&gt; &lt;span class="function-name"&gt;Data::Dumper&lt;/span&gt;;
&lt;span class="cperl-nonoverridable"&gt;print&lt;/span&gt; Dumper(\&lt;span class="cperl-array"&gt;@li2&lt;/span&gt;); &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;('web7-s.jpg', 'my23i.jpg', 'fris88large.jpg', 'my283.jpg')&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;In the above Perl code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;code&gt;map { [ $_, ($_=~m/(\d+)/)[0] ] } @li;&lt;/code&gt; generates a temp array. Each element is a pair, item ＆ key.&lt;/li&gt;
&lt;li&gt;Then, sort is applied to the temp array.&lt;/li&gt;
&lt;li&gt;Then, another map &lt;code&gt;map { $_-&amp;gt;[0] } …&lt;/code&gt; gets the items of the original list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this way, the cost to compute the same key multiple times is avoided.
This method is good when computing the key is expensive.&lt;/p&gt;

&lt;p&gt;&lt;span class="ref"&gt;&lt;a href="http://perldoc.perl.org/functions/sort.html"&gt;perldoc -f sort&lt;/a&gt;&lt;/span&gt;
&lt;/p&gt;

&lt;h2&gt;General Function to Sort Matrix&lt;/h2&gt;

&lt;p&gt;See: &lt;a href="http://xahlee.info/perl-python/sort_matrix.html"&gt;Perl: General Function for Sorting Matrix&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/XQKPqiZhtZI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/373224958059300241/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/perl-sort-list-matrix-object.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/373224958059300241?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/373224958059300241?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/XQKPqiZhtZI/perl-sort-list-matrix-object.html" title="Perl: Sort List, Matrix, Object" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/perl-sort-list-matrix-object.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8HSHg_cSp7ImA9WhBbEk4.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-7998154651943016618</id><published>2013-05-10T19:07:00.002-07:00</published><updated>2013-05-10T19:20:39.649-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-10T19:20:39.649-07:00</app:edited><title>Syntax = Most Important Aspect of a Programing Language</title><content type="html">
&lt;p&gt;the quality of a programing language, can be judged by how much of it can be explained by its syntax alone.&lt;/p&gt;

&lt;p&gt;with this criterion, the order are roughly: Mathematica ≻ PHP ≻ Lisp ≻ JavaScript ≻ Ruby? ≻ Perl ≻ Python ≻ Java.&lt;/p&gt;


&lt;p&gt;If you have coded one of {Haskell, ML/OCaml/F#, erlang, Pascal/Ada, Lua, tcl, PostScript}, i'd be interested in your opinion on their placement in the above. (you should have coded in the lang for a few years)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/DmwHNVQNs-s" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/7998154651943016618/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/syntax-most-important-aspect-of.html#comment-form" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/7998154651943016618?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/7998154651943016618?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/DmwHNVQNs-s/syntax-most-important-aspect-of.html" title="Syntax = Most Important Aspect of a Programing Language" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>5</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/syntax-most-important-aspect-of.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkIMQ3Y6cCp7ImA9WhBbEk4.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-8224243418042469611</id><published>2013-05-10T17:03:00.000-07:00</published><updated>2013-05-10T17:03:02.818-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-10T17:03:02.818-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programing" /><category scheme="http://www.blogger.com/atom/ns#" term="computer languages" /><title>Python 3: Sort List, Matrix, Object</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://xahlee.info/python/python3_sort.html"&gt;http://xahlee.info/python/python3_sort.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This page shows you how to sort in Python&lt;/p&gt;

&lt;h2&gt;sort Method&lt;/h2&gt;

&lt;p&gt;You can use the “sort” method. For example:&lt;/p&gt;

&lt;pre class="python3"&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;python 3
&lt;/span&gt;
&lt;span class="variable-name"&gt;li&lt;/span&gt; = [1,9,2,3]

li.sort() &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;the variable is modified
&lt;/span&gt;
&lt;span class="keyword"&gt;print&lt;/span&gt;(li) &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;[1, 2, 3, 9]
&lt;/span&gt;&lt;/pre&gt;

&lt;h2&gt;sort Function&lt;/h2&gt;

&lt;p&gt;You can use the “sorted” function. This does not modify the variable. For example:&lt;/p&gt;

&lt;pre class="python3"&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;python 3
&lt;/span&gt;
&lt;span class="variable-name"&gt;li&lt;/span&gt; = [1,9,2,3]

&lt;span class="variable-name"&gt;li2&lt;/span&gt; = &lt;span class="builtin"&gt;sorted&lt;/span&gt;(li)

&lt;span class="keyword"&gt;print&lt;/span&gt;(li)                       &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;[1, 9, 2, 3]
&lt;/span&gt;&lt;span class="keyword"&gt;print&lt;/span&gt;(li2)                      &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;[1, 2, 3, 9]
&lt;/span&gt;&lt;/pre&gt;

&lt;h2&gt;sort by Column/Key&lt;/h2&gt;

&lt;p&gt;You can sort by specifying a optional parameter “key”. This is most useful for sorting a matrix.&lt;/p&gt;

&lt;pre class="python3"&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;python 3
&lt;/span&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;sort a matrix
&lt;/span&gt;
&lt;span class="variable-name"&gt;li&lt;/span&gt; = [[2,6],[1,3],[5,4]]

li.sort(key=&lt;span class="keyword"&gt;lambda&lt;/span&gt; x:x[1])

&lt;span class="keyword"&gt;print&lt;/span&gt;(li);                      &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;prints [[1, 3], [5, 4], [2, 6]]
&lt;/span&gt;&lt;/pre&gt;

&lt;h3&gt;Sort and Reverse&lt;/h3&gt;

&lt;p&gt;Another optional parameter is “reverse”. You can use it like this&lt;/p&gt;

&lt;pre class="python3"&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;python 3
&lt;/span&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;sort a matrix, by 2nd column, reverse order
&lt;/span&gt;
&lt;span class="variable-name"&gt;li&lt;/span&gt; = [[2,6],[1,3],[5,4]]

li.sort(key=&lt;span class="keyword"&gt;lambda&lt;/span&gt; x:x[1], reverse=&lt;span class="constant"&gt;True&lt;/span&gt;)

&lt;span class="keyword"&gt;print&lt;/span&gt;(li);                      &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;prints [[2, 6], [5, 4], [1, 3]]
&lt;/span&gt;&lt;/pre&gt;

&lt;h2&gt;Sort Arbitrary Object&lt;/h2&gt;

&lt;p&gt;Here's a more complex example. Suppose you have a list of strings.&lt;/p&gt;

&lt;pre class="code"&gt;'my283.jpg'
'my23i.jpg'
'web7-s.jpg'
'fris88large.jpg'
…&lt;/pre&gt;

&lt;p&gt;You want to sort them by the number embedded in them.&lt;/p&gt;

&lt;p&gt;You need to define a ordering function, and pass it to sort. The function should takes two strings, and compare the integer inside the string. Here's the solution:&lt;/p&gt;

&lt;pre class="python3"&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;-*- coding: utf-8 -*-
&lt;/span&gt;&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;python 3
&lt;/span&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;sort by custom order
&lt;/span&gt;
&lt;span class="keyword"&gt;import&lt;/span&gt; re

&lt;span class="variable-name"&gt;li&lt;/span&gt; = [
&lt;span class="string"&gt;"my283.jpg"&lt;/span&gt;,
&lt;span class="string"&gt;"my23i.jpg"&lt;/span&gt;,
&lt;span class="string"&gt;"web7-s.jpg"&lt;/span&gt;,
&lt;span class="string"&gt;"fris88large.jpg"&lt;/span&gt;,
]

&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;compare number inside string
&lt;/span&gt;&lt;span class="keyword"&gt;def&lt;/span&gt; &lt;span class="function-name"&gt;myKey&lt;/span&gt; (myString):
    &lt;span class="keyword"&gt;return&lt;/span&gt; &lt;span class="builtin"&gt;float&lt;/span&gt;(re.findall(r&lt;span class="string"&gt;"\d+"&lt;/span&gt;, myString)[0]) &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;return number part in string
&lt;/span&gt;
li.sort(key = myKey)

&lt;span class="keyword"&gt;print&lt;/span&gt;(li) &lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;returns ["web7-s.jpg", "my23i.jpg", "fris88large.jpg", "my283.jpg"]
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Here, we defined a function “myKey” to tell sort about the key to use.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/pkFLkyZzG98" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/8224243418042469611/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/python-3-sort-list-matrix-object.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/8224243418042469611?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/8224243418042469611?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/pkFLkyZzG98/python-3-sort-list-matrix-object.html" title="Python 3: Sort List, Matrix, Object" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/python-3-sort-list-matrix-object.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UBQXo7eip7ImA9WhBbEk8.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-1439123885269780325</id><published>2013-05-10T16:40:00.002-07:00</published><updated>2013-05-10T16:40:50.402-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-10T16:40:50.402-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="computer languages" /><title>Programing Language Design: Syntax Sugar Problem: Irregularity vs Convenience</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://xahlee.info/comp/syntax_irregularity_vs_convenience.html"&gt;http://xahlee.info/comp/syntax_irregularity_vs_convenience.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;one of the idiocy of HTML spec is that the “pre” tag discards the first blank line.&lt;/p&gt;

&lt;p&gt;for example, if you have:&lt;/p&gt;

&lt;pre class="html"&gt;
&amp;lt;&lt;span class="function-name"&gt;pre&lt;/span&gt; &lt;span class="variable-name"&gt;style&lt;/span&gt;=&lt;span class="string"&gt;"border:solid thin red"&lt;/span&gt;&amp;gt;
x = 3
&amp;lt;/&lt;span class="function-name"&gt;pre&lt;/span&gt;&amp;gt;&lt;/pre&gt;

&lt;p&gt;Here's how your browser renders it:&lt;/p&gt;

&lt;pre style="border:solid thin red"&gt;
x = 3
&lt;/pre&gt;

&lt;p&gt;The first blank line is ignored. However, only the FIRST blank line is ignored. If you have 2 blank lines in the beginning, it'll be rendered with 1 blank line.&lt;/p&gt;

&lt;pre class="html"&gt;
&amp;lt;&lt;span class="function-name"&gt;pre&lt;/span&gt; &lt;span class="variable-name"&gt;style&lt;/span&gt;=&lt;span class="string"&gt;"border:solid thin red"&lt;/span&gt;&amp;gt;

x = 3
&amp;lt;/&lt;span class="function-name"&gt;pre&lt;/span&gt;&amp;gt;&lt;/pre&gt;

&lt;pre style="border:solid thin red"&gt;

x = 3
&lt;/pre&gt;

&lt;p&gt;They do this, because, it's convenient for coder. Because, one likes to see the pre content aligned to the left in raw HTML.&lt;/p&gt;

&lt;p&gt;For example, you rather write it this way:&lt;/p&gt;

&lt;pre class="html"&gt;
&amp;lt;&lt;span class="function-name"&gt;pre&lt;/span&gt;&amp;gt;
1
2
3
&amp;lt;/&lt;span class="function-name"&gt;pre&lt;/span&gt;&amp;gt;&lt;/pre&gt;

&lt;p&gt;than&lt;/p&gt;

&lt;pre class="html"&gt;
&amp;lt;&lt;span class="function-name"&gt;pre&lt;/span&gt;&amp;gt;1
2
3&amp;lt;/&lt;span class="function-name"&gt;pre&lt;/span&gt;&amp;gt;&lt;/pre&gt;

&lt;p&gt;this is a idiocy because it mixes convenience with syntax.&lt;/p&gt;

&lt;p&gt;The problem comes, when you have programs that deal with code. That's why, in programing, computing tech, there are one hundred exceptions, irregularities, and thus bugs, headaches. The worst offender is unix shell syntax.
〔☛ &lt;a href="http://xahlee.info/comp/unix_pipes_and_functional_lang.html"&gt;Unix Shell Syntax Irregularities Galore&lt;/a&gt;〕
&lt;/p&gt;

&lt;p&gt;At first, syntax conveniences like these are nice. The rules are lax, and you use it without problems. But then, once the language grew, and you deal with many languages, you find everywhere there's exceptions, special rules, and you can't remember what rule they thought were convenient at the time, and there is no simple systematic rule about them. Each one becomes a ad hoc syntax soup of hell.&lt;/p&gt;

&lt;p&gt;For example of the bad consequence of the “pre” tag, see: &lt;a href="http://xahlee.info/js/linebreak_after_tag.html"&gt;CSS “pre” Problem: No Linebreak After Tag&lt;/a&gt;. And syntax coloring tools that color computer program source code in HTML, have to work-around the problem by wrapping “span” tag with line-breaks at unnatural places.
〔☛ &lt;a href="http://ergoemacs.org/emacs/elisp_htmlize.html"&gt;Emacs Lisp: Syntax Color Source Code in HTML&lt;/a&gt;〕
&lt;/p&gt;

&lt;p&gt;Almost all languages have this problem, to various degrees. C language syntax is worst. It is basically of no design. Most of the syntax “design” is based on user's typing convenience at the time.
〔☛ &lt;a href="http://xahlee.info/comp/why_i_hate_C_lang.html"&gt;Programing: Why I Hate C&lt;/a&gt;〕
Even lisp, didn't escape this problem.
〔☛ &lt;a href="http://xahlee.info/UnixResource_dir/writ/lisp_problems.html"&gt;Programing Language: Fundamental Problems of Lisp&lt;/a&gt;〕
&lt;/p&gt;

&lt;p&gt;Another major problem of HTML irregularity is letting users to omit ending tags. Big offender is Google, telling users to omit ending tags in their HTML style guide. The consequence is that people will omit ending tags that cannot be ommited, and we are back to syntax-soup quirk-mode hell. See:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/js/ex/html_head_body_optional.html"&gt;HTML {html, head, body} Tags are Optional&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/js/Google_html_css_style_guide.html"&gt;Google HTML/CSS Style Guide: Good Style or Bad Taste?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;How to Solve the Syntax Sugar Problem?&lt;/h2&gt;

&lt;p&gt;This problem should be solved by clear separation of issues. For example, XML takes the regularity approach, and you can have editors that represent the data to the user in a most easy-to-read format, or structural editors. Another approach is Mathematica, where you have a systematic syntax layer. So, at the bottom layer, it's purely nested like XML and LISP, but without irregularities, and another layer on top, that supports all the syntax warts we human have got used to, as in traditional math notation and infix notation. Yet, there's a simple, regular, systematic, transformation rules that can change these two layers easily.&lt;/p&gt;

&lt;p&gt;Instead of syntax sugar, you should have a 100% regular syntax, or a layer with systematic rule, and let editor deal with it, and present code to user in a different layer.&lt;/p&gt;

&lt;p&gt;See also:&lt;/p&gt;

&lt;div class="rltd"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/comp/whitespace_in_programing_language.html"&gt;What Does it Means When a Programing Language Claims “Whitespace is Insignificant”?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/comp/language_syntax_brackets_vs_begin_end.html"&gt;Language Syntax: Brackets vs Begin/End&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/UnixResource_dir/writ/notations.html"&gt;Concepts ＆ Confusions of {Prefix, Infix, Postfix, Fully Nested} Notations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/UnixResource_dir/writ/lisp_problems.html"&gt;Programing Language: Fundamental Problems of Lisp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/comp/properties_of_syntax.html"&gt;What Are Good Qualities of Computer Language Syntax?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/math/function_and_operators.html"&gt;What's Function, What's Operator?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/comp/comp_lang_unicode.html"&gt;Problems of Symbol Congestion in Computer Languages; ASCII Jam vs Unicode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/comp/strings_syntax_in_lang.html"&gt;Computer Language Design: String Syntax&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/cmaci/notation/TeX_pestilence.html"&gt;The TeX Pestilence (the problems of TeX/LaTeX)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/mswin/autohotkey_problems.html"&gt;Windows Programing: AutoHotkey Syntax Problems&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/UnixResource_dir/writ/hard-wrap.html"&gt;Programing: the Harm of Hard-wrapping Lines&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/UnixResource_dir/writ/tabs_vs_spaces.html"&gt;Computer Programing: Tabs vs Spaces in Source Code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/vCuQSGheIRc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/1439123885269780325/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/programing-language-design-syntax-sugar.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1439123885269780325?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1439123885269780325?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/vCuQSGheIRc/programing-language-design-syntax-sugar.html" title="Programing Language Design: Syntax Sugar Problem: Irregularity vs Convenience" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/programing-language-design-syntax-sugar.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEIMQHk-eyp7ImA9WhBbEkw.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-8215058707345703673</id><published>2013-05-10T13:09:00.003-07:00</published><updated>2013-05-10T13:09:41.753-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-10T13:09:41.753-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>Emacs: How Do You Insert Current Date?</title><content type="html">
&lt;p&gt;here's how i do it.&lt;/p&gt;

&lt;pre class="elisp"&gt;
(&lt;span class="keyword"&gt;defun&lt;/span&gt; &lt;span class="function-name"&gt;insert-date&lt;/span&gt; (&lt;span class="type"&gt;&amp;amp;optional&lt;/span&gt; addTimeStamp-p)
  &lt;span class="doc"&gt;"Insert current date and or time.

• In this format yyyy-mm-dd.
• When called with `&lt;/span&gt;&lt;span class="constant"&gt;&lt;span class="doc"&gt;universal-argument&lt;/span&gt;&lt;/span&gt;&lt;span class="doc"&gt;', insert date and time, e.g. 2012-05-28T07:06:23-07:00
• Replaces text selection.

See also `&lt;/span&gt;&lt;span class="constant"&gt;&lt;span class="doc"&gt;current-date-time-string&lt;/span&gt;&lt;/span&gt;&lt;span class="doc"&gt;'."&lt;/span&gt;
  (interactive &lt;span class="string"&gt;"P"&lt;/span&gt;)
  (&lt;span class="keyword"&gt;when&lt;/span&gt; (region-active-p) (delete-region (region-beginning) (region-end) ) )
  (&lt;span class="keyword"&gt;cond&lt;/span&gt;
   ((equal addTimeStamp-p nil ) (insert (format-time-string &lt;span class="string"&gt;"%Y-%m-%d"&lt;/span&gt;)))
   (t (insert (current-date-time-string))) ) )

(&lt;span class="keyword"&gt;defun&lt;/span&gt; &lt;span class="function-name"&gt;current-date-time-string&lt;/span&gt; ()
  &lt;span class="doc"&gt;"Returns current date-time string in full ISO 8601 format.
Example: 「2012-04-05T21:08:24-07:00」.

Note, for the time zone offset, both the formats 「hhmm」 and 「hh:mm」 are valid ISO 8601. However, Atom Webfeed spec seems to require 「hh:mm」."&lt;/span&gt;
  (concat
   (format-time-string &lt;span class="string"&gt;"%Y-%m-%dT%T"&lt;/span&gt;)
   ((&lt;span class="keyword"&gt;lambda&lt;/span&gt; (ξx) (format &lt;span class="string"&gt;"%s:%s"&lt;/span&gt; (substring ξx 0 3) (substring ξx 3 5))) (format-time-string &lt;span class="string"&gt;"%z"&lt;/span&gt;)) )
  )
&lt;/pre&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/N55ouRWfRVM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/8215058707345703673/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/emacs-how-do-you-insert-current-date.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/8215058707345703673?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/8215058707345703673?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/N55ouRWfRVM/emacs-how-do-you-insert-current-date.html" title="Emacs: How Do You Insert Current Date?" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/emacs-how-do-you-insert-current-date.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8BQno7cCp7ImA9WhBbEUo.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-478598012542217884</id><published>2013-05-10T02:40:00.002-07:00</published><updated>2013-05-10T02:40:53.408-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-10T02:40:53.408-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>emacs: xah-html-mode, improved xhm-make-citation</title><content type="html">

&lt;p&gt;much improved “xhm-make-citation”. Now, the order of lines for {title, url, author, date} doesn't matter. Get it in &lt;a href="http://ergoemacs.org/emacs/xah-html-mode.html"&gt;Emacs: Xah HTML Mode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;to learn how to write it, see &lt;a href="http://ergoemacs.org/emacs/elisp_make-citation.html"&gt;Emacs Lisp: Writing a make-citation Command&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/YOgwYVIexGY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/478598012542217884/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/emacs-xah-html-mode-improved-xhm-make.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/478598012542217884?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/478598012542217884?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/YOgwYVIexGY/emacs-xah-html-mode-improved-xhm-make.html" title="emacs: xah-html-mode, improved xhm-make-citation" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/emacs-xah-html-mode-improved-xhm-make.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcNSHs4fyp7ImA9WhBbEUo.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-7349713550145119820</id><published>2013-05-09T23:50:00.003-07:00</published><updated>2013-05-10T01:54:59.537-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-10T01:54:59.537-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="keyboarding" /><title>keyboard: one thousand function keys</title><content type="html">

&lt;p&gt;A new function keys keyboard manufacture. See: &lt;a class="sorc" href="http://www.access-is.com/custom_keyboards.php" data-accessed="2013-05-09"&gt;http://www.access-is.com/custom_keyboards.php&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;that's nice if you are the master of function keys. See also:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/kbd/keyboard_one_thousand_function_keys.html"&gt;Keyboard Master: One Thousand Function Keys&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/kbd/keyboard_function_keys.html"&gt;Computer Keyboard: Increase Productivity Using Function Keys&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/comp/keyboard_shortcut_design.html"&gt;Keyboard Shortcut Design: Dedicated keys, Special Buttons, Extra Keys&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ergoemacs.org/emacs/gnu_emacs_keybinding.html"&gt;A Curious Look at GNU Emacs's 1000+ Default Keybinding&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;thx to &lt;a class="sorc" href="https://www.facebook.com/david.rogoff" data-accessed="2013-05-09"&gt;David Rogoff&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/6nLsq_PREoE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/7349713550145119820/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/keyboard-one-thousand-function-keys.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/7349713550145119820?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/7349713550145119820?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/6nLsq_PREoE/keyboard-one-thousand-function-keys.html" title="keyboard: one thousand function keys" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/keyboard-one-thousand-function-keys.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4NSHszeCp7ImA9WhBbEUs.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-2327786534990761357</id><published>2013-05-09T23:15:00.000-07:00</published><updated>2013-05-09T23:23:19.580-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-09T23:23:19.580-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linguistics" /><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>Logic Write Style: the Incongruousness of the Word “Actually”</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://wordyenglish.com/lit/the_word_actually.html"&gt;http://wordyenglish.com/lit/the_word_actually.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's the inline doc of “assoc” from GNU Emacs 24.3.1:&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre&gt;
assoc is a built-in function in `C source code'.

(assoc KEY LIST)

Return non-nil if KEY is `equal' to the car of an element of LIST.
The value is &lt;mark&gt;actually&lt;/mark&gt; the first element of LIST whose car equals KEY.
&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;note the word “actually”.&lt;/p&gt;

&lt;p&gt;the word “actually” is often used for emphasis purposes. It means “in fact”. It came from “actual” + “ly”.&lt;/p&gt;

&lt;p&gt;&lt;span class="cδe"&gt;&lt;a href="http://www.etymonline.com/index.php?search=actually"&gt;actually&lt;/a&gt;&lt;/span&gt; «early 15c., “in fact, in reality” (as opposed to in possibility), from actual + -ly (2). Meaning “actively, vigorously” is from mid-15c.; that of “at this time, at present” is from 1660s. As an intensive added to a statement and suggesting “as a matter of fact, really, in truth” it is attested from 1762.»&lt;/p&gt;

&lt;p&gt;when writing in a logical style, the use of “actually” is a oddity, incongruous, or redundant.&lt;/p&gt;

&lt;div class="rltd"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://wordyenglish.com/lit/1_2_and_3.html"&gt;On the Postposition of Conjunction in Penultimate Position of a Sequence&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://wordyenglish.com/lit/plurality.html"&gt;Plurality in English Grammar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://wordyenglish.com/lit/writing_style_logic_and_phraseme.html"&gt;Writing Style: Logic vs Phraseme&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://wordyenglish.com/lit/article.html"&gt;The Meddling of English Article with Meaning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://wordyenglish.com/lit/active_voice_passive_voice.html"&gt;What's Passive Voice? What's Aggressive Voice?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/mmOiBCnFIqI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/2327786534990761357/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/logic-write-style-incongruousness-of.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/2327786534990761357?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/2327786534990761357?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/mmOiBCnFIqI/logic-write-style-incongruousness-of.html" title="Logic Write Style: the Incongruousness of the Word “Actually”" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/logic-write-style-incongruousness-of.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8DR3wzfSp7ImA9WhBbEUk.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-8546696022932048237</id><published>2013-05-09T16:57:00.003-07:00</published><updated>2013-05-09T16:57:56.285-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-09T16:57:56.285-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Linux: Convert HTML to PDF</title><content type="html">
&lt;p&gt;to convert HTML to PDF on Linux, you can use &lt;code&gt;wkhtmltopdf&lt;/code&gt;. It's based on webkit, the web browser engine used by Safari an Google Chrome.&lt;/p&gt;

&lt;pre class="bash"&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;install
&lt;/span&gt;sudo apt-get install wkhtmltopdf&lt;/pre&gt;

&lt;pre class="bash"&gt;wkhtmltopdf my_resume.html my_resume.pdf&lt;/pre&gt;

&lt;p&gt;if you just have one single file, you can also use &lt;code&gt;libreoffice&lt;/code&gt;.&lt;/p&gt;

&lt;pre class="bash"&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;install libreoffice
&lt;/span&gt;sudo apt-get install libreoffice&lt;/pre&gt;

&lt;p&gt;Type &lt;code&gt;libreoffice&lt;/code&gt; to start it, then, open the HTML file, then use menu 〖File ▸ Export…〗.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/fhSg31I9t94" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/8546696022932048237/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/linux-convert-html-to-pdf.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/8546696022932048237?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/8546696022932048237?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/fhSg31I9t94/linux-convert-html-to-pdf.html" title="Linux: Convert HTML to PDF" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/linux-convert-html-to-pdf.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEUNQnY8eCp7ImA9WhBbEE4.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-1103257691986222188</id><published>2013-05-08T09:58:00.001-07:00</published><updated>2013-05-08T09:58:13.870-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-08T09:58:13.870-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>video: Emacs, Shell, Abbrev, and ELISP Power to Bear!</title><content type="html">
&lt;p&gt;here's a video version of today tutorial.&lt;/p&gt;

&lt;figure&gt;
&lt;iframe title="YouTube video player" class="youtube-player" width="640" height="385" src="http://www.youtube.com/embed/oKS_iIoQ0A4?rel=0"&gt;&lt;/iframe&gt;
&lt;figcaption&gt;Emacs, Shell, Abbrev, and ELISP Power to Bear!&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;code at &lt;a href="emacs_abbrev_shell_elisp.html"&gt;Emacs, Shell, Abbrev, and ELISP Power to Bear!&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/SY3uqTuVVDY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/1103257691986222188/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/video-emacs-shell-abbrev-and-elisp.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1103257691986222188?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1103257691986222188?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/SY3uqTuVVDY/video-emacs-shell-abbrev-and-elisp.html" title="video: Emacs, Shell, Abbrev, and ELISP Power to Bear!" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/oKS_iIoQ0A4/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/video-emacs-shell-abbrev-and-elisp.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUANQHk7eSp7ImA9WhBbEE8.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-1160514242090183441</id><published>2013-05-08T07:36:00.003-07:00</published><updated>2013-05-08T07:36:31.701-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-08T07:36:31.701-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="lisp" /><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>Emacs, Shell, Abbrev, and ELISP Power to Bear!</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://ergoemacs.org/misc/emacs_abbrev_shell_elisp.html"&gt;http://ergoemacs.org/misc/emacs_abbrev_shell_elisp.html&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Using Abbrev for Shell Commands&lt;/h2&gt;

&lt;p&gt;You can define abbrev for frequently used shell commands. For example, i type “3rs” and it expands to&lt;/p&gt;

&lt;pre class="bash"&gt;rsync -z -r -v -t --chmod=Dugo+x --chmod=ugo+r --delete --exclude='*~' --exclude='.bash_history' --exclude='logs/'  --rsh='ssh -l u89150' ~/web/ u89150@s72750.example.com:~/&lt;/pre&gt;

&lt;p class="q"&gt;Is emacs abbrev better than bash alias?&lt;/p&gt;
&lt;div class="a"&gt;
&lt;p&gt;Emacs abbrev is better than bash alias, because you see the full command.&lt;/p&gt;
&lt;/div&gt;

&lt;p class="q"&gt;what about using shell 【&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt;】 back search feature?&lt;/p&gt;
&lt;div class="a"&gt;
&lt;p&gt;That's great, but for frequently used command, alias or abbrev is better, because you get EXACTLY the command you want.&lt;/p&gt;

&lt;p&gt;With back search, you might have modified a command, and you have to eye-ball to be sure it's the command you want. Bash alias or emacs abbrev are muscle memory.&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;for how to set abbrev, see: &lt;a href="http://ergoemacs.org/emacs/emacs_abbrev_mode.html"&gt;Using Emacs Abbrev Mode for Abbreviation&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Advantage of Using Shell Inside Emacs&lt;/h2&gt;

&lt;p&gt;using shell inside emacs is much superior than using a terminal. You have all lines logged by default, can be saved if you want, anytime. You can edit or copy/paste easily any past lines. And you have full power of emacs to edit any line, or jump into any file path (&lt;code class="elisp-ƒ"&gt;ffap&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;for how to use shell inside emacs, see &lt;a href="http://ergoemacs.org/emacs/emacs_unix.html"&gt;Emacs Shell Tutorial (Bash, cmd.exe, PowerShell)&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Elisp Power Come to Bear&lt;/h2&gt;

&lt;p&gt;now, for the more advanced and esoteric emacs users.&lt;/p&gt;

&lt;p&gt;What's even better, is elisp.&lt;/p&gt;

&lt;p&gt;I have many shell command abbrevs. For example:&lt;/p&gt;

&lt;pre class="elisp"&gt;
&lt;span class="comment-delimiter"&gt;;; &lt;/span&gt;&lt;span class="comment"&gt;shell commands
&lt;/span&gt;(&lt;span class="string"&gt;"3ditto"&lt;/span&gt; &lt;span class="string"&gt;"ditto -ck --sequesterRsrc --keepParent src dest"&lt;/span&gt;)
(&lt;span class="string"&gt;"3im"&lt;/span&gt; &lt;span class="string"&gt;"convert -quality 85% "&lt;/span&gt;)
(&lt;span class="string"&gt;"3ims"&lt;/span&gt; &lt;span class="string"&gt;"convert -size  -quality 85% "&lt;/span&gt;)
(&lt;span class="string"&gt;"3im256"&lt;/span&gt; &lt;span class="string"&gt;"convert +dither -colors 256 "&lt;/span&gt;)
(&lt;span class="string"&gt;"3imf"&lt;/span&gt; &lt;span class="string"&gt;"find . -name \"*png\" | xargs -l -i basename \"{}\" \".png\" | xargs -l -i  convert -quality 85% \"{}.png\" \"{}.jpg\""&lt;/span&gt;)

(&lt;span class="string"&gt;"3f0"&lt;/span&gt; &lt;span class="string"&gt;"find . -type f -empty"&lt;/span&gt;)
(&lt;span class="string"&gt;"3f00"&lt;/span&gt; &lt;span class="string"&gt;"find . -type f -size 0 -exec rm {} ';'"&lt;/span&gt;)
(&lt;span class="string"&gt;"3chmod"&lt;/span&gt; &lt;span class="string"&gt;"find . -type f -exec chmod 644 {} ';'"&lt;/span&gt;)
(&lt;span class="string"&gt;"3chmod2"&lt;/span&gt; &lt;span class="string"&gt;"find . -type d -exec chmod 755 {} ';'"&lt;/span&gt;)

(&lt;span class="string"&gt;"3unison"&lt;/span&gt; &lt;span class="string"&gt;"unison -servercmd /usr/bin/unison c:/Users/xah/web ssh://xah@example.com//Users/xah/web"&lt;/span&gt;)
(&lt;span class="string"&gt;"3sftp"&lt;/span&gt; &lt;span class="string"&gt;"sftp xah@xahlee.org"&lt;/span&gt;)
(&lt;span class="string"&gt;"3ssh"&lt;/span&gt; &lt;span class="string"&gt;"ssh xah@xahlee.org"&lt;/span&gt;)
(&lt;span class="string"&gt;"3rsync"&lt;/span&gt; &lt;span class="string"&gt;"rsync -z -r -v -t --exclude=\"*~\" --exclude=\".DS_Store\" --exclude=\".bash_history\" --exclude=\"**/xx_xahlee_info/*\"  --exclude=\"*/_curves_robert_yates/*.png\" --exclude=\"logs/*\"  --exclude=\"xlogs/*\" --delete --rsh=\"ssh -l xah\" ~/web/ xah@example.com:~/"&lt;/span&gt;)

(&lt;span class="string"&gt;"3rsync2"&lt;/span&gt; &lt;span class="string"&gt;"rsync -r -v -t --delete --rsh=\"ssh -l xah\" ~/web/ xah@example.com:~/web/"&lt;/span&gt;)
(&lt;span class="string"&gt;"3rsync3"&lt;/span&gt; &lt;span class="string"&gt;"rsync -r -v -t --delete --exclude=\"**/My *\" --rsh=\"ssh -l xah\" ~/Documents/ xah@example.com:~/Documents/"&lt;/span&gt;)
&lt;/pre&gt;

&lt;p&gt;the problem is, some of them are not frequently used, and i forgot what is the abbrev. For example, i have many command that convert image in various ways. They starts with “3im”. But i forgot the one i wanted. So, i have to open my abbrev file to see.
〔☛ &lt;a href="http://ergoemacs.org/emacs/bookmark.html"&gt;Using Emacs's Bookmark Feature&lt;/a&gt;〕
&lt;/p&gt;

&lt;p&gt;would it be great, if all your abbrevs has a ido-like interface? so that you can see them as you type?
〔☛ &lt;a href="http://ergoemacs.org/emacs/emacs_iswitch_vs_ido.html"&gt;Emacs: iswitch vs ido mode&lt;/a&gt;〕
〔☛ &lt;a href="http://ergoemacs.org/emacs/emacs_name_completion.html"&gt;Emacs: Name Completion Features ＆ Packages&lt;/a&gt;〕
〔☛ &lt;a href="http://ergoemacs.org/emacs/emacs_buffer_management.html"&gt;Emacs: List/Switch Buffers&lt;/a&gt;〕
&lt;/p&gt;

&lt;p&gt;So, now i wrote a  command, like this:&lt;/p&gt;

&lt;pre class="elisp"&gt;
(&lt;span class="keyword"&gt;defcustom&lt;/span&gt; &lt;span class="variable-name"&gt;xah-shell-abbrev-alist&lt;/span&gt; nil &lt;span class="doc"&gt;"alist of xah's shell abbrevs"&lt;/span&gt;)
(setq xah-shell-abbrev-alist
          '(
            (&lt;span class="string"&gt;"rsync1"&lt;/span&gt; . &lt;span class="string"&gt;"rsync -z -r -v -t --chmod=Dugo+x --chmod=ugo+r --delete --exclude='*~' --exclude='.bash_history' --exclude='logs/'  --rsh='ssh -l u80781' ~/web/ u80781@s30097.example.com:~/"&lt;/span&gt;)

            (&lt;span class="string"&gt;"ssh"&lt;/span&gt; . &lt;span class="string"&gt;"ssh -l u80781 xahlee.org "&lt;/span&gt;)
            (&lt;span class="string"&gt;"img1"&lt;/span&gt; . &lt;span class="string"&gt;"convert -quality 85% "&lt;/span&gt;)
            (&lt;span class="string"&gt;"imgScale"&lt;/span&gt; . &lt;span class="string"&gt;"convert -scale 50% -quality 85% "&lt;/span&gt;)
            (&lt;span class="string"&gt;"img256"&lt;/span&gt; . &lt;span class="string"&gt;"convert +dither -colors 256 "&lt;/span&gt;)
            (&lt;span class="string"&gt;"imgBatch"&lt;/span&gt; . &lt;span class="string"&gt;"find . -name \"*png\" | xargs -l -i basename \"{}\" \".png\" | xargs -l -i  convert -quality 85% \"{}.png\" \"{}.jpg\""&lt;/span&gt;)
            (&lt;span class="string"&gt;"img-bmp2png"&lt;/span&gt; . &lt;span class="string"&gt;"find . -name \"*bmp\" | xargs -l -i basename \"{}\" \".bmp\" | xargs -l -i  convert \"{}.bmp\" \"{}.png\""&lt;/span&gt;)

            (&lt;span class="string"&gt;"grep"&lt;/span&gt; . &lt;span class="string"&gt;"grep -r -F 'xxx' --include='*html' ~/web"&lt;/span&gt;)

            (&lt;span class="string"&gt;"rm_empty"&lt;/span&gt; . &lt;span class="string"&gt;"find . -type f -empty"&lt;/span&gt;)
            (&lt;span class="string"&gt;"chmod_file"&lt;/span&gt; . &lt;span class="string"&gt;"find . -type f -exec chmod 644 {} ';'"&lt;/span&gt;)
            (&lt;span class="string"&gt;"rm~"&lt;/span&gt; . &lt;span class="string"&gt;"find . -name \"*~\" -exec rm {} ';'"&lt;/span&gt;)
            (&lt;span class="string"&gt;"findEmptyDir"&lt;/span&gt; . &lt;span class="string"&gt;"find . -depth -empty -type d"&lt;/span&gt;)
            (&lt;span class="string"&gt;"rmEmptyDir"&lt;/span&gt; . &lt;span class="string"&gt;"find . -depth -empty -type d -exec rmdir {} ';'"&lt;/span&gt;)
            (&lt;span class="string"&gt;"chmod2"&lt;/span&gt; . &lt;span class="string"&gt;"find . -type d -exec chmod 755 {} ';'"&lt;/span&gt;)
            (&lt;span class="string"&gt;"lynx"&lt;/span&gt; . &lt;span class="string"&gt;"lynx -dump -assume_local_charset=utf-8 -display_charset=utf-8 -width=100"&lt;/span&gt;)
            (&lt;span class="string"&gt;"vp"&lt;/span&gt; . &lt;span class="string"&gt;"feh --randomize --recursive --auto-zoom --action \"gvfs-trash '%f'\" --geometry 1600x1000 ~/Pictures/cinse_pixra3/ &amp;amp;"&lt;/span&gt;)
            )

          )

(&lt;span class="keyword"&gt;defun&lt;/span&gt; &lt;span class="function-name"&gt;xah-shell-commands&lt;/span&gt; (cmdAbbrev)
  &lt;span class="doc"&gt;"insert shell command from a selection prompt."&lt;/span&gt;
  (interactive
   (list
      (ido-completing-read &lt;span class="string"&gt;"shell abbrevs:"&lt;/span&gt; (mapcar (&lt;span class="keyword"&gt;lambda&lt;/span&gt; (x) (car x)) xah-shell-abbrev-alist) &lt;span class="string"&gt;"PREDICATE"&lt;/span&gt; &lt;span class="string"&gt;"REQUIRE-MATCH"&lt;/span&gt;) ) )
  (&lt;span class="keyword"&gt;progn&lt;/span&gt;
    (insert (cdr (assoc cmdAbbrev xah-shell-abbrev-alist)))
    ))
&lt;/pre&gt;

&lt;p&gt;i give a easy key for this command. When i need a shell command, i press a key, ido comes up showing me all the abbrevs. Then, i type 2 or more keys and press &lt;kbd&gt;Enter ↵&lt;/kbd&gt; and my command is inserted. Nice!&lt;/p&gt;

&lt;p&gt;be warned, that this will take some used to. Like keybinding, you have to kick habit, and that may not be easy.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/l6U4ZYfhw1U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/1160514242090183441/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/emacs-shell-abbrev-and-elisp-power-to.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1160514242090183441?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/1160514242090183441?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/l6U4ZYfhw1U/emacs-shell-abbrev-and-elisp-power-to.html" title="Emacs, Shell, Abbrev, and ELISP Power to Bear!" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/emacs-shell-abbrev-and-elisp-power-to.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcHRHY6cCp7ImA9WhBUGU8.&quot;"><id>tag:blogger.com,1999:blog-33528550.post-6764925605065763971</id><published>2013-05-07T04:59:00.002-07:00</published><updated>2013-05-07T05:00:35.818-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-07T05:00:35.818-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programing" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>unix linux shell uniq unicode bug</title><content type="html">

&lt;p&gt;Perm URL with updates: &lt;a href="http://xahlee.info/comp/unix_uniq_unicode_bug.html"&gt;http://xahlee.info/comp/unix_uniq_unicode_bug.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a bug of unix/linux GNU shellutil &lt;code&gt;uniq&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Create a file of the following text:&lt;/p&gt;

&lt;pre class="code"&gt;
═
═
═
║
║
║
╒
╓
╔
╕
╖
╗
╘
╙
╚
╛
╜
╝
╞
╟
╠
╡
╢
╣
╤
╥
╦
╧
╨
╩
╪
╫
╬&lt;/pre&gt;

&lt;p&gt;save it as 〔unicode.txt〕, then do &lt;code&gt;cat unicode.txt | unicq -c&lt;/code&gt;. You get “33 ═”. Idiotic unix.&lt;/p&gt;

&lt;pre class="bash-output"&gt;◆ uniq --version
uniq (GNU coreutils) 8.13
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Richard M. Stallman and David MacKenzie.&lt;/pre&gt;

&lt;p&gt;The man page doesn't mention anything about Unicode. Here's my locale setting anyhow.&lt;/p&gt;

&lt;pre class="bash-output"&gt;◆ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=&lt;/pre&gt;

&lt;p&gt;i think, since about 2005, unix utils are in frenzed patch trying to be Unicode compatible. It looks like, the state is still shi�tty.&lt;/p&gt;

&lt;p&gt;A related problem is grep.
〔☛ &lt;a href="http://ergoemacs.org/emacs/emacs_grep_problem.html"&gt;Problems of Calling Unix grep in Emacs&lt;/a&gt;〕
I thought the problem is between the complexity of emacs+cygwin+layer+environment variable. But now i know, it's unix!&lt;/p&gt;

&lt;p&gt;am not sure how many unix utils still have Unicode problem.&lt;/p&gt;

&lt;p&gt;see also: &lt;a href="http://xahlee.info/comp/complexity_software_engineering.html"&gt;Complexity ＆ Tedium of Software Engineering&lt;/a&gt;&lt;/p&gt;

&lt;div class="rltd"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/comp/unix_tar_problem.html"&gt;UNIX Tar Problem: File Length Truncation, Unicode Name Support&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xahlee.info/mswin/unicode_support_file_names.html"&gt;Unicode Support in File Names: Windows, Mac, Emacs, Unison, Rsync, USB, Zip&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/XahLeeAtBlogger/~4/KJQDkAwIWgY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://xahlee.blogspot.com/feeds/6764925605065763971/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://xahlee.blogspot.com/2013/05/unix-linux-shell-uniq-unicode-bug.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/6764925605065763971?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33528550/posts/default/6764925605065763971?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/XahLeeAtBlogger/~3/KJQDkAwIWgY/unix-linux-shell-uniq-unicode-bug.html" title="unix linux shell uniq unicode bug" /><author><name>Xah Lee</name><uri>https://plus.google.com/112757647855302148298</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-pUm2--nei1Y/AAAAAAAAAAI/AAAAAAAAY-o/aK-sxWd8mGs/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://xahlee.blogspot.com/2013/05/unix-linux-shell-uniq-unicode-bug.html</feedburner:origLink></entry></feed>
