reddit / emacs
Weekly Tips, Tricks, &c. Thread
AutoModerator · 2022-05-25 08:15
This is a thread for smaller, miscellaneous items that might not warrant a full post on their own.
[See this search for previous "Weekly Tips, Tricks, &c." Threads.](https://www.reddit.com/r/emacs/search?q=Weekly+tips&restrict_sr=on&sort=new&t=all)
Don't feel constrained in regards to what you post, just keep your post vaguely, generally on the topic of emacs.
khourhin · 2022-05-25 10:19
Just discovered that you can do pull request from magit forge. Got some troubles with the origin / myfork setup and was helped by this issue: https://github.com/magit/forge/issues/278 .
And this improved as well how I deal with the naming of my remotes.
Pure awesomeness, thanks a lot for Magit/ Magit forge !
slinchisl · 2022-05-25 12:11
[arxiv-citation](https://github.com/slotthe/arxiv-citation) from my [last post](https://old.reddit.com/r/emacs/comments/ufvg93/my_phd_research_workflowemacs_inside/) is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)!
On that note, I've written a little bit about [calling Emacs from XMonad](https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html). The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful.
pwnedary · 2022-05-25 17:22
This is the best way I have found to continue comments when pressing RET while in Insert mode using Evil mode:
(evil-define-key 'insert 'global
[remap newline]
'(menu-item "" default-indent-new-line :filter
(lambda (_cmd)
(when (save-excursion (comment-beginning))
`(lambda () (interactive) (,comment-line-break-function))))))
While it does call `(comment-beginning)` twice instead of once when pressing RET, it does have the big benefit of otherwise behaving exactly like `newline` when outside comments.
vjgoh · 2022-05-25 17:35
2 questions:
I asked this just as the previous thread was winding down: I've started working with Unreal, and it has stuff like
UCLASS(<some stuff>)
[Normal line of C++];
How do I get emacs to treat those special declarations like they're terminated with a semicolon? (The compiler will complain if I put a semicolon there myself, and it would be at odds with how everyone else is coding anyway.)
I'm trying to figure out how to remove items from a list like:
("--exe=foo.exe" "--target=Development" "--platform=Win64" "-progress" "-NoHotreloadfromide")
I feel like cl-set-difference should do the job. I consistently just want to remove the `--exe`, `--target` and `--platform` elements. I tried this:
(cl-set-difference argument-list '("--exe" "--target" "--platform") :test #'s-contains?)
But that doesn't actually seem to do what I want. I know s-contains? works if I use cl-remove with each individual thing I want to remove. It also seems to work with cl-member.
Now that I'm looking at it, I'll be that the problem is the order that the arguments are being fed to s-contains?, but I'm also bound by the order that cl-set-difference demands. Anyone have a solution for that? (I'm actually going to solve this issue in a different way and remove all elements from the list that contain "--", and stick to a scheme where removable items start with that.)
emacsomancer · 2022-05-25 19:20
Is there a way to have [org-download](https://github.com/abo-abo/org-download) sanitise file-names? I end up with problems syncing files since some names include colons or other characters that some file-systems don't like. Some way of having it filter out certain characters from filenames?
[deleted] · 2022-05-25 23:41
[removed]
nv-elisp · 2022-05-26 03:25
There are lots of ways to achieve what you're after.
Here is one:
(let ((args '("--exe=foo.exe"
"--target=Development"
"--platform=Win64"
"-progress"
"-NoHotreloadfromide")))
(cl-remove-if
(apply-partially #'string-match-p
(concat "^--" (regexp-opt '("exe" "platform" "target"))))
args))
;; => ("-progress" "-NoHotreloadfromide")
Psionikus · 2022-05-26 08:23
How do I configure straight to always pull the latest tag matching pattern for a package. So that org mode stops getting broken by using the head accidentally.
takeonrules · 2022-05-26 12:32
You might be able to add an advice function around: https://github.com/abo-abo/org-download/blob/master/org-download.el#L298-L302
vjgoh · 2022-05-26 14:31
Oh, apply-partially is new to me. That's very interesting! Thanks! :)
Sudo_Brew · 2022-05-26 17:32
I have a script which uses a lot of carriage returns to update a progress percentage, then another carriage return to display the done message. When I run this in compilation-mode, it will typically replace these messages with a `[...]`. If I hit enter or click on this, it will display the full message, but I'd rather it not be hidden in the first place. I'm not sure how to describe this well enough to get any useful search results nor look for variables to tweak. Does anyone know how to get compilation mode to not collapse messages like this?
b3n · 2022-05-29 11:20
Is there a reason you can't do this?
(evil-define-key 'insert 'global [remap newline] #'default-indent-new-line)
pwnedary · 2022-05-29 12:53
Yes, I tried that at first, but it causes problems with e.g. `electric-pair-mode` etc. because they check if `(eq last-command-event ?\n)` and that is only set by `newline`. Just looking at the source of `newline`, it does "more" than `default-indent-new-line`. I could be wrong though.
Psionikus · 2022-05-31 07:24
(defun pmx-vterm-avy-goto-word-1 ()
"Jump, but enable vterm copy mode first"
(interactive)
(unless vterm-copy-mode
(vterm-copy-mode 1))
(call-interactively 'avy-goto-word-1))
(defun pmx-vterm-kill-ring-save ()
"Kill, but enable vterm copy mode first"
(interactive)
(unless vterm-copy-mode
(vterm-copy-mode 1))
(call-interactively 'kill-ring-save))
(defun pmx-vterm-send-enter ()
"Enter, but disable vterm copy mode first"
(interactive)
(when vterm-copy-mode
(vterm-copy-mode -1))
(call-interactively 'vterm-send-enter))
(defun pmx-vterm-yank ()
"Yank, but disable vterm copy mode first"
(interactive)
(when vterm-copy-mode
(vterm-copy-mode -1))
(call-interactively 'vterm-yank))
(general-def 'vterm-mode-map "M-j" 'pmx-vterm-avy-goto-word-1)
(general-def 'vterm-mode-map "M-w" 'pmx-vterm-kill-ring-save)
(general-def 'vterm-mode-map "RET" 'pmx-vterm-send-enter)
(general-def 'vterm-mode-map "C-y" 'pmx-vterm-yank)
Automatic `vterm-copy-mode` calls in the `vterm-mode-map` to make common jump, kill, paste, enter commands do the right thing with copy mode before executing the command normally.
I never need these bindings in vterm, and if I did, I could use `M-x` `vterm-send-M-w` etc.
spdevlin · 2022-06-01 01:48
Check out this customization option for cc-mode: https://www.gnu.org/software/emacs/manual/html_node/ccmode/Macros-with-_003b.html.
vjgoh · 2022-06-01 18:03
Oh amazing, thanks!