Can we make an Emacs buffer to be static/pinned? - emacs

I use an Org file to keep track of my activities, because it's often that I am loosing track of what actually I am aiming to do :)
Now, I would like to reserved a top buffer window with only 5 lines tall and show the narrowed todo from that org file. All other window/buffer activites will not touch that static/pinned buffer.
Is there a way to achieve that result???
Thanks!
EDITED : Can we make that certain buffer to have different background Color? I pressume it's not, because all we have is set-background-color... I hope I am wrong..

Maybe setting the variable special-display-buffer-names will set you in the right direction.
(setq special-display-buffer-names
'(("magic buffer" (width . 70)
(height . 7)
(background-color . "green"))
))
to test certainly made a buffer called "magic buffer" turn up in a small and very very green frame. (For real-life use, of course do go through the customize mechanism by all means.)
ETA: And then, there's also this question which might apply here.

If you clock in to the Org TODO item, that task will be displayed in the modeline of the current buffer; you might also find that helpful as a reminder of what you're working on.

The original part of the question is a duplicate. See How do I make this Emacs frame keep its buffer and not get resized? (which is slightly enhanced over the earlier Pin Emacs buffers to windows (for cscope)), and the set-window-dedicated-p function.

YOu can use org-todo-list to show TODO items and org-agenda will show you useful choices such as "M" that filters your TODO items by keyword.

I struggled with the same problem for a while. The best solution I came up with was creating a small Emacs frame (size: 80x13) for my Org-mode agenda and placing it in an always-visible portion of my screen. (Use "C-x 5 2" to create a new frame.)

Related

Emacs multiple hl-line faces/change line hook?

I was updating my emacs (I use doom btw) config when I came across a problem. I want to flash the current line for all movement operations. I also want a constant effect on the current line. I'm able to do one or the other, but thus far I can't find a way to do both.
Currently, I have a box around the line that I want to always be present. I would like the background to flash on any movement, (e.g. line changes, frame focusing). I can use hl-line+.el to flash the line when it moves, but this seems to co-opt the hl-line face. It forces me to choose between constant line highlight and line highlighting on movement. I also can use nav-flash to flash on changing buffers, but this does not react to line changes. Is there a hook I can add nav-flash to? Is there a way I can override hl-line+ to use a different face and allow the line to be highlighted normally too? For what it's worth, here are my current config settings:
((hl-line &override)
:background bg
:box '(
:color "#fb7d32"
:line-width -1))
(nav-flash-face
:foreground bg
:background "#fb7d32")
Any suggestions are greatly appreciated, I would consider myself an intermediate emacs user, so I'm not afraid to write my own functions and hooks if thats what this comes to. Regardless, thank you in advance for your help and suggestions!
I'm on emacs 26.3 with doom installed.
hl-line-flash, from hl-line+.el just uses hl-line-highlight.
And that function just reuses the existing overlay. That overlay (created by hl-line-make-overlay) uses the value of variable hl-line-face.
What you could do is advise hl-line-flash with an :around advice, so that it does this:
Binds hl-line-face to the face you want to flash with.
Deletes the existing overlay (hl-line-overlay).
Then invokes the original definition of hl-line-highlight-now.
There are no doubt other ways to do what you want, as well. One way is to just define your own command to use in place of hl-line-flash, with code that does the same thing as the above advice description. Just do that around the call to hl-line-highlight-now, so that function uses the face you want for flashing.

Cycle through a list of buffers in Emacs

I want to have something like this:
A list of buffer is display
As I select a buffer in the list, it's content is display immediately.
The list can be in minibuffer (preferred) or in a separate window
Is there a plug in for this?
Finally found what I wanted (although a bit differed from what I wanted, but it got the essential feature right): https://github.com/martinp26/cycbuf
It automatically display buffers with a list of buffer as the cursor move at a buffer name. Customize variable cycbuf-clear-delay to adjust the time the buffer list is toggled; after exceeding the delay, the buffer list is automatically turned off and the buffer is picked.
^x^b displays a list of buffers, then you can click on one. Is that what you want?
There are several alternatives. For discussion on these, see for example http://www.emacswiki.org/emacs/ControlTABbufferCycling
There's many options. Some are:
to display a list of buffers: ibuffer is an option http://www.emacswiki.org/emacs/IbufferMode
to have the list in the minibuffer: ido-switch-buffer http://wikemacs.org/index.php/Ido#Virtual_Buffers or you can use helm's interface http://wikemacs.org/index.php/Helm
The EmacsWiki pages cited in the other answers (so far) are a subset of the wiki's main page for this topic, which is where you should start.
(That wiki page is also a good place for other answers, which do not cite EmacsWiki, to update. ;-) )

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.

emacs editing Rnw keep region highlighted when highlighting R chunk

When editing an Rnw file in Emacs, I often want to make the region cover a chunk of text that contains an R chunk. For a simple example:
ewr
<<>>=
#
wer
I use transient-mark-mode such that the region is highlighted. But, if I put the point on the first line and hit C-SPC, then use C-n to move the point down, the highlighting disappears when I try to advance the point past the <<. The region I want is still selected, but highlighting seems to fail when crossing the <<. How can I fix this?
Thanks and best regards
I find that your problem shows up when I do what you describe, but it goes away if you scroll down using C-down or C-M-n instead. I think you can even use C-down to get past the R chunk and then C-n to step past lines afterward.
I had the same problem and the solution suggested by fojtasek did not work for me because I had an additional configuration problem. I hope that this might be useful for you and other users. Make sure that if you are using ESS and Auctex that you have fully loaded Auctex. To be more specific, it turned out that when I had previously installed auctex 11.86, I did not correctly load the package. Because I am a novice emacs user, I only managed to load the first of the following two lines:
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
If you have not added the second line, you will only have an Auctex menu but NOT a preview-latex menu.
Thanks to Fojtasek for the C advice. I find C- with the arrow key will keep a contiguous highlight. C-down brings up a page that says "this confusing feature has been disabled by default".
In my opinion, this behavior that OP complained about is a flaw in Auctex, and the fact that Fojtasek has a way to avoid it is helpful, but still it is just a workaround. I don't want Auctex to to this and I don't really want to have to use my left hand for holding down C while scrolling. PITA.
If Auctex needs some special selection tool, they should have to use unusual keystrokes for that. Why impose it on the rest of us who just want to highlight big sections and move them around, whether or not they have <<>> in them.

Emacs - Multiple columns one buffer

I'm trying to edit some assembly code which tends to be formatted in long but thin listings. I'd like to be able to use some of the acres of horizontal space I have and see more code on-screen at one time. Is there a method for getting Emacs (or indeed another editor) to show me multiple columns all pointing to the same buffer?
C-x 3 (emacs) and :vsplit (vim) are great for multiple separate views into the code, but I'd like it to flow from one column to the other (like text in a newspaper).
See follow-mode.
Excerpt:
Follow mode is a minor mode that makes two windows, both showing the same buffer, scroll as a single tall “virtual window.” To use Follow mode, go to a frame with just one window, split it into two side-by-side windows using C-x 3, and then type M-x follow-mode. From then on, you can edit the buffer in either of the two windows, or scroll either one; the other window follows it.
In Follow mode, if you move point outside the portion visible in one window and into the portion visible in the other window, that selects the other window—again, treating the two as if they were parts of one large window.
I use this function to invoke follow-mode, although it would need customization for a different screen size:
;;; I want a key to open the current buffer all over the screen.
(defun all-over-the-screen ()
(interactive)
(delete-other-windows)
(split-window-horizontally)
(split-window-horizontally)
(balance-windows)
(follow-mode t))
The "Multipager" plugin for Vim can do this with VIM splits for people who want to get this behavior in Vim.
Get it from Dr. Chip's page: http://mysite.verizon.net/astronaut/vim/index.html#MPAGE
Docs: http://mysite.verizon.net/astronaut/vim/doc/mpage.txt.html
Vim can do this using :vsplit - and you can have the same buffer open in multiple "windows" (which are actually sections within a single "window").
Documentation here
A quick look at the emacs wiki doesn't show a mode like you describe. However, it shouldn't be too hard to write one... You just need to split the window with C-x 3 and move the text in the other window down, and whenever you move the text, do the same to the other window...
Problems may occur when you get to the bottom of the buffer, do you want the cursor to immediately go to the other window at the top?
Hmm, maybe its not that easy. But it should still be doable...
this is the default behaviour of emacs when splitting the window (C-x 3 for vertical split)
you get two columns which both have the current buffer open
Use vertical-split with C-x 3. This will split the current buffer into two columns that you can switch between with C-x o.