Emacs

333 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 2 years ago
MODERATORS
376
 
 

Ever since DistroTube finished his Configuring Emacs series a couple of months ago, I moved from using (the somewhat monolithic and impenetrable in my opinion) Doom Emacs every now and then, to seriously using Emacs with his config about a month ago, and I've fallen in love. So much so that I clearly wanted to start using Emacs as my window manager.

I really like having a statusbar, so since I had been using dwm (also, if you want dwm-like window management, Edwina is the package for you), I figured it was finally time to set Polybar up. I did, but as many people experienced, Polybar had the issue of workspaces being off by one with the standard EMWH module. I looked around, and wasn't able to find the solution anywhere else, so I'll post my solution.

The crux of the problem lies in an assumption made in the code for switching workspaces, provided by the EXWM developers, namely the following code: I'm not even going to begin to fight Reddit's markdown on this one. The workspaces created are zero-indexed, which is all well and good for Polybar, but the bindings are where the problems come up. The code assigns workspace 0 to s-0, workspace 1 to s-1, etc. (and I don't claim to be any kind of Elisp guru, since as mentioned, I've only been seriously using Emacs for about a month or so). The problem is that the EWMH plugin counts workspace 0 as 1, workspace 1 as 2, etc., and also because of the way the bindings work, you end up with 10 total workspaces at the end.

The (mostly satisfying) solution I found is to change the last two lines of the mapping.... whatever you wanna call it. This maps workspace 0 to s-1, workspace 1 to s-2, etc. Naturally, this requires configuring exwm-workspace-number. (exwm-workspace-switch-create ,(- i 1)))))

(number-sequence 1 exwm-workspace-number))

There is a resulting issue with this solution though: the ninth workspace. The mapping thingamabob gets a bit upset if 10 gets passed into it, so you need to map s-9 manually, but that's easy enough to do with a short helper function. Something like (defun exwm-workspace-switch-to-9 () (interactive) (exwm-workspace-switch-create 8)) and then bind as you would any other global key. This allows the EWMH module to work just fine, without any need for any hooks or anything like that. Outside of having to define another function, this is about the most satisfying solution I've been able to come up with. Naturally, if anyone has any even-more-elegant solution, I'd love to hear it, but I'm plenty happy with this. This way, polybar is able to show what workspaces EXWM buffers are open on, alerts, etc.

377
 
 

I have been experimenting with PlantUML in Org Babel recently, and it has greatly enhanced my ability to visualize concepts mentally. During post-meal walks, I often engage in mental planning exercises, such as sketching Gantt charts. However, my deficient drawing abilities consistently impede my progress, particularly when it comes to mentally manipulating lines, arrows, and objects. Since discovering PlantUML, the visualization skills have steadily improved, thanks to its intuitive text-to-graph syntax.

When reading "Marcovaldo: Or, The Seasons in the City" before bedtime for sleep aid, I spend a significant amount of time immersed in its pleasing pages, sometimes without a clear sense of progress. In such instances, I draw a Gantt chart to gain a visual representation of the slow progress.

@startgantt
Project starts 2023-10-02
[Reading Marcovaldo] lasts 2 weeks and 4 days and is 30% completed
@endgantt

https://preview.redd.it/gqhuh7g9f6vb1.png?width=587&format=png&auto=webp&s=74df6808ae7e6b5baa53ded20991d72552f41b5f

This chart illustrates that the book is being read slowly, and at the current pace, it will take another three weeks to complete.

PlantUML's Gantt chart is expressive, it mimic task bars as [ ] , specify durations with the "lasts" keyword, and "complete" to indicate progress with percentages. This helps to construct mental diagrams and translate thoughts or words into visual representations effortlessly, eliminating the need for manual drawing of lines, arrows, and objects. This feature is particularly beneficial for individuals with limited drawing skills.

PlantUML's Gantt chart functionality goes beyond planning in days, months, and other timeframes. It can also be adapted to manage a single day effectively. Although the smallest unit in PlantUML is a day, it can be flexibly adjusted to represent hours within a day. This means that a Gantt chart spanning 24 days can be used to represent 24 hours each.

@startgantt
!theme mono
[Sleeping] starts on D+0 and lasts 5 days

then [Wakeup@05:45] as [Wake] happens on D+5
then [Breakfast] lasts 1 day and is displayed on the same row as [Sleeping]
then [Morning-Tasks] starts D+8 and lasts 3 days
then [Lunch] starts on D+11 and lasts 1 day and is displayed on the same row as [Breakfast]
then [Afternoon-Tasks] as [Afternoon] lasts 5 days and is 50% completed
then [Dinner] starts on D+17 and lasts 1 day and is displayed on the same row as [Lunch]
then [Evening-Tasks] lasts 4 days
then [Bedtime@22:45] happens on D+21 and is displayed on the same row as [Wake]
then [Sleep] lasts 1 day and is displayed on the same row as [Sleeping]

Separator just at [Sleeping]'s end
'Separator just at [Dinner]'s end
Separator just at [Evening-Tasks]'s end
printscale daily zoom 1.8
'highlight today
today is 14 days after start and is colored in lightgray
'Label on the first column and right-aligned

hide footbox
@endgantt

https://preview.redd.it/duh8uv1jf6vb1.png?width=758&format=png&auto=webp&s=59d72d860bb96048c3a7eaea9140df1828f51681

Just like a wizard casting spells in PlantUML, you can conjure a vivid visualization of the complete panorama of a day in mind. Whether during walks, bedtime, or while commuting on the subway, by consistently practicing and leveraging the unique features of PlantUML, you will unlock the untapped mental prowess for visualization and creativity.

378
 
 

I had a very great setup using app-specific password till now. But now want to move to oauth2 because app-specific passwords will not work any more. So I changed my settings as follows,

;; older setting
;; ...
     (nnimap "gmail"
             (nnimap-address "imap.gmail.com")
             (nnimap-inbox "INBOX")
             (nnimap-expunge immediately)
             (nnimap-stream ssl))
;; ...

I looked for a solution, or rather asked ChatGPT about the oauth2.el thing. And it suggested the following,

;; new settings
;; ...
     (nnimap "gml"
             (nnimap-address "imap.gmail.com")
             (nnimap-inbox "INBOX")
             (nnimap-expunge immediately)
             (nnimap-stream ssl)
             (nnimap-authenticator oauth2)
             (nnimap-oauth2-client-id "client-id")
             (nnimap-oauth2-client-secret "client-secret")
             (nnimap-oauth2-credentials "~/.emacs.d/.gmail.oauth2-token"))
;; ...

I created a new project in Google Cloud Console, enabled Gmail API and generated client-id and client-secret for the above. But this doesn't seem to be working. When I launch Gnus (M-x gnus), it is stuck at "Openning connection to imap.gmail.com via tls...". Default browser is not launched for the oauth2 workflow.

I have tested the following code. It launches the default browser and works just fine,

(require 'oauth2)
(defvar my-oauth2-token 
  (oauth2-auth-and-store "https://accounts.google.com/o/oauth2/auth"
                         "https://accounts.google.com/o/oauth2/token"
                         "https://www.googleapis.com/auth/userinfo.email"
                         "client-id"
			 "client-secret"))

Has anyone here done this kind of configuration - gnus+gmail+oauth2?

379
 
 

I just uploaded the latest version of Emacs Writing Studio, a configuration and manual for authors seeking to use Emacs.

Next step: convert the webpage into a book with enhanced content.

380
 
 

Hi, I wanted to come into the Emacs Reddit server for the best advice I could possibly get to learning Emacs. I switched recently from a normal code editor and as of right now, Emacs is kind of hard to get the hang of. All I need is for someone to give me advice on where I might find help, Including YouTube, forums, etc.

381
 
 

Weird issue on my windows 11 computer where scrolling w the touchpad only moves the page up, not down. Regardless of which direction I am trying to scroll. Works on my other windows computer fine, same .emacs file and everything.

Anyone have any ideas?? Searched around the web and didn’t find anything.

382
 
 

I'm an Emacs newbie (using Doom Emacs with GNU Emacs 29.1). I came from vim, and battling with undo there was crazy enough, but I won using this:

inoremap  u
inoremap  u
inoremap  u
inoremap  u
inoremap  u
inoremap  u
inoremap  u
inoremap , ,u
inoremap . .u
inoremap ( (u
inoremap [ [u
inoremap = =u
inoremap \" \"u
inoremap  u
inoremap  u

Also, I had autogroup that breaks undo every 4 seconds.

Basically, this configuration breaks undo on almost every possible type command, every Spacebar, Enter, comma, bracket, moving up, down, everything. This is because I hate when undo deletes the whole screen of text.

How do I replicate this in Emacs? I read this, but it doesn't say what is considered a "recent change".

383
 
 

For speed, I wish to disable everything that a language server (in this case clangd) provides *except* for code completion. I use eglot. How would I do this?

PS: No I don't want to use lsp-bridge because I want my own custom completion style.

384
 
 

What is the best version of Emacs?

For me, I LOVE MicroEmacs.

View Poll

385
 
 

I have a bunch of one off functions to do frame/window layout. But an issue I run into is that if I do, say

(set-frame-size (selected-frame) 255 80)
(some-other-function-that-looks-at-frame-size-to-split-windows)

Half the time the resize hasn't finished by the time the split function runs, and so it splits incorrectly. I'm assuming the resize happens asynchronously, but I don't see a hook or event I can make use of to make sure I'm splitting after the fact. Is there something I'm missing? Sleeping doesn't seem to fix it because that just delays the resize as well.

386
 
 

I use pdf-tools for reading and recently started using bookmark+ and dired+ for navigating. Unfortunately these two great packages seems to conflict.

One of the issues I noticed was that the bookmark+ command for bookmarking a pdf location in a pdf-tools buffer didn't work; it gave an empty buffer warning. Turns out bookmark+ creator Drew Adams had already suggested a workaround which I discovered here: https://emacs.stackexchange.com/questions/72786/bookmark-plus-and-pdf-tools-pdf-view-error

So that solved or at least patched that issue. But then I noticed that with dired+ installed and any fairly large pdf opened in pdf-tools, emacs will freeze if you attempt to do dired-jump or helm-find-files. Dired-jump without dired+ is not affected by the size of the pdf at all and just opens the underlying directory immediately. But with dired+ anything above about 1mb or so hangs it for quite a while, anything around 10mb or more just freezes it for minutes on end to the point that unless you want to go make yourself lunch and coffee, you will have to force kill emacs to keep working.

As a noob, non-techie, non-developer, I just wanted to ask, what is the right way of asking about possibly getting this issue fixed, because I love these two packages and would love to have both in working order, but obviously don't have the coding know how to do it myself. Of course if anybody knows of a fix that's already out there for this issue, I'd love to know about that as well.

387
 
 

Now that I'm back, the series continues. Today we start the emoji-replace project. When we're done we'll have a mode where you can type an emoji name in a buffer like :dog: and it will be replaced with the emoji.

Here's part 1:

https://cestlaz.github.io/post/learning-elisp-11/

388
 
 

For some reason, when I click a button, be it in the customize buffer or hyperlinks in org documents, it sometimes works, and other times the whole buffer shifts to the left like a single pixel and it sets a mark (it says so in the minibuffer). The button is not clicked in those instances.

Has someone experienced something similar? Is there a way to improve this?

389
 
 

Drag and drop files into bibtex

I found code here dnd images into auxtex. I am using the excellent Zotra package. I modified the dnd to auctex code to allow drag and drop pdf files into bibtex. My attempt below works. It creates a bibtex "file" field and fills it with the link to the file. However, it would be nice if I could add the following functionality: change the path of the uri to the directory citar-library-paths, change the file-name (excl ext) to the bib-key, move the file to the new path and then sets the file field. This will be useful when one has to manually add files to the bibtex database (in case where the Zotero translation server doesn't find the file. Any help or pointers to a package that works similarly would be appreciated.

(defcustom BIBTex-dnd-protocol-alist
  '(("^file:///" . BIBTex-dnd-bibtex-file)
    ("^file://"  . BIBTex-dnd-bibtex-file)
    ("^file:"    . BIBTex-dnd-bibtex-file))
  "The functions to call when a drop in a .bib file is made."
  :type '(choice (repeat (cons (regexp) (function))))
  :group 'bibtex)



(define-minor-mode BIBTex-dnd-mode
  "Minor mode to insert the name and full path of a dropped file into the 'file' entry of a .bib file."
  :lighter " DND"
  (when (boundp 'dnd-protocol-alist)
    (if BIBTex-dnd-mode
        (set (make-local-variable 'dnd-protocol-alist)
             (append BIBTex-dnd-protocol-alist 'dnd-protocol-alist))
      (kill-local-variable 'dnd-protocol-alist))))


(defun BIBTex-dnd-bibtex-file (uri action)
  "Insert the name and full path of a dropped file into the 'file' entry of a .bib file."
  (when (equal major-mode 'bibtex-mode)
    (let ((file (dnd-get-local-file-name uri t)))
      (when (and file (file-regular-p file))
        (bibtex-set-field "file" file )))))
390
 
 

I have recently approached the world of Emacs, which I find great... The problem though is that I feel I'm wasting too much time trying to have it running in order to do the real work (and I've seen, there are several memes about it), so I was wondering what are the must-have extensions to quickly fire something functional (similar to vscode... Don't make me get back to that please) for development.

By the way, I've seen several configurations scattered around the web, and something tells me that I've ended up in another anarchic realm (which is, something I both hate and love), as if that of distros -being the same except for one thing- wasn't enough.

Of interest are: Python, Go, Bash, Clojure, Elixir, yaml (Docker, Terraform, Ansible), json, csv

I would also appreciate the general must-have extensions, currently I'm getting lost navigating Doom Emacs and Melpa packages.

Thank you!

391
 
 

I've been away from this Lemmy community for a while (because something went wrong with both my Lemmy clients 🤷‍♀️) and now that I'm back I see that it shares a lot of post and comments with r/emacs. How does that work? Is this automated? Are people just posting the same thing in both places?

392
393
 
 

Hello,

Anyone aware of any package/code snipped that could replicate the paste behavior of vs code? To elaborate what I mean by that. When I copy image in file manager and paste it in a markdown file in vscode it automatically converts it into relative path from the current file. Alternatively is there a way to auto complete in the `C-c C-i` mini buffer?

394
 
 

Hello, I usually run the same command with async-shell-command, however I have to navigate back to the last command history to trigger my last run command, is there any way async-shell-command (and shell-command) can autofill with last run command so that I just hit enter without extra steps?

395
 
 

Hey guys, took me a while to figure this out since there isn't much information about this anywhere so I figured I'd leave this here for anyone else having the same issue.

If you're a terminal aficionado and you're using Kitty, all you have to do is install kkp.el and enable it in your config and all keybindings will work properly.

396
 
 

I'd like magit-status to open full frame, ie a single window. When I hit q to exit, I'd like my previous window configuration to be restored.

What's the best way to do this? Setting the follow var causes it to open full frame, but removes all windows except for one upon exit:

 (setq magit-display-buffer-function
  #'magit-display-buffer-fullframe-status-v1)

I can get to my previous window layout with winner-undo, but I'd like q to do the right thing in this case.

Any thoughts?

397
 
 

I am not skilled in drawing, but after trying PlantUML, I found that I can create visual representations directly using code. This has greatly aided my spatial imagination.

Take, for example, the usecases diagram:

@startuml
:user: -right-> (Right)
:user: -up-> (Up)
@enduml

https://preview.redd.it/1bx7h7sa7vub1.png?width=152&format=png&auto=webp&s=6271256f6855b88a93a62abf63569f1bc542ded5

With the use of directional terms like "up" and "right," you can intuitively draw the diagram as shown. it lowers barrier for non-artists - no drawing ability needed and focuses thought process on structural elements and relationships.

When immersed in text, our spatial imagination can often become less active. For example, when trying to imagine the hierarchical structure of an article such as org-mode, our mental representation tends to be more like a bullet structure in an editor, rather than a graphical tree structure.

PlantUML addresses the challenge of limited spatial imagination by providing an intuitive text-graph syntax. One notable feature is the Work Breakdown Structure (WBS) functionality.

Consider the following example:

@startwbs
!theme mono
    Emamcs
    ** Texting Editing
    ** Note taking
    ** File Manager
    ** Literature Programming
@endwbs

https://preview.redd.it/95b2mg6w9vub1.png?width=567&format=png&auto=webp&s=2e0f00c54e4d411ec731eba7b23a46a665ed78fc

The WBS feature in PlantUML facilitates the effortless transformation of a vertical structure into a horizontal representation. This allows me to mentally interpret and visualize the PlantUML code, automatically converting the vertical structure into a spatially-oriented horizontal structure in mind. Consequently, it effectively resolves the issue of my limited visual imagination and improving it continually.

398
 
 

When I installed doom emacs, I added lsp, c and c++ support and other things to init.el. When I started writing code in C, after adding the header file, auto completion advised me to add a comment to the code and other strange things. What could this be related to?

399
 
 

Hey there,

Maybe I'm just missing something obvious, but I'm a little bit confused as to how eat-eshell-mode works. If I, for example, fire up Eshell with Eat installed:

(elpaca-test
  :interactive t
  :init
  (elpaca eat (eat-eshell-mode))
  (eshell))

Then I try running e.g. top, I'd expect top to open in an Eat buffer, but it's not doing that for me right now: it just opens in plain ol' dumpy Term mode.

What am I missing? Is this not what Eshell integration is supposed to do? How do you use Eshell and Eat together?

400
 
 

I use dwm in my laptop, but previously used i3wm for a few years. I'm curious about:

  • How well EXWM performs nowadays?
  • Is it resource heavy compared to other tiling window managers?
  • Is it still an issue EXWM not being multi-threaded?

My daily tasks involves just opening chrome, telegram and/or slack, watching movies and coding of course. Would it be a good fit for my needs?

I'd love to know your thoughts if you use or have some previous experience with EXWM. Thank you in advance!

view more: ‹ prev next ›