Emacs tips and tricks
Forum rules
Share your brain ;)
Share your brain ;)
Re: Emacs tips and tricks
^ I love eshell, been using it a lot lately (it also works over TRAMP, which I find it very useful). I have to try this trick, thanks for sharing it.
Re: Emacs tips and tricks
i just gotta say: there seem to be a lot more Emacs tips and tricks than Vim tips and tricks. even though i dont even use either of them, just from hearing you guys about it, in my mind Emacs still wins ;)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
Re: Emacs tips and tricks
Well Rho, they're very different in what they actually are. Vi/Vim is a text editor that's extensible by scripts, while Emacs is a lisp-interpreter made to behave as a text editor. While that may not seem like a big deal at first glance...it means that you can change literally ANYTHING about emacs with some lisp.
Example: Bacon has mentioned before about how you don't need tmux if using emacs because it has active buffers and windows. On the other hand, if you are on the top window...but want to be on the bottom one with it on top, then the standard set of keybinds for making those moves are {C^x 0 C^x 4 b RET} or {C^x 0 C^x 2 C^x b RET} depending on which buffer/window your cursor is in. Well, fuck that...too many buttons. You'll end up with RSI.
Or, you can pull my window_swap.el script at github/lisp_scripts and put a line to load it in your init, and now {C^c s} 'swaps windows'. Problem solved. :)
Example: Bacon has mentioned before about how you don't need tmux if using emacs because it has active buffers and windows. On the other hand, if you are on the top window...but want to be on the bottom one with it on top, then the standard set of keybinds for making those moves are {C^x 0 C^x 4 b RET} or {C^x 0 C^x 2 C^x b RET} depending on which buffer/window your cursor is in. Well, fuck that...too many buttons. You'll end up with RSI.
Or, you can pull my window_swap.el script at github/lisp_scripts and put a line to load it in your init, and now {C^c s} 'swaps windows'. Problem solved. :)
Re: Emacs tips and tricks
so does that mean that, if you look at it honestly, there really is no reason whatsoever for the whole emacs/vim debate as they are essentially two different things and you end up basically comparing apples to pears?
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
Re: Emacs tips and tricks
Pretty much. Most us v them arguments are stupid, but in this case especially. It's like comparing a hammer and screwdriver and arguing about which is the best tool. It depends on what you need.
& @ GekkoP: eshell is something that I've always just sort of 'used' like ansi-term, but only recently got into REALLY playing with. It's addictive in that it's a shell, but you can use elisp commands directly or as scripts. At the point where I really began to grok that I can type (count-windows) or (window-list) or whatever directly into the shell and get stdout as emacs would see it...well, then the horizons got a lot more broad. For instance, typing in $echo "what buffer" (buffer-name) is acceptable and you end up with a lisp list as output! My command line jazz just got that much more avant garde.
& @ GekkoP: eshell is something that I've always just sort of 'used' like ansi-term, but only recently got into REALLY playing with. It's addictive in that it's a shell, but you can use elisp commands directly or as scripts. At the point where I really began to grok that I can type (count-windows) or (window-list) or whatever directly into the shell and get stdout as emacs would see it...well, then the horizons got a lot more broad. For instance, typing in $echo "what buffer" (buffer-name) is acceptable and you end up with a lisp list as output! My command line jazz just got that much more avant garde.
Re: Emacs tips and tricks
thanks for explaining joe :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
Re: Emacs tips and tricks
Ok, so here's something that I'm working on that I think is possibly worth sharing.
Using a shell of any kind to produce a process that you plan to keep running seems a bit redundant, and one of the most common things I do is start mpg123 and pick out a radio stream with it to listen to. So if I'm in emacs, I launch eshell (or Ansi-term which starts zsh) to launch a script (normally bash) to start mpg123 pointed at the stream I want. Meh, that's cheesy. So:
I am working on making a new module.
Essentially, putting this one in your load path will allow you to M^x eplayer-[TAB] to get a list of stations in a new window that shows the different stations. Once you select the one you want, it will fork a process of mpg123 and place the metadata in a new buffer named after the station you're listening to and notifying you of what you chose in the mini-buffer. Killing the meta-data buffer will kill the process, so it's easy to stop the stream.
I plan to add every station available from them over the next couple of days, and actually maintain this to keep it synced with somafm's direct servers. It currently works, it just doesn't have all the stations yet.
edit: pretty much caught up with the stations I want to track now. Let me know if you use this and run into any issues.
Using a shell of any kind to produce a process that you plan to keep running seems a bit redundant, and one of the most common things I do is start mpg123 and pick out a radio stream with it to listen to. So if I'm in emacs, I launch eshell (or Ansi-term which starts zsh) to launch a script (normally bash) to start mpg123 pointed at the stream I want. Meh, that's cheesy. So:
I am working on making a new module.
Essentially, putting this one in your load path will allow you to M^x eplayer-[TAB] to get a list of stations in a new window that shows the different stations. Once you select the one you want, it will fork a process of mpg123 and place the metadata in a new buffer named after the station you're listening to and notifying you of what you chose in the mini-buffer. Killing the meta-data buffer will kill the process, so it's easy to stop the stream.
I plan to add every station available from them over the next couple of days, and actually maintain this to keep it synced with somafm's direct servers. It currently works, it just doesn't have all the stations yet.
edit: pretty much caught up with the stations I want to track now. Let me know if you use this and run into any issues.
Re: Emacs tips and tricks
^ beautiful idea, I'll play with it later.
And about eshell: I'm with you, as I've been more into eshell than zsh lately.
And about eshell: I'm with you, as I've been more into eshell than zsh lately.
Re: Emacs tips and tricks
In case you are using MELPA and didn't notice, it is about to change URL. Just change it like this in your init and you will be happy:
Code: Select all
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
That's superb, since M^x mpg123-open does not really open URLs. I think people can easily add their desired stream, maybe I'll fork this one later and add the shit from our radiolists.DebianJoe wrote:Ok, so here's something that I'm working on that I think is possibly worth sharing.
Using a shell of any kind to produce a process that you plan to keep running seems a bit redundant, and one of the most common things I do is start mpg123 and pick out a radio stream with it to listen to. So if I'm in emacs, I launch eshell (or Ansi-term which starts zsh) to launch a script (normally bash) to start mpg123 pointed at the stream I want. Meh, that's cheesy. So:
I am working on making a new module.
Essentially, putting this one in your load path will allow you to M^x eplayer-[TAB] to get a list of stations in a new window that shows the different stations. Once you select the one you want, it will fork a process of mpg123 and place the metadata in a new buffer named after the station you're listening to and notifying you of what you chose in the mini-buffer. Killing the meta-data buffer will kill the process, so it's easy to stop the stream.
I plan to add every station available from them over the next couple of days, and actually maintain this to keep it synced with somafm's direct servers. It currently works, it just doesn't have all the stations yet.
edit: pretty much caught up with the stations I want to track now. Let me know if you use this and run into any issues.
Love you (in a homo way)!
..gnutella..
Re: Emacs tips and tricks
Note: I'm currently working on pointing the player at the .pls rather than the port number, since the ports at soma change, while the pls should be consistent from day to day. If you go to add streams, note that string substitution ("%s" variable) works well for a single argument, while using (concat "-@" variable) allows us to gang-load multiple argvs mixing variables and strings.
So, if your stream is something like "http://shitmusic.com:8000" then use the first format. If it's not a port number, such as a .pls, use the concat form.
While this is baby's first elisp-to-*nix stuff, it can be frustrating to figure out on your own. It's good to be loved...however I get it. :D
So, if your stream is something like "http://shitmusic.com:8000" then use the first format. If it's not a port number, such as a .pls, use the concat form.
Code: Select all
;; Type 1, string matching for a port number stream ;;
(setq bebl '"http://xstream1.somafm.com:8388")
(start-process "Beat Blender" "Beat Blender" "mpg123" "%s" bebl)
;;Type 2, concat argvs for a .pls type stream ;;
(setq covr '"http://somafm.com/covers.pls")
(start-process "Covers" "Covers" "mpg123" (concat "-@" covr))
Re: Emacs tips and tricks
Ok, I may totally overkill this over the next few days/weeks as I'm still digging into eshell, but I'm still working on some tweakage to get eshell to behave more like I want. One of the things I noticed was that 'clear' doesn't do anything:
...and now it does. :)
Code: Select all
(defun eshell/clear ()
"clears the eshell buffer"
(interactive)
(let ((inhibit-read-only t))
(erase-buffer)))
Re: Emacs tips and tricks
Since we are loving eshell, I'll add this useful snippet.
Ido-powered-up Eshell history.
Code: Select all
(add-hook 'eshell-mode-hook
(lambda ()
(local-set-key (kbd "C-c h")
(lambda ()
(interactive)
(insert
(ido-completing-read "Eshell history: "
(delete-dups
(ring-elements eshell-history-ring))))))
(local-set-key (kbd "C-c C-h") 'eshell-list-history)))
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
..gnutella..
Re: Emacs tips and tricks
^^ some very cool stuff in there! Some of the prompt options do not agree with my prompt setup, but they have the clear and a bunch of other neat snippets. I also like having '(emacs (file))' lead to (find-file file). I had 'ff' aliased to find-file, but this will probably prevent some typos. If you guys run across more of these, I'd like to see them. I am still just getting into what all can be done here.
I was pleased to find out that eshell gets along well with the kxt script I did for killx, and that by setting an alias {alias kxt /path/to/killxdots/kxt $1} the behavior is almost identical to any other shell. While it does spawn a subshell, it does cut out a lot of rewriting scripts.
I was pleased to find out that eshell gets along well with the kxt script I did for killx, and that by setting an alias {alias kxt /path/to/killxdots/kxt $1} the behavior is almost identical to any other shell. While it does spawn a subshell, it does cut out a lot of rewriting scripts.
- Dr_Chroot
- Alfalfa
- Posts: 1100
- Joined: Mon Jun 09, 2014 9:49 pm
- Location: among the sagebrush
- Contact:
Re: Emacs tips and tricks
^^ Fantastic! Thanks, MB. This was exactly the sort of thing I was looking for.
Fight internet censorship.
EFF | Tor Project | Bitcoin
"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden
EFF | Tor Project | Bitcoin
"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden
Re: Emacs tips and tricks
If you don't know what to eat, just ask Emacs: https://github.com/balle/fooddice
- Dr_Chroot
- Alfalfa
- Posts: 1100
- Joined: Mon Jun 09, 2014 9:49 pm
- Location: among the sagebrush
- Contact:
Re: Emacs tips and tricks
^ That is actually fairly humorous! I love it B)
Fight internet censorship.
EFF | Tor Project | Bitcoin
"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden
EFF | Tor Project | Bitcoin
"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden
Re: Emacs tips and tricks
Up until today I have never heard of auto-insert. Turns out it is a pretty cool way to simplify your life in Emacs.
For instance, every time I create a new .org file, first thing I do is put this string at the very top of it:
Now, let Emacs take care of this, shall we?
This works only when I open the file for the first time, so exactly what I need. Check the links I provided above for other examples.
For instance, every time I create a new .org file, first thing I do is put this string at the very top of it:
Code: Select all
#+STARTUP: showall
Code: Select all
;; Auto insert custom text upon opening an org file
(auto-insert-mode)
(setq auto-insert-query nil)
(eval-after-load 'autoinsert
'(define-auto-insert '("\\.org\\'" . "Org skeleton")
'(
"Short description: "
"#+STARTUP: showall\n"
> _ \n \n)))
Re: Emacs tips and tricks
This one is super-easy to figure out, but assuming that you want to associate something other than the default Scheme (I think it's EdWin on some editions, Guile on others) with M^x run-scheme:
In the case of Chicken, 'csi' is your REPL, so you want it instead of 'csc' (displayed example in scrot).
Code: Select all
(setq scheme-program-name "/full/path/to/interpreter")