Matrix-like Idle Animation for Emacs - emacs

As is, my emacs is set up to show green text on a black background. On seeing it, a friend remarked that I just took it because of the Matrix-like appearance it gives. So, now what I want to do is implement an idle animation for it where, like in the matrix, changing text falls down the screen. Like in the zone out functions, it should run after emacs has been idle for a while. How would this be done?

You might want to check out the package zone: M-x zone
The 'zone-pgm-drip is like the Matrix drip, only one character at a time. I'm sure it could be enhanced to be more flood like. Also, the 'zone-pgm-jitter has text flooding down, but it's just the text currently on the screen (so it's horizontal extent is limited to what was already showing). You can just run M-x zone over and over until you find what you like.
If you want to limit the choices zone uses, you can restrict the array that zone uses:
(setq zone-programs [zone-pgm-jitter])
The choices for zone-programs are:
zone-pgm-jitter
zone-pgm-putz-with-case
zone-pgm-dissolve
zone-pgm-explode
zone-pgm-whack-chars
zone-pgm-rotate
zone-pgm-rotate-LR-lockstep
zone-pgm-rotate-RL-lockstep
zone-pgm-rotate-LR-variable
zone-pgm-rotate-RL-variable
zone-pgm-drip
zone-pgm-drip-fretfully
zone-pgm-five-oclock-swan-dive
zone-pgm-martini-swan-dive
zone-pgm-rat-race
zone-pgm-paragraph-spaz
zone-pgm-stress
zone-pgm-stress-destress
zone-pgm-random-life

You could install zone-matrix from Marmalade. "M-x package-install zone-matrix"

Looks like someone just made one. It worked for me after a small amount of tweaking:
https://github.com/emacsmirror/zone-matrix

You could just use the xmatrix screensaver, which could probably be modified to run in a window other than the X root if you really want it to run it within emacs. Bonus points if you can modify it to use glyphs based on the text in the current window. By strange coincidence, Jamie Zawinski both wrote xmatrix and large chunks of Lucid Emacs, which was subsequently released under an open-source licence as Xemacs.

Related

Is there a region change hook in emacs lisp?

I'm trying to get the content of current selected region in buffer. I'm aware of idle timer, but a hook should be more efficient/cleaner...
Not sure what you mean by "region change". If you mean "the text in the region is modified", then you'll need to use after-change-functions. If you mean that the selected text is modified by changing its bounds, then you'll probably want post-command-hook or maybe an idle timer (which is not less efficient than a hook, the main difference is that you get less guarantees about when it gets run; e.g. it won't be run between two commands if there's no idle time between the two, as is the case when running a keyboard macro).
A way to go seems to advice handle-shift-selection. AFAICT this function is called with every region-change by keyboard. Resp. advice mouse-drag-region.

Creating, recreating many Emacs-windows

From time to time I would like to create a bunch of say 8 windows with some fixed names, with some shells, all split vertically. So I do a lot of C-x 2 and rearrange the window size. Isn't there a better way to do this?
So the desktop saver is no help to me, unless I missed something.
(By windows, I mean emacs-windows, not the windows "window-managers" are built-for which you can Alt-Tab to)
You can store your current window layout to the Configurations register
However, to make it persistent across sessions, you might need a tool like Policy Switch.
Emacs Screen also looks very promising for what you want.
This is something that I have been meaning to do for myself for a long time; appreciate the nudge ;)
While there are various prepackaged solutions for recording and saving windows and frame congurations as alluded to in the other answer, it is quite easy to do this directly.
You can call 'make-frame' directly with the frame parameters you want. An example may look like this:
(make-frame '((name . "(SHELL)")
(icon-name . "(SHELL)")
(icon-type)
(top . 720)
(left . 1300)
(height . 30)
(width . 81)))
This call will not only create the frame (in case you are running under a windowing system) but also return the newly created frame.
If you want a quick peek at what parameters are available, you can make a call like this:
(frame-parameters)
which will return the parameters of the currently selected frame.
You can change one or more parameters of a frame with 'modify-frame-parameters' and get a list of all frames with 'frames-on-display-list'.
There are many more nifty functions that allows you to deal with frames. Check the documentation for more info.

emacs zoom in/out globally

I know that I can zoom in/out using C-x C-+, but this applies only to the current file. Once I open another one, the text goes back to the default value and it's really tiresome to do it over and over. How can I keep the zoom level global for the current emacs session?
I know it's possible to set this in the init file if you know the exact font size, which I don't. Plus, I don't want to keep it that permanent - I usually need this when I'm without an external screen for a couple of hours or connected to a beamer while giving a presentation.
This piece of code modify the zoom in/out functionality to apply the commands to every buffer. That should achieve what you are trying to do.
(defadvice text-scale-increase (around all-buffers (arg) activate)
(dolist (buffer (buffer-list))
(with-current-buffer buffer
ad-do-it)))
All of the answers given here, and more, are available on the
EmacsWiki page dedicated to the question of setting and changing font
size, including changing it incrementally.
The answer from #abo-abo is on the right track, regardless of whether
you think the size he used in the example code was too big, and
regardless of whether the solution does not address incremental
adjustment.
The answer from #juanleon essentially makes text scaling simulate
changing the default character size (#abo-abo's answer).
The point of text scaling is to scale the buffer text (one buffer, no
matter where it is shown), not the frame text (all buffers shown in
the frame). But if you want all buffers to have their text size
changed in a given frame then there is no reason to bother with text
scaling in that case: just change the font size.
You can do either or both (scale the buffer text everywhere or zoom a
frame), and do so incrementally, using the same command, if you use
command zoom-in/out from library
zoom-frm.el.
On the other hand, if you really do want to incrementally change the
text size of all buffers in all frames, then the best approaches are
either (1) #juanleon's suggestion or (2) incrementally zoom the standard face
default.
To do the latter, you can use commands zoom-all-frames-in and
zoom-all-frames-out in library
zoom-frm.el
Just paste this in *scratch* and evaluate (with C-j or C-x C-e):
(set-face-attribute 'default nil :height 150)
There's nothing wrong in putting this in the init file
and commenting it out later, when you don't need it.
Its possible to scale all text (including status-line & line-numbers) using a little mode that handles this exact problem: purcell/default-text-scale. It's available in Melpa.
This scales all text to avoid text scale mismatch such as line-numbers of fill-column indicator being offset incorrectly.
The other answers here either don't work for new buffers or require too much manual intervention.
connected to a beamer while giving a presentation.
There is another package for that!
emacs-presentation-mode
Quoting from the site
Execute M-x presentation-mode to start the presentation.
Adjust scale size by C-x C-+ or C-x C--
See https://www.gnu.org/software/emacs/manual/html_node/emacs/Text-Scale.html
After the presentation, execute M-x presentation-mode again.
And then execute M-x presentation-mode again, the last scale will be reproduced.
If you want to persistize its size as the default size of presentation-mode
after restarting Emacs, set presentation-default-text-scale.
It's also have description of differences from other similar modes/package.

How do I get Aquamacs/Emacs to show a right margin indicator?

After living with Java IDE's for quite some time now, I'm back into the world of C++ development. And I've returned to my editor of choice: Emacs (actually, most of the time I'm in Aquamacs on the Mac, but I do occasionally use Emacs when I'm on a Linux box).
Strangely, the thing I find myself missing most is a right margin indicator. I find myself using M-x 3 a lot to put code up side by side. Knowing exactly where I've set the margin would help me keep things clean and neat.
Is there any hope of setting up Aquamacs to show a right margin indicator? Or something that would have a similar effect? How about Emacs with X support?
You can use the column-marker library to set column markers with specific faces.
using C-u 80 # I can quickly insert # 80 times to separate chunks of code.
this also acts as visual guide so I don't go above 80 characters on single line, a common coding convention (perhaps same as your reason)
C-u followed by a number and then a command, repeats the command the given number of times
eg, C-u 10 C-n will move cursor 10 lines down

Emacs reselect region, as Vim shortcut 'gv' does

In vim, visual block can be recall by 'gv' command so that multiple commands can be applied easily. (such as, comment out, then indent, then do_something_fun).
In Emacs, how can this be achieved?
[C-xC-x] only works when current cursor position stays where previous block ended.
If previous block was changed, the closest is to go through 'point-to-register' and 'jump-to-register'.
Just I am curious if there is an Emacs built-in command making this in one shot.
If Transient Mark mode is off, the region is always active. If it's on (which it sounds like is your situation), you can set mark-even-if-inactive to non-nil to allow region commands to work while the region isn't highlighted.
However, note you also can cycle back through previous mark positions using C-u C-SPC -- this will pop the mark ring. Once you're back to where you want to be, C-x C-x will rehighlight the region you want. (It may take a little bit of playing with this feature to get a feel for it, but it's why I can't switch away from Emacs now.)
If I understand correctly what you are asking for, then you don't need to do anything. When you select a region in emacs, it stays selected until you select a new one. So you could select the region and then perform as many actions as you want.
Sounds like you're looking for the secondary selection, which stays put even as the region might change. (It stays put until you move it.)
See:
the Emacs manual, node Secondary Selection
Emacs wiki page Secondary Selection
library second-sel.el:
Also narrow-to-region (CTRL-x n n ) applies every command from then on just to that region- you can't hurt the rest of the buffer, it doesn't even show. After done editing , widen (CTRL-x n w )to get back the whole buffer.
CMM
If you use evil-mode, just press gv like in vim.
Since the answers here and for other similar SO questions didn't help for me (CUA-mode, Emacs 24, not only indent-rigidly), I continued searching and finally found a reselect-last-region defined in this collection of custom function (starting line 670). That worked like a charm for me - and hopefully does for others still arriving here.