reddit / emacs

Weekly Tips, Tricks, &c. Thread

AutoModerator · 2022-06-29 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.
styrg · 2022-06-29 11:44
Disclaimer: I don't know the appropriate names for many things in emacs, apologies if I describe something incorrectly. This might be spacemacs only, but I found that if, at the bar at the bottom, you have a prompt asking for the user to type something in, you can paste from your keyboard with ctrl+Y. This most often comes up for me when using magit, and creating a new branch, and naming the branch allows out kanban integration to work. I just copy the branch name from the integration, then press ctrl+Y in that bottom bar when asked for a branch title. I'm mostly posting this because it was a bit tough for me to figure out how to paste in there when I was searching for it. I suppose partially because I still don't know what to call that bottom bar prompt.
_viz_ · 2022-06-29 12:30
(I don't know how transient works) Most probably, you're talking about the "minibuffer"
remillard · 2022-06-29 13:44
Decided that this might be a better place to ask a question rather than start a post like I did last time (though it was illuminating.) In any event, I'm still in the process of converting a largely Customization driven .emacs file to a more explicit init.el file where I am handling the details myself. Today's quandry is treemacs, all-the-icons, and the treemacs-all-the-icons package. I should not, if this is done with installing packages through the Customization route, this all works pretty seamlessly, so I'm clearly doing something in the wrong order or something along those lines. What I've got in the init.el file is the following: ;; ;; Treemacs and Icons ;; (use-package treemacs :config (setq treemacs-python-executable "c:/Python310/python.exe")) (use-package all-the-icons :after (treemacs)) (use-package treemacs-all-the-icons :after (treemacs all-the-icons)) (require 'treemacs) (require 'all-the-icons) (require 'treemacs-all-the-icons) (treemacs-load-theme "all-the-icons") The last 4 lines are a bit of a hack experiement. The final two lines are from the treemacs-all-the-icons instructions, and I figured I might need to explicitly make sure the two prior packages were not lazy loaded. I would note that when I first did this and evaluated the lines, it worked fine. Now however upon loading and calling treemacs sidebar I get the following behavior: https://imgur.com/a/oXzzVy1 Any ideas?
remillard · 2022-06-29 14:00
I think I got it sorted. It wasn't so much the treemacs-all-the-icons as it was all-the-icons and needing the fonts that become the icons to be loaded into the operating system (in this case, Windows). My final configuration that seems to work is: ;; ;; Treemacs and Icons ;; (use-package all-the-icons :if (display-graphic-p)) (use-package treemacs :bind ("C-x M-b" . treemacs) :config (setq treemacs-python-executable "c:/Python310/python.exe")) (use-package treemacs-all-the-icons :after (treemacs all-the-icons)) (require 'treemacs-all-the-icons) (treemacs-load-theme "all-the-icons")
WallyMetropolis · 2022-06-29 14:58
That interactive area at the bottom is the "minibuffer" And `C-y` is almost certainly bound to "yank." Which will take the last text that has been "killed" and copy it at point. `C-y` will work almost everywhere in emacs, not only the minibuffer. It's sibling command is `C-k` which kills a line and adds whatever was killed to the "kill ring." You can also yank text that has been killed earlier, browse the kill ring and pick some text to yank, and other nifty things. You can see the name of a function being used by a key press, and documentation for that function through the interactive help: Press `C-h k` to get help for a keybinding. Then type whatever keybinding you like (in this case, it could be `C-y` to learn about yank or `C-k` to learn about kill) to see often quite a lot of documentation about the function being called.
WallyMetropolis · 2022-06-29 15:02
You can add those last two lines to the :config block instead of having them ouside of the use-package definition. I'm surprised that you have to `require` treemacs-all-the-icons, as `use-package` should handle that implicitly. Also do you have a typo? treemacs-all-the-icons loading after itself doesn't make much sense. Do you have use-package configured to automatically defer?
remillard · 2022-06-29 15:14
It's entirely possible I do not need them. The only thing I have set for `use-package` is `(use-package-always-ensure t)` so it's possible it's loading at each invocation. I just remember reading a lot in the `use-package` docs about the lazy loading and I don't know when it loads lazily and when it's active immediately. As for the `:after` clause, I think it's correct. It **IS** visually confusing though, because there's a space there between `treemacs` and `all-the-icons` which coincidentally is exactly lined up with the line below where there is a dash instead! :D The final two lines were from `treemacs-all-the-icons` documentations. I could try putting the final line in a `:config` section for sure.
remillard · 2022-06-29 15:19
And indeed doing the following seems to work just fine: (use-package treemacs-all-the-icons :after (treemacs all-the-icons) :config (treemacs-load-theme "all-the-icons"))
WallyMetropolis · 2022-06-29 16:21
Ah, yeah, didn't see the space. Ha!
sauntcartas · 2022-06-29 17:55
I recently discovered `thing-at-point-looking-at`, which seems much easier to use on its own than to fully define a new kind of "thing." For a while I've been wanting to conveniently identify a Jira ticket identifier at point so I can browse to it. Ticket IDs are basically a sequence of letters, a hyphen, and a sequence of digits. First I tried using `symbol-at-point`, but that can include extraneous neighboring characters, like `/` when the ticket ID is part of a URL. Eventually, while poring over the `thingatpt` source, I found `thing-at-point-looking-at`, which quickly led to: (defun browse-ticket-at-point () (interactive) (if (thing-at-point-looking-at (rx (+ alpha) "-" (+ digit))) (browse-url (format "https://jirahost/browse/%s" (match-string 0))) (error "No ticket at point"))) Easy peasy!
rucci99 · 2022-06-29 19:30
You might also like [bug-reference-mode](https://www.gnu.org/software/emacs/manual/html_node/emacs/Bug-Reference.html)
itistheblurstoftimes · 2022-06-30 01:38
Suddenly mbsync is giving me `Socket error: secure connect to outlook.office365.com . . . error . . . SSL routines:ssl3_get_record:wrong version number.` (I've omitted some numbers.) Any chance someone knows what is going on? There is too much work to do. Cannot fuck around with my emails.
itistheblurstoftimes · 2022-06-30 01:43
That was the error on port 143. I went back to 993 (which is where I was also getting a similar (but different) error). I switched SSLVersions to TLSv1.3 and now I get this ungodly error: `Socket error: secure connect to outlook.office365.com ... : Success.` I am lost.
styrg · 2022-06-30 18:51
Thanks, I think thats it!
styrg · 2022-06-30 18:51
Oh right, I always forget about C-h. Thanks! I usually explore in spacemacs by just pressing leader and exploring through various menus and searching in the docs and on the internet. This will help a lot!
E3D3redit · 2022-06-30 19:08
I don't know if this has anything to do with your configuration. My treemacs looks simular after each update of treemacs, until I restart Emacs. Too bad that I don't have a better solution, yet. Maybe I/we should ask it the friendly developper.
WallyMetropolis · 2022-06-30 19:24
Probably the single most important habit to establish when learning emacs is to take advantage of the gargantuan amount of built-in documentation. I've been using Emacs for more than a decade and still use the help tools weekly, sometimes daily. The manual is worth reading through, too.
remillard · 2022-06-30 21:36
Well everything seemed to sort itself out as on this machine I had not yet installed the font files. I think that was really the root cause.
github-alphapapa · 2022-07-01 05:41
Cool. The key of `thing-at-point-looking-at` is: "Return non-nil if point is in or just after a match for REGEXP."
github-alphapapa · 2022-07-01 05:41
Maybe Office365 changed some TLS settings on their end?
[deleted] · 2022-07-01 22:20
[deleted]
tryptych · 2022-07-03 06:23
Is it possible, using the common combination of `selectrum` \+ `orderless` \+ `consult`, to filter based on *groups*? For example, if I run `consult-ripgrep` in a project I will see a list of matching lines, grouped by file, but I may then want to limit by file-type. Is that possible? From what I can see, `orderless` only sees the matching lines (candidates), and grouping is done by `selectrum` which offers navigation (`M-}` / `M-{`) but not filtering.
itistheblurstoftimes · 2022-07-03 12:06
Still haven't figured out what happened but it started working the next day so Microsoft did something screwy. But fixed it in the meantime by setting up davmail and point mbsync to it instead.
[deleted] · 2022-07-03 18:33
[removed]
yigitemres · 2022-07-03 21:40
I have a question: Let's say that I have a `(defmacro macroa)`, `(defmacro macrob)` and `(defmacro macro_biggest)` macros. In my elisp file I do the following: (defmacro macro_biggest (...) .... `(macroa ,vars) `(macrob ,vars) ) When I call `(macro_biggest vars)` it works but only call `macrob`. When I modify `macro_biggest` to following: (defmacro macro_biggest (...) .... `(macrob ,vars) `(macroa ,vars) ) only calls `macroa`. I cannot figure how I call both macros. `progn` is not working. `(lambda () )` is not working.
Tohiko · 2022-07-04 09:38
A macro should return a list of forms to execute. So the easiest would be to do: ``` (defmacro macro_biggest (...) .... `(progn (macroa ,vars) (macrob ,vars))) ```
yigitemres · 2022-07-04 09:51
This is why I love elisp... When I try to do with `(progn)` I do the following: (progn `(macroa ,vars) `(macrob ,vars)) Thanks for the reminding me that I should be very careful where I put my backticks (BTW, I learn how to write macros yesterday, so mistakes is a good think IMO)... Thank you so much.
aisamu · 2022-07-04 21:05
I recently asked myself the same thing because I had to narrow down a project-wide `ripgrep` search to test files only. After not finding anything, I ended up using the following abominations (since we can forward raw flags to `rg` with `--`): * To search for `query` on all files under `__test__` folders - `#query -- -g*/__test__/*` * To search for `query` on files with unit on the file name. - `#query -- -g*unit*` But that's infinitely less convenient than something that'd allow us to filter groups "natively" (e.g. after a third `#` or something similar)
tryptych · 2022-07-04 23:56
Huh, TIL about using `--` there though, thanks :)
joncol79 · 2022-07-05 08:13
u/rucci99: Nice tip, didn't know about that mode. Do you know if there's any way to make the links appear also when exporting a buffer from within `org-mode`? I usually export to markdown to paste into Slack, but I'd need clickable links there, if possible...
rucci99 · 2022-07-05 08:22
[Yes, there is a way](https://orgmode.org/manual/Link-Abbreviations.html#Link-Abbreviations). It doesn't use bug-reference-mode, though.
joncol79 · 2022-07-05 09:02
OK, link abbreviations was what I was hoping to replace by bug-reference mode :).
Stefan-Kangas · 2022-07-05 13:27
The default `downcase-region` and `upcase-region` act also on an inactive region, which might not be what you want. So unbind them, and use the DWIM commands instead: ``` (global-set-key (kbd "M-c") #'capitalize-dwim) (global-set-key (kbd "M-u") #'upcase-dwim) (global-set-key (kbd "M-l") #'downcase-dwim) (global-unset-key (kbd "C-x C-l")) ; default is `downcase-region' (global-unset-key (kbd "C-x C-u")) ; default is `upcase-region' ```
remillard · 2022-07-05 15:22
Got a magit error I can't seem to work out. This is in Windows so there's confusion on where programs start and so forth, but I don't have the luxury of using something else (it's work) so this is what I've got. I've had it working before though. I have tested this with git at the command line, with a `git commit` and `git push origin` so I have tested CLI and the tool works fine, the configuration is fine. So this is definitely magit. I am testing my `.emacs.d` repository. I can do the `magit-status` and correction see the current status of the local repository. I made a small comment change to init.el and now magit correctly reports an unstaged change. I stage this and commit. During commit there's the following error: 0 git.exe … "add" "-u" "--" "init.el" 1 git.exe … "commit" "--" Waiting for Emacs... *ERROR*: Not inside Git repositoryerror: There was a problem with the editor '"c:/Program Files/Emacs/emacs-28.1/bin/emacsclient.exe"'. Please supply the message using either -m or -F option. I have not found anything relevant in Google searches. Most seems to fail even on status however as noted `git status` works fine. And all of this works fine in the command line. And on another computer this works completely fine with the identical init.el! So it's something in the environment on this machine in how it invokes emacs or something. Any ideas on this one? It's strange because of the inconsistent behavior between machines.
divinedominion · 2022-07-14 07:31
Did not know about this, that's amazing. Jira ticket links, here I come
divinedominion · 2022-07-14 07:32
Were you able to combine this with link-style fontification to make this appear clickable?
sauntcartas · 2022-07-14 17:13
No, I didn't try. I just wanted a browsing command I could invoke from any buffer, regardless of mode.