Gnu Emacs General /geg/

>Wiki
emacswiki.org/
>Manual
gnu.org/software/emacs/manual/emacs.html
>Tutorials
C-h t (Interactive Tutorial)
gnu.org/software/emacs/tour/
tldp.org/HOWTO/Emacs-Beginner-HOWTO-1.html
ergoemacs.org/emacs/emacs.html
youtube.com/playlist?list=PLX2044Ew-UVVv31a0-Qn3dA6Sd_-NyA1n (general introduction)
youtube.com/playlist?list=PLVtKhBrRV_ZkPnBtt_TD1Cs9PJlU0IIdE (org-mode)
>Self Documentation
C-h k (Keybinds)
C-h f (Functions)
C-h v (Variables)
>Programming in Elisp
gnu.org/software/emacs/manual/eintr.html
ergoemacs.org/emacs/elisp.html
github.com/bbatsov/emacs-lisp-style-guide

>Packages
melpa.org (package repo)
pastebin.com/KUAbRwJR (short list of recs)
github.com/emacs-tw/awesome-emacs (the big list)
>Premade Distros / Configs
Make your own
github.com/hlissner/doom-emacs/tree/develop
github.com/syl20bnr/spacemacs (heavy)
github.com/snackon/Witchmacs (Basic config with sane defaults)
seagle0128.github.io/.emacs.d/ (Centaur Emacs)
gitlab.com/k-bps/mesk (Minimalist Emacs Starter Kit)
>Muh Startup Time
use-package defer
pastebin.com/mrPsnUas (increase GC during startup)
emacswiki.org/emacs/EmacsAsDaemon
emacswiki.org/emacs/EmacsClient

>Muh Default Keybinds
pastebin.com/UAUCvs73 (Fixing Emacs Default Keybinds)

>This pasta:
pastebin.com/LyD95ADj
>org source:
pastebin.com/pm7wPBEm

Previous thread:

Attached: emacs-logo.jpg (192x189, 8K)

Other urls found in this thread:

emacs.stackexchange.com/questions/33/put-all-backups-into-one-backup-folder
informatimago.com/linux/emacs-on-user-mode-linux.html
gnu.org/software/emacs/manual/html_node/emacs/Auto-Save.html#Auto-Save
github.com/akrito/acme-mouse
emacs.stackexchange.com/questions/7403/evil-cursor-change-by-state#answer-7404
strawpoll.me/18265831
wiki.archlinux.org/index.php/Xdg-utils#xdg-mime
youtube.com/watch?v=cIuX87Xo8Fc
twitter.com/AnonBabble

general titles are usually formatted like
/geg/ - Gnu Emacs General

Vim user trying to switch here but having problems

- How do I make Emacs write unsaved files in swap files like Vim does? All Emacs documentation says is that I should use gdb to restore unsaved buffers - seriously?
- What are the ~ postfixed files Emacs sometimes creates?
- Is there no robust persistent undo system for Emacs?

Outside of these things Emacs seems great, I'll just have to fix some Vim things like persistent search highlighting.

Stick to Vim.
It's superior in every way.

>-
emacs.stackexchange.com/questions/33/put-all-backups-into-one-backup-folder
>-
autosaves
>-
undotree package

best general

How do I reload the splash screen so I can see what my weeb logos look like after setting fancy-splash-image? I've tried revert-buffer but the splash page isn't associated with a buffer in the typical sense.

Attached: 2019-07-02.png (666x630, 166K)

> usually

I figured out the difference between backups and auto-saves. Backups are earlier saved versions of the file, auto-saves are temporary and intended for crash recovery.

Backup files I basically don't want (gonna disable them), I have incremental backups and I'd rather have persistent undo history. Problem is, I read undo-tree can make your session crash and is generally unstable. I'll have to see for myself.

Autosaves (#filename#) are still an issue - I suppose I'll have to reduce the delay (auto-save-interval?) and make it prefix the names with a dot so that they don't mess up my file browser listing.

On another note, I added this to prevent emacs from quitting if I have unsaved buffers. Wonder if there's a better way

(add-hook 'kill-emacs-query-functions
(lambda ()
(if
(seq-some
(lambda (buff)
(and
(string-match "^\\*new" (buffer-name buff))
(buffer-modified-p buff)))
(buffer-list))
(y-or-n-p "Unsaved buffers! Exit anyway?")
t))
'append)

>I added this to prevent emacs from quitting if I have unsaved buffers
That's default behavior. If you have any modified or unsaved buffers emacs will ask you what you want to do with each respectively before closing.

>That indentation
Jesus christ

It certainly doesn't. Try creating a buffer without an associated file (evil for example does this) and Emacs will happily throw away all your changes without any confirmation when you quit.

It's not a big issue though since it was so easy to fix. I still don't like the way Emacs treats non-file buffers as if they were worthless.

It's Jow Forums replacing tabs with spaces

dilate

>Try creating a buffer without an associated file (evil for example does this) and Emacs will happily throw away all your changes without any confirmation when you quit.
I see. If the buffer isn't tied to a file it follows emacs wouldn't know what to do with it on exit. Personally any kind of semi-temporary notekeeping I do ends up in ~/todo.txt

have sex

dilate beats have sex

Well I get that, but personally I'm too used to my current workflow - when I think of something I need to quickly write down, I just open a new window, type everything out and only worry about saving after I'm done. Having to think of save locations and file names feels stressful when I just gotta translate what's in my head into text fast

What function should I use to replace a regex match with new text in a string? I can't believe how hard this is to find on google or the docs

like (regex_str, new_str, target_str) => result
(regex-replace "b." "\1x" "abcd")
=> "abcxd"

Fuck, forgot parens around the regex, meant to use a capturing group:
(regex-replace "\(b.\)" "\1x" "abcd")
=> "abcxd"

Is there a way to save the command history and eval history between restarts?

I switched to micro, see ya losers!

replace-regexp-in-string ? M-x apropos is your friend btw.

Yep thanks!

>usually Im an obnoxious faggot

savehist-mode

It's probably best just to use the dashboard package, it has a dedicated refresh function. It's also more functional than the default splash screen.

why do people say this is an os itself? is it an exaggeration to make a point or is it actually an os, literally?

because they never used emacs. its an elisp interpreter that comes bundled with an editor, written in elisp

>dilate sex

Your move

Attached: meta.png (843x903, 39K)

it just needs a kernel (e.g. linux)
informatimago.com/linux/emacs-on-user-mode-linux.html
not all syscalls will work though.

It's a continuation of the old Lisp machines where you can modify everything as it's running. Look up people using Symbolics Genera and you can see the heritage of emacs. It has its own terminals, can display images inline, and can manage windows so you could in principle do everything in it.

Attached: 1561844306983.png (700x700, 202K)

Any idea how to make my work flow smoother for org?
Right now I have a single work.org with my current projects and slate, and it's archive for when some project is completed.
With a keybinding to quickly visit the file

What about you guys?

I have this file test.el:
(add-hook 'kill-emacs-query-functions #'cleanup-auto-saves 'append)

; comment


When the cursor is at the end of the last line, pressing enter causes Emacs to do something insane with the comment line's indentation:
(add-hook 'kill-emacs-query-functions #'cleanup-auto-saves 'append)
; comment

Any idea what this is about? This is on a vanilla setup.

last block was wrong, it doesn't remove the empty line, just changes the comment line's indent
(add-hook 'kill-emacs-query-functions #'cleanup-auto-saves 'append)

; comment

It's a Lisp convention to align all ; on the `comment column' and for ;; to be aligned to indentation.

Attached: linux.png (480x400, 151K)

Thanks that gets me on the right track. savehist gets confused when you have multiple instances open though, the last instance to be closed overrides the other instances' data. That seems to be the case for all session management options. Too bad, I don't feel like spending my vacation on dealing with this.

Oh so I should use ;;? I'm fine with that, cool.

cringe

What should I bind ctrl-s to if I want it to open a graphical dialog when saving for the first time like the file menu "save" option does?

(define-key global-map (kbd "C-s") 'save-buffer)

this is actually pretty accurate, I'm impressed
is it, dare I say, based?

Post your favorite packages.

so far I like hungry-delete, smart-tabs-mode, telephone-line, evil-leader and evil-nerdcommenter

I really like multiple-cursors.

write-file maybe

Hungry delete doesnt seem all that useful if you already have evil.

isnt evil just vim keybindings?

Yeah. I dunno, it's pretty easy to delete whitespace in vim already.

kek

In my experience undotree (while still useful for the tree), failed to load persistent undo history frequently if that is enabled.
Kinda sucks, but I guess simply using git accomplishes similar functionality.

Which one is the best? Ivy, Ido, or Helm?

I know I'm gonna be ridiculed for asking this, but...
is there a decent package that can provide Acme-like chords in Emacs?

>How do I make Emacs write unsaved files in swap files like Vim does?
Do nothing? Emacs auto saves by default
gnu.org/software/emacs/manual/html_node/emacs/Auto-Save.html#Auto-Save

There's this package written 10 years ago - github.com/akrito/acme-mouse
I don't know about acme specifically, but you can chord things with the mouse in emacs by default, so you could use that as a baseline for writing your own package.

That's what org capture is for

avy is great

> gnu/hurd
Hurd was ment to be the kernel.

elfeed (rss feed reader better newsbeuter)

It's not an OS, as an OS must manage hardware by definition.
That's also why GNU is not an OS, no matter how hard they cry.

Bind it to what the file menu "save" open is? All of the menus are just commands.

In global-map:

(write-file menu-item "Save As..." write-file :enable #20=(and #19=(menu-bar-menu-frame-live-and-visible-p)
. #15#)
:help "Write current buffer to another file")

write-file is an interactive compiled Lisp function in ‘files.el’.

It is bound to C-x C-w, .

I actually got to try out Genera years ago.
Shit was good, it's truly a shame we are now stuck with POSIX faggotry, and it doesn't help that the only other viable choice is Microsoft braindamage.

Or maybe this:

(save-buffer menu-item "Save" save-buffer :enable
(and #16=(buffer-modified-p)
(buffer-file-name)
. #15=(#14#))
:help "Save current buffer to its file")

M+x load-file

and reload .emacs file

how so? can evil also delete all white-space without additional keypresses

people abuse language all the time people think at distro is package manger + desktop. its opperating system from the perspective that peoples experience of different operating systems is defined by applications.

Use dashboard. All these links on the default startup screen are useless.

Thanks, too bad it doesn't show the GUI picker when invoked from a keymap.

No it doesn't. I'd have to map evil's :enew command and everything else to call (auto-save-mode) when starting. Or maybe use a buffer open hook and enable auto save if the name starts with "*new*"

Thanks for the info, this is good to know. I like having undo history provided by my editor when I edit stuff not on git, and it's also comfy that it doesn't matter if I close a window between edits, I can always go back to an earlier state by pressing "u" . But this isn't a complete dealbreaker.

This faggot here All in all I made some great progress with Emacs and it's a fantastic system but I'll have to put it on ice for the near future. Evil is just fantastic and the source code is a joy to read, but so much else in Emacs is backwards (for me since I'm used to vim) that it's gonna take a massive amount of work to get right and even though I could do that I'm not looking to spend all my time working on my editor when vim already is flexible enough for me (although only barely in some respects), fills my needs and is simpler to get right. Gonna miss the introspection features of Emacs though.

Things I put on my todo:
- Evil repeat doesn't work with motions that use read-key. They have a pull request fixing this already, though.
- Evil change boundary marks don't work, another known issue.
- Relative line numbers with absolute number for current line seem like a bit of a hassle
- Auto-saving non-file buffers is a bit of a hassle
- Persistent command histories don't work with multiple instances running (and I want one instance per file, generally)
- Persistent undo can be flaky
- Can't use vim bindings in minibuffers - would need to implement evil's "q:" system for all minibuffers
- Need to figure out autocompletion
- Persistent search highlighting isn't available with evil OOTB
- I hear regexes don't support non-static lookarounds, that's a big problem
- Need to import all vim plugins and config to emacs

Thank you for reading my blog and being helpful. I'll get back to Emacs when I have the time to work on these things or the ecosystem has manufactured (aka somebody else has done it)

>Relative line numbers with absolute number for current line seem like a bit of a hassle
(setq display-line-numbers-type 'relative)
(global-display-line-numbers-mode)

>Can't use vim bindings in minibuffers
(use-package evil-collection
:custom (evil-collection-setup-minibuffer t)
:init (evil-collection-init))

>Need to figure out autocompletion
company isnt that hard to setup
>Persistent search highlighting isn't available with evil OOTB
do you mean this?
(setq evil-search-module 'evil-search)

Holy shit you're awesome. The first two save me a shitload of time, especially the minibuffer feature makes the switch way easier for me, can't live without it.

The third one meant I'd like to have the search highlights "stick" even after I move the cursor, like hlsearch does in Vim. I had a look at evil-search.el, and looks like all I need to do is disable the line calling (lazy-highlight-cleanup t). I can then perform the cleanup later manually with a keymap.

Now the switch to Emacs looks manageable again, so I'll keep working on it during downtimes

>search highlights "stick"
that's weird because it already works like that for me. press / type the thing, press enter and then they stick.

I'll just say that it's funny really that Emacs is better at the Vim parts than Vim itself. It was only the random extra stuff that vim does better by default, and it looks like almost every alternate workflow for emacs already has been implemented, you just gotta find the right packages. I'm seeing the light now

Nah, didn't work that way for me, might be some change I've made.

just tested it, when you leave the search module at the default (isearch) then they dont stick, they do when you set it to evil-search

I pasted the variable setup before and after evil init, still doesn't seem to work that way. Might be we have different versions or something else is causing a conflict. Regardless, I just removed the "cleanup" call from evil-search.el since I've edited evil anyway to change the cursor from a block to a slim bar that sits between chars instead of on them.

Just in case anybody is interested, pic related is enough to get a "normal" cursor in evil mode

;;init.el

(setq evil-move-beyond-eol t)
(setq evil-move-cursor-back nil)

(add-to-list 'default-frame-alist '(cursor-type . bar))
(add-to-list 'default-frame-alist '(cursor-color . "#ff0000"))
(setq evil-default-cursor '("#ff0000" bar))
(setq evil-normal-state-cursor '("#ff0000" bar))
(setq evil-insert-state-cursor '("#0000ff" bar))
(setq evil-operator-state-cursor '("#ff0000" bar))

Attached: evil.png (922x761, 115K)

>change the cursor from a block to a slim bar
you dont need to edit evil for that
emacs.stackexchange.com/questions/7403/evil-cursor-change-by-state#answer-7404

Just made a matrix room for /geg/ (Would make a irc one, but i figured that keeping it not public would be better.
In order to join the room, go on your matrix client of choice and join the room
!JkOxqhmAyBzXAbPyhZ:privacytools.io

Ah but that doesn't truly make it behave like a proper bar cursor. With pressing "e" brings you to the end of a word instead of to the left of the last char, and everything just works smoothly without the dumb block cursor for normal mode. I think vi's block cursor was a huge mistake - it takes some unlearning, but I promise you you don't wanna go back when you get used to a regular slim cursor.

Is it better to use spacemacs or evil? I tried spacemacs but it got frustrating trying to work with some of the commands as opposed to regular and was interested in trying evil

Attached: 7f42d4ae1ba15a267e388303a9669a8ddd12131ab766a3edd4ab6934be34136d.png (523x548, 273K)

Only use spacemacs if you're actually interested in trying spacemacs and all the packages it provides by default. There's no real reason to use it just for trying evil.

yasnippet

cuck

What bindings does /geg/ use? Emacs or evil?
strawpoll.me/18265831

Best way to draw diagrams on emacs and render them into images? i usually do ascii diagrams on artist-mode, but i'd like to render them into pdfs and such

ay, any ideas on how to automagically open video files on mpv through dired? just enter and it opens mpv with that file?

read-file-name is a compiled Lisp function in ‘minibuffer.el’.


If this command was invoked with the mouse, use a graphical file
dialog if ‘use-dialog-box’ is non-nil, and the window system or X
toolkit in use provides a file dialog box, and DIR is not a
remote file. For graphical file dialogs, any of the special values
of MUSTMATCH ‘confirm’ and ‘confirm-after-completion’ are
treated as equivalent to nil. Some graphical file dialogs respect
a MUSTMATCH value of t, and some do not (or it only has a cosmetic
effect, and does not actually prevent the user from entering a
non-existent file).

Internally, that calls next-read-file-uses-dialog-p You can write a thin wrapper that just monkey patches next-read-file-uses-dialog-p to return true.

I seriously don't understand the resistance to using emacs bindings. It's the same as normal shell bindings (Ctrl-A, Ctrl-E, etc.), so it just makes sense. Except for the kill ring stuff, that's still out there in the sense that nothing else compares to it. Evil users, please let me know why you like it better, I'm totally open to trying it out long term.

This worked, thanks!

dilate

I use Emacs of course.

Attached: 0230D81A-3DE9-4071-A886-123BB6893E38.jpg (1068x601, 65K)

I'd do it in LaTeX+tikz or something

I use Plantuml. You can even export them from an org file using Babel.

I have no idea what I'm doing. next-read-file-uses-dialog-p keeps returning t after save even with the fset I have there at the end.

(defun true () t)
(defun dialog-save (&optional arg)
(interactive "p")
(let ((dialog-p (symbol-function 'next-read-file-uses-dialog-p)))
(fset 'next-read-file-uses-dialog-p 'true)
(save-buffer arg)
(fset 'next-read-file-uses-dialog-p dialog-p)))
(define-key global-map (kbd "C-s") 'dialog-save)


- With modal bindings you don't need to press modifier keys at all a lot of time
- Chaining keys is more convenient when you don't have to worry about keeping modifiers pressed
- Vim keyscheme is easily composable, you can combine operators with motions and registers, and motions with counts
Other than that it's the same, you just press and release modifiers instead of holding them down.

>setup mpv as default media player
>highlight file in dired
>press 'W'
>???
>profit

Set it as default video player how? as in the environment variable?

I just do it in the file manager (thunar), but this should also work
wiki.archlinux.org/index.php/Xdg-utils#xdg-mime

just found a nice package called openwith that let's me assign an external command to certain mimetypes, works fine. Thanks for the answer tho :)

artist-mode
youtube.com/watch?v=cIuX87Xo8Fc

Ah, I suppose I wouldn't need to change my caps lock to an extra ctrl... I'll give it a shot. Thanks.