Emacs

314 readers
2 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 1 year ago
MODERATORS
376
 
 

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?

377
 
 

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.

378
 
 

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.

379
 
 

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.

380
 
 

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".

381
 
 

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.

382
 
 

What is the best version of Emacs?

For me, I LOVE MicroEmacs.

View Poll

383
 
 

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.

384
 
 

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.

385
 
 

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/

386
 
 

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?

387
 
 

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 )))))
388
 
 

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!

389
 
 

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?

390
391
 
 

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?

392
 
 

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?

393
 
 

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.

394
 
 

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?

395
 
 

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.

396
 
 

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?

397
 
 

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?

398
 
 

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!

399
 
 

It might be a bit controversial notion. But when I try to look for extensions say for completion framework there are many available and I used ido and then moved to ivy. I knew helm existed and is much more powerful in terms of feature-set, but never used it.

I read that emacs can report on keyboard usage (I think from xahlee's posts). Can it be repurposed to monitor which extensions are used often in users setup and they can share that report if they wish to public say via melpa like services. I suppose that melpa downloads can be used as a measure of usage.

400
 
 

When I use isearch-forward with cua keybindings enabled, then I still have to paste the text searched for in the minibuffer with C-y. When I use C-v then it pastes the text in the current buffer and not in the minibuffer. Is this correct behavior?

view more: ‹ prev next ›