Profile

Cover photo
1,619 followers|1,172,079 views
AboutPostsPhotosVideos

Stream

ErgoEmacs

Shared publicly  - 
 
 
why you shouldn't use dotimes and cons. Guy Steele on Parallel Programing: Get rid of cons! http://xahlee.info/comp/Guy_Steele_parallel_computing.html #lisp
1
Add a comment...

ErgoEmacs

Discussion  - 
 
#emacs 
Here's some very useful commands i now and then hear people surprised by. 
apologies if i posted this before. 

• list-matching-lines (this is a alias to occur)
• delete-matching-lines (this is a alias to flush-lines)
• delete-non-matching-lines (this is a alias to keep-lines)
• delete-duplicate-lines (Emacs 24.4) delete duplicated lines in text selection.

• sort-lines
• sort-numeric-fields
• reverse-region

• highlight-lines-matching-regexp

List/Delete/Highlight Matching Lines, Sort/Reverse Lines 
http://ergoemacs.org/emacs/elisp_list_matching_lines.html
3
Add a comment...

ErgoEmacs

Tutorials  - 
 
#emacs #lisp  
Here's a emacs lisp command that deletes the current file.

(defun xah-delete-current-file (&optional φno-backup-p)
  "Delete the file associated with the current buffer.

Also close the current buffer.  If no file is associated, just close buffer.

A backup file is created with filename appended “~‹date time stamp›~”. Existing file of the same name is overwritten. If the file is not associated with buffer, the backup file name starts with “xx_”.

When called with `universal-argument', don't create backup."
  (interactive "P")
  (let* (
         (fName (buffer-file-name))
         (bufferIsFile-p (if (null fName) nil t ))
         (backupName (concat fName "~" (format-time-string "%Y%m%d_%H%M%S") "~")))
    (if bufferIsFile-p
        (progn
          (save-buffer fName)
          (if φno-backup-p
              nil
            (copy-file fName backupName t))
          (delete-file fName)
          (message "deleted and backup created at 「%s」." backupName))
      (progn
        (if φno-backup-p
            nil
          (write-region (point-min) (point-max) (concat "xx_~" (format-time-string "%Y%m%d_%H%M%S") "~")))))
    (kill-buffer (current-buffer))))

perm url
 http://ergoemacs.org/emacs/elisp_delete-current-file.html
2
Yuriy Pitometsu's profile photoErgoEmacs's profile photo
6 comments
 
+ErgoEmacs you right, thanks for correction.
Add a comment...

ErgoEmacs

Shared publicly  - 
 
the JavaScript dom event has a event.metaKey!
https://developer.mozilla.org/en-US/docs/Web/API/event.metaKey

this is back in 1997ish, when Sun Microsystems is still around with Sun Station and Sun Microsystems Type 6 Keyboard
http://xahlee.info/kbd/sun_microsystems_keyboard.html
is stil around.

it has a diamond ◆ key, and that key is officially called Meta.

linux developed to name that key Super instead.
2
1
Xah Lee's profile photoMoe Bius's profile photoErgoEmacs's profile photo
2 comments
 
+Moe Bius the Cmd key on Apple keyboard and Window key on Microsoft keyboard both send the same scancode, at least on the usb ones. I think probably so for the Meta ◆ key on Sun type 6 too.

linux just call the Window key as Super.

The Meta, Super, Hyper, are dedicated hardware keys on the lisp machine keyboards.
http://xahlee.info/kbd/lisp_keyboards.html
Add a comment...

ErgoEmacs

Shared publicly  - 
 
 
someone must have posted about my Truly Ergonomic Keyboard page somewhere, because, am getting several emails about the keyboard.

i don't know where yet, probably one of those reddit/geekhack/deskthority. gonna find out.
3
1
Steffen Glückselig's profile photo
Add a comment...

ErgoEmacs

Shared publicly  - 
 
emacs: ergoemacs-mode link change

ergoemacs-mode news, from +Matthew Fidler . Link is changed

https://ergoemacs.github.io/ergoemacs-mode/   ← old
https://ergoemacs.github.io/           ← new

the change is made because: before, when you check out, you get some 100 mega bytes of stuff, which includes the ergoemacs-mode website and all the images about layout.

now, the code and home page are separate github projects.

    ergoemacs-mode package: https://github.com/ergoemacs/ergoemacs-mode

    ergoemacs-mode home page: https://ergoemacs.github.io/

    ergoemacs-mode home page source code: https://github.com/ergoemacs/ergoemacs.github.io

be sure to update your links.

there's automatic redirect. But some link with specific URL may break, Matt is fixing them. Thanks Matt.
4
Add a comment...
In their circles
1,348 people
Have them in circles
1,619 people
蒋维's profile photo
Hongqing Hu's profile photo
Kai Zhang's profile photo
Chris McDevitt's profile photo
Mira HÉDL's profile photo
Yoshifumi Hosoya's profile photo
Anubhav Singh's profile photo

ErgoEmacs

Shared publicly  - 
 
emacs lisp: twitterfy-shorten text

(defun xah-twitterfy ()
  "shorten words for twitter."
  (interactive)
  (let* ((bds (get-selection-or-unit 'block))
         (p1 (elt bds 1))
         (p2 (elt bds 2)))
    (replace-pairs-region p1 p2 '(
                                  [" are " " r "]
                                  [" you " " u "]
                                  [" and " " & "]
                                  [", " ","]
                                  ["..." "…"]
                                  [". " "。"]
                                  ["。 " "。"]
                                  ))))

Xah Emacs Blog
http://ergoemacs.org/emacs/blog.html
1
Dan Lentz's profile photoErgoEmacs's profile photo
23 comments
 
Ive considered picking up a license for M.  I may.  The issue is that I have a lot of Clojure work on my plate and my first priority is getting good at that.  Actually, the language I'm second most interested in is Swift so I could write iPad apps (since I already have some familiarity with Scala)  But I will do as I can to work on this macro issue with you until you see the light. :)

BTW, I think it would be more practical for you to learn Clojure, and its macro system is almost identical to CL, just a bit simplified.
Add a comment...

ErgoEmacs

Discussion  - 
 
emacs: How to filter elements from a list?
emacs lisp doesn't have a filter/grep function for list.
you can use the cl-remove-if or cl-remove-if-not in CL library, like this:

(require 'cl)
(cl-remove-if-not 'numberp  '(1 "a" 2)) ;; (1 2)

(emacs 24.x changed the name remove-if to cl-remove-if)

or, you can write your own:

(defun xah-filter-list (φpredicate φlist)
  "Return a new list such that φpredicate is true on all members of φlist.
This function is similar to perl's “grep” or other lang's “filter” function."
  (let ((ξresult '()))
    (mapc
     (lambda (ξx)
       (when (funcall φpredicate ξx) (setq ξresult (cons ξx ξresult))))
     φlist)
    (reverse ξresult)))

Emacs Lisp: Filter a List
http://ergoemacs.org/emacs/elisp_filter_list.html
2
Randy Morris's profile photoAlex Bennée's profile photoErgoEmacs's profile photoArtur Malabarba's profile photo
10 comments
 
+Randy Morris well that's surprising. Last time I clicked on renaming they specifically warned me they do not setup redirects.
Add a comment...

ErgoEmacs

Packages  - 
 
ergoemacs-mode is now in GNU ELPA http://elpa.gnu.org/packages/ergoemacs-mode.html
5
1
Fabrizio Guzzetta's profile photo
Add a comment...

ErgoEmacs

Questions  - 
 
in magit-mode, magit-status, pressing tab on a file will show diff. Is there a way to collapse it again (or collapse all) without having to move cursor on the file?

#emacs
 
1
Jan Synáček's profile photoAlexander Yakushev's profile photoErgoEmacs's profile photoTom Willemse's profile photo
6 comments
 
You can also press ^ followed by TAB. It doesn't directly answer your question, but I think that making a function that calls the two (their functions respectively) and binding it should do the job.
Add a comment...

ErgoEmacs

Shared publicly  - 
3
Dan Lentz's profile photoMoe Bius's profile photoEpo Jemba's profile photo
6 comments
 
Oh, ok I got it. But if you found that interesting, do look up prog in CLHS or (better) CLTL2. It is a form of control flow operator not used as often anymore but at one point very popular. The implicit tagbody provides a means of nonlinear control-flow not unlike the idea of "continuations" in languages which support them. You might think of it as a state-machine of sorts.
Add a comment...

ErgoEmacs

Shared publicly  - 
 
 
the js lang, because it doesn't have name space and because the way it is used on the web, there arises a style where all js code tries to minimize the number of exposed names.

for example, in jquery or any js lib, they only export one single name. (in jquery, that's $() or jquery().) All the rest of vars or function names used by the lib is made to be a property of that single exported name.

this is interesting. In emacs lisp, it suffer the same problem of no namespace. However, the conventional solution is simply to attach a prefix to all names. e.g. suppose i have a lib called xah-fly-keys. All var and function names in that lib will start with xah-.

but emacs lisp also supports function properties, or hash table, or list... the bottom line is that, it's also possible in elisp, to make it so that one package just export one single name.

i haven't looked further. Is this easy to do? anyone seen this idea done?
3
Yuri Khan's profile photoMoe Bius's profile photoErgoEmacs's profile photo
4 comments
 
+Yuri Khan
This post drives home just how shallow my elisp knowledge is  :(
Add a comment...
People
In their circles
1,348 people
Have them in circles
1,619 people
蒋维's profile photo
Hongqing Hu's profile photo
Kai Zhang's profile photo
Chris McDevitt's profile photo
Mira HÉDL's profile photo
Yoshifumi Hosoya's profile photo
Anubhav Singh's profile photo
Contact Information
Contact info
Email
Story
Tagline
Emacs tips & tricks + ErgoEmacs news.
Introduction
One or two emacs tips per day.

• Tips in using emacs
• Tips in coding emacs lisp.
• Occasional news/tips about ErgoEmacs.

Spread emacs. Join us.