Stream

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
1
Add a comment...

zhu aihui

Questions  - 
 
I am run emacs as daemon by "emacs -daemon"
and then run emasclicent with custom shell script named ecli like this
"
#!/usr/bin/sh
process=`ps -ef | grep "emacs --daemon" | wc -l`
if [ $process != "2" ]
then
emacs -nw $@
else
emacsclient -t $@
fi
"
normaly, it work out very nice.

but when i run this script as root through "sudo" ,
it just show me "can't find socket, are you started the server?".
i guess it may be the problem of permission, but i don't know fix it.

Is there someone know?
1
Yuriy Pitometsu's profile photozhu aihui's profile photo
2 comments
 
thanks
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
Moe Bius's profile photoArtur Malabarba's profile photo
8 comments
 
Looks good, but this additional information I found may be significant. I read in Conrad Barski's book that the -if-not functions were deprecated, so I did some web searching.

"X3J13 voted in January 1989 (176) to deprecate the use of :test-not key-word arguments and if-not functions. This means that these features are very likely to be retained in the forthcoming standard but are regarded as candidates for removal in a future revision of the ANSI standard. X3J13 also voted in January 1989 (87) to add the complement function, intended to re-duce or eliminate the need for these deprecated features." -- Common Lisp: The Language, Second Edition, Guy L. Steele Jr. (page 419)


Edited to fix formatting problems associated with copy+pasting.
Add a comment...

zhijia yuan

Questions  - 
 
i posted this question a while ago, got some supports but no answers, hope some one here can help 
http://superuser.com/q/605325/226706
4
1
William Xu's profile photozhijia yuan's profile photo
6 comments
 
one good example that emacs is lack of wyswyw editing support.
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...

Boy Wang

Questions  - 
 
Ch.22 in lisp manual is really hard understanding for me:
What does the values in `lisp-mode-map' stand for?
lisp-mode-map =>
(keymap
 (3 keymap
    (26 . run-lisp))
 (27 keymap
     (24 . lisp-eval-defun))
 keymap
 (127 . backward-delete-char-untabify)
 (27 keymap
     (17 . indent-sexp)))
=================
The manual says `lisp-mode-map' defines bindings for DEL, C-c C-z, C-M-q and C-M-x. So I test their basic types and found it seems to have nothing to do with above types. Would someone explain what does values in `lisp-mode-map' mean?

(event-basic-type ?\C-c) => 99
(event-basic-type ?\C-z) => 122
(event-basic-type ?\C-\M-q) => 113
(event-basic-type ?\C-\M-x) => 120
(event-basic-type 'delete) => delete
1
Left Right's profile photoBoy Wang's profile photo
3 comments
 
Oh no wonder my further test is so confusing. Anyway, at least `string' can give me some human readable results. :D
=== test ===
(string 3) ;; => "^C", = (text-char-description ?\C-c)
(string 26) ;; => "^Z", = (text-char-description ?\C-z)
;; (event-basic-type 3) = (event-basic-type ?c)

(string 27) ;; => "^[", = ESC (meta) character (text-char-description ?\^\[)
(string 24) ;; => "^X", = (text-char-description ?\C-x)

(string 127) ;; => "^?", = DEL character = (text-char-description ?\^?)

(string 27) ;; => "^[", = (text-char-description ?\^\[)
(string 17) ;; => "^Q", = (text-char-description ?\C-q)
Add a comment...
 
I am not a fantastic typist. My speed is acceptable, but I make a great deal of mistakes.
This snippet has turned me into the Messi of keyboards. =)
11
Nuno Salgueiro's profile photoArtur Malabarba's profile photo
2 comments
 
+Nuno Salgueiro in a tunnel under the English channel. But now I wish it were a submarine... :-(
Wonder how many people ever used emacs inside a submarine...
Add a comment...
 
Require Feature or Install Package


3
Boy Wang's profile photo
 
It's very helpful for beginners like me (LOL).
Add a comment...
 
I use ansi-term a bit but one really annoying thing is that I can't get completion to be bound to just <tab>. 
If i type C-M-i i get the same behaviour as in a regular terminal, but I have no idea how to bind this to just <tab>.

This is the code I've been trying out:

(add-hook 'term-mode-hook
          (lambda ()
            (setq yas-dont-activate t)
            (local-set-key (kbd "<tab>") 'completion-at-point-functions)
            ))

This doesn't seem to work, and describe-bindings doesn't give me anything useful.

Btw, I'm not sure of disabling YASnippet is needed, but some StackOverflow question suggested it. (and it doesn't seem to matter).

Any hints much appreciated.
2
Mattias Bengtsson's profile photo
2 comments
 
Ok I got it working:

(add-hook 'term-mode-hook
          (lambda ()
            (define-key term-raw-map   (kbd "<tab>")
              (lookup-key term-raw-map (kbd "C-M-i")))
            (define-key term-raw-map   (kbd "M-x") 'smex)
            ))

:)
Add a comment...

About this community

A community for Emacs lovers. Now you don't have to restrict those emacs posts because your friends and family have no clue what you are talking about!
 
git-gutter v0.68 is out. git-gutter.el supports Mercurial from this version. We can use git-gutter.el for bitbucket products etc.

Please report me via github issues if you have any problems or suggestion.

Thanks.
3
1
William Xu's profile photo
Add a comment...
 
Does proced work for everyone but me? I tried M-x proced, but I just get an empty proced-mode buffer named *Proced*. I'm using http://emacsformacosx.com/:
---
(emacs-version)
_"GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
 of 2013-03-13 on bob.porkrind.org"_

#emacs #processmanagement  
1
Moe Bius's profile photoIngolf Schaefer's profile photo
3 comments
 
I do not know. AFAIK somebody wrote a patch in 2010, but that was never published. The alternative on Mac OS X seems to be this, but I never tried it:

https://github.com/emacsmirror/vkill
Add a comment...
11
2
Adrian Knoth's profile photoHolger Schauer's profile photoMalk Zameth's profile photoYuriy Pitometsu's profile photo
2 comments
 
so beautiful
Add a comment...
 
The little changes are the ones I like the most. :-)
6
1
Alexander Yakushev's profile photoYuriy Pitometsu's profile photoMcKay Marston's profile photo
2 comments
 
Good news! :)
Add a comment...

ErgoEmacs

Packages  - 
 
ergoemacs-mode is now in GNU ELPA http://elpa.gnu.org/packages/ergoemacs-mode.html
4
1
Fabrizio Guzzetta's profile photo
Add a comment...
 
I've just released version 1.3 of the Emacs Documentation Android app. You can:

download it at the Emacs Online Documentation website,
http://doc.endlessparentheses.com/app.html#main_content
or find it at the Play Store (donate version).
https://play.google.com/store/apps/details?id=com.malabarba.emacsdocumentation

This version addresses a previous annoyance in which you'd have to zoom-in every time you open a page (because the mobile pages aren't quite mobile-friendly). This was addressed by implementing a (optional) built-in viewer which remembers your zoom level.

It also implements theme choosing through the settings menu.
3
Add a comment...

faried nawaz

Discussion  - 
 
i found a copy of this in an old email.
3
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 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...
 
Pain with linum mode when running emacs daemon
Lately, I am having trouble with "Invalid face: linum" error ONLY when launching emacs in daemon mode using emacsclient.

That error does not show up when I simply run \emacs&

In my init.el, I have
===== CODE =====
(require 'setup-linum)
===== END =====

 and in setup-linum.el, I have
===== CODE =====
(require 'nlinum)
(setq global-nlinum-mode -1
      nlinum-format      "%4d ") ; right aligned, 4 char wide line num col
;; NOTE: nlinum mode is turned on in the setup files of the desired major modes
(setq setup-linum-loaded t)
(provide 'setup-linum)
===== END =====

If I comment out the (require 'setup-linum) line in my init.el, emacs starts fine in both normal and daemon modes. But if I keep that line, emacs launches fine ONLY in normal mode.

I can't figure out why daemon mode throws the "Invalid face: linum" error. It can be arduous going through someone else's config but if anyone has time and will, please help me out.

init.el: 
https://github.com/kaushalmodi/.emacs.d/blob/master/init.el

setup-linum.el:
https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-linum.el
1
Add a comment...
 
Looks like a bug, what do u think?

Pure Emacs: open some buffer M-s-o for occur
then e for occur-edit-mode, then M-x replace-regexp [ ^I]+ RET SPC RET
;; try to replace excess spaces or tabs by just one space symbol in matched strings

Error in minibuffer => Wrong type argument: markerp, nil
OS X, Emacs 24.3
What do you think about: should I create bug report for this? Or just something doing very wrong? =) Thanks.
1
Nathanael Farley's profile photoArtur Malabarba's profile photo
3 comments
 
Test if it happens with emacs -q
If it does, definitely submit a report.
Add a comment...