Emacs

297 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 1 year ago
MODERATORS
51
 
 

I'm using Emacs Mac from Homebrew on my M1 Macbook Pro with the notch, and when I toggle fullscreen using (toggle-frame-fullscreen) I see that part of the top line of text gets hidden by the notch (like in image). In other applications fullscreen omits the entire top height of the notch, but for some reason Emacs fullscreen isn't like other native fullscreen - the Emacs frame occupies the entire screen but is still in the Desktop space. So I lose words in the middle of the top line. How can I avoid this situation? I don't see a ns-use-native-fullscreen variable (or any variables containing the words "ns", "native", or "fullscreen" that are useful).

https://preview.redd.it/fonw4bxbrf3c1.png?width=2982&format=png&auto=webp&s=fe9699c278f66944d4dcbb0ed6240cd93674fb65

52
 
 

Hello emacs and Lisp enthusiasts,

I remember seeing an article that talked about the superfluity of parenthesis in Lisp code, and how non-Lisp programmers were overwhelmed by them, but Lisp programmers had trained their eyes to look at indentation structure and didn't see the parenthesis, and it showed an image of Lisp code without and with the parenthesis faded. I don't have a link to the article, but even as a slightly seasoned Lisper I thought the fainter parenthesis improved readability.

So I'm wondering if/how it's possible to achieve this effect in emacs. Is there already a minor-mode for it? Would it involve a font-lock/face for parenthesis? I've tried to navigate the syntax highlighting code before and was a bit turned off by the apparent complexity, so any form of introduction would be greatly appreciated.

53
 
 

ultra-scroll-mac: scroll like lightning

Emacs-mac is a beautiful port, and was the first to offer pixel-precise smooth scrolling nearly a decade ago. But with modern high-resolution trackpads and high density displays, I found its scrolling handlers just couldn't keep up. On large, full-screen buffers in a heavy mode, trackpad scrolling verged on painful, and, maddeningly, was much worse in one direction than the other. And no wonder: modern trackpads deliver scroll events >50⨉ per second! The other key problem with all known smooth scrolling packages is they tend to stutter and loop back as you try to scroll across images taller than the window.

This package solves both of these problems:

  • Scrolling performance has been increased 25-50⨉ — you move your fingers, the page responds, instantly.
  • Large image handling has been worked around so you can scroll right across them without any hiccups.
  • As a bonus, dumb mice get pretty good smooth(-ish) scrolling too.

I'll be contributing the core scrolling functions upstream, so hopefully pixel-precision-scroll-mode (which inspired this package, and is recommended on other builds) can make use of some of these improvements in the future.

Finally, this was all (to me) surprisingly hard to achieve, which you can read all about if you are a glutton.

54
 
 

Hello I'm having some troubles fixing the next error.

Error (use-package): aas/:config: Condition must be either nil or a function

the source of code is:

(use-package aas
  :hook (LaTeX-mode . aas-activate-for-major-mode)
  :hook (org-mode . aas-activate-for-major-mode)
  :config
  (aas-set-snippets 'org-mode

    ;; set condition!
    :cond #'texmathp ; expand only while in math

   "fr" '(yas "\\frac{$1}{$2}$0") 
   "lr(" '(yas "\\left( $1 \\right)$0") 
   "lr[" '(yas "\\left[ $1 \\right]$0")
   "lr{" '(yas "\\left\\\\{ $1 \\right\\\\}$0")
   "lr|" '(yas "\\left| $1 \\right|$0")
   "lr<" '(yas "\\left\\langle $1 \\right\\rangle$0")
   "sqr" '(yas "\\sqrt{$1}$0")
   "cbr" '(yas "\\sqrt[3]{$1}$0")
   "nthr" '(yas "\\sqrt[$1]{$2}$0")
   "dint" '(yas "\\int_{$1}^{$2}{$3 d$4}$0")
   "int" '(yas "\\int{$1 d$2}$0")
   "lim" '(yas "\\lim_{$1 \\to $2}{$3}$0")
   "neq" '(yas "\\neq $0")
   "geq" '(yas "\\geq $0")
   "leq" '(yas "\\leq $0")
   "sim" '(yas "\\sim $0")
   "->"  '(yas "\\to $0")
   "=>"  '(yas "\\implies $0")
   "inn" '(yas "\\in $0")
   "set" '(yas "\\\\{$1 \\\\}$0")
   "cc"  '(yas "\\subset $0")
   "EE"   '(yas "\\exists $0")
   "nEE"  '(yas "\\nexists $0")
   "VV"   '(yas "\\forall $0")
   "xx"   '(yas "\\times $0")
   "..."  '(yas "\\dots $0")
   ";."   '(yas "\\vdots $0")
   ";/"   '(yas "\\ddots $0")

   
    )

(aas-set-snippets 'org-mode

    "mk" '(yas "$$0$") 
    "md" '(yas "$$ $0 $$")
))

I think the problem is in the line :cond #'texmathp.

Thanks in advance!

55
 
 

If a site asks one to authenticate with some web service like Twitter, Github, Reddit, Goole, etc, how do you do this programmatically from Elisp, if it is even possible to do so? I have looked in the manual and did a web search but honestly, I am lost on this.

I want to automate something and am downloading content from a website, but in order to be able to download it, one has to "sign-in" via some of those above-mentioned, for the content to be generated and served.

56
 
 

tl;dr I'm a noob using DooM and it seems I don't understand variables

Firstly; please forgive the gratuitous image of my RGB Steamdeck / Corne / DOOM Emacs "coffee shop" setup - I'm just enjoying it at the mo, and have a burning desire to share.

After a quick play with Zone I'm trying to setup zone-matrix as my "screensaver"

I did the following:

  1. Pulled the files from zone-matrix githib to .emacs.d/zone/
  2. Added the following to my in my config.el. I realised I was comitting heresy for copying another person's config (from a stackexchange answer) and braced myself for errors;
(defun tabbar-mode () (lambda (x) (message "%s")))
(add-to-list 'load-path (concat dotfiles-dir "zone"))
(require 'zone-matrix)
(require 'zone-matrix-settings)
(require 'zone-settings)

(setq zone-programs [zone-matrix])
(zone-when-idle 60)

After a doom sync I get an (to be honest expected) error void-variable dotfiles-dir.

The issue I have is with the definition dotfiles-dir - I clearly don't have that variable set, and wonder which of the following is the least-worst approach:

  1. Because I'm on DooM there is probably already a similar variable set linking to .config/doom/ am I better putting the zone directory in there? If so, do I hard-code the path in the line containing dotfiles-dir?

  2. Should I define a dotfiles-dir or zone-matrix-dir instead? I assume that flies in the face of dotfile conventions?

I'd love to hear your thoughts

57
 
 

Hi,

as nvim-user I am just starting out with orgmode and want to use emacs on 4 systems: 2 linux-boxes and 2 android-systems.

The linux-boxes run emacs 29, on android (in a termux/proot environment) the emacs version currently is 27.

I am using emacs only for orgmode with evil-mode and the modus-themes.

What I want is to have the same environment on all machines and so this is my plan:

I will use syncthing to sync all my org-files as well as the init.el between all machines and in the init.el I will only load packages with use-package.

So the idea is that when I e.g. introduce a new package on one machine, the new config is synced to the other machines and when I start emacs there the package is installed automatically - everything stays in sync.

My question: Would that work in practice or are there pitfalls I am not aware of?

58
 
 

Context: I was using debian 12 with KDE Plasma, long story short I have to reinstall debian 12 with xfce, I use the same configuration file for emacs (it used to work fine in debian 12 with KDE) but in this new debian I got this message:

Warning (Emacs): elpaca version mismatch

Note 2: I didnt install emacs from the debian repositories because they dont have the version 29.1 so I compile myself the source.

59
 
 

There's also a small wrapper for the GitHub CLI. I should call this a "survival kit for corporate life". But since I'm not that creative, "emacs-utils" it is:

https://git.sr.ht/~sebasmonia/emacs-utils

Story below:

I've had versions of a piece of code to pull info from JIRA, in private repos associated with different jobs, for years now.
When I started my current gig I realized I should put that code in a public place, and maybe someone would write a "proper" JIRA package out of it. If anything, this lets you read details and comments (doesn't do inline images nor attachments). I find it useful in its current state and maybe some of you will too.

And last weekend I wrote a Confluence reader. After being BEYOND ANNOYED that you can't read pages without JS.I remember the old (and good) versions of Confluence that didn't force the fancy editor down your throat and you could write everything in wiki markup...anyway.
The reader detects when a link isn't external, so it doesn't send you to EWW. It doesn't work in 100% of the cases, will probably revisit that code.

Oh and both JIRA and Confluence support Emacs' bookmarks, thank to EWW's implementation and our beloved editor being open in the truest sense of the word.

60
 
 

Hi,

every time I try to get into orgmode (which is great) I have to deal with emacs (I ususally use nvim) and I feel that regardless of any productivity boost orgmode may give me, I will never recover the time I have wasted with emacs configuration issues - it seems to be just a very, very fragile ecosystem...

Here is the latest problem:

I want to use the modus-operandi theme and have added a use-package clause copied from the documentation.

But now when I open emacs I get a prompt, informing me that loading a theme can run lisp code and if I wanted to proceed, I say yes, I am asked if this theme should be deemed safe for future sessions, I say yes and then the theme loads fine - but only for this sesssion.

When I close emacs the whole thing starts again, so my question is: How can I get rid of this annoying prompt?

61
 
 

Is there a way to replace all hyperlinks in a buffer with some shorthand phrase say "link" while keeping them as clickable links to their respective site?

I've been importing csv files as tables and one of the columns stores links but they're quite long and making things awkward looking so I'd like to replace them with some shorthand.

Sorry, probably a noob question, still new.

62
 
 

Hi guys, sometimes I try something new to compare with already used packages, this weekend I wanted to try Eglot, however, I ran into a number of problems. One of them is autocomplete.

For example, when I write in vue, I want to autocomplete a watch function. This function is available in the following packages

import { watch } from 'vue';
import { watch } from 'fs';
import { watch } from 'fs/promises'
... etc

But when I use autocomplete in eglot I only see the first candidate - importing from the fs package. Is there any possibility or workaround to display all possible candidates?

Example of autocomplete with eglot

https://preview.redd.it/tlgtg5imw43c1.jpg?width=2930&format=pjpg&auto=webp&s=7f0cd2ff1b6733ec26021b77b6e5e392f26921df

Example of autocomplete with lsp-mode

https://preview.redd.it/rcntp2vow43c1.jpg?width=1224&format=pjpg&auto=webp&s=a246d790c47b4d48a3fba5e5f1cb361841eccc02

I also know that lsp-mode in conjunction with corfu has a similar problem, but it is impossible to solve it there as the authors of both packages think that the problem is not on their side 😅 Is the situation with eglot the same?

63
 
 

I have a few newbie questions about theme customisation. In the doom-one-theme.el file, all of the colour definitions have 3 arguments, commented as being "default", "256", and "16".

  ;; name        default   256           16
  ((bg         '("#282c34" "black"       "black"  ))
   (fg         '("#bbc2cf" "#bfbfbf"     "brightwhite"  ))

My best guess is that these refer to colour depths, but I'm feeling a bit out of my depth here (hah!). My questions are as follows:

  1. How does Emacs decide which colour/depth to use?
  2. Are these fields all required, or are they customary/nice to have?
  3. Why are some colours hexes and others strings? Do the strings refer to some table somewhere with more hexes?

I would be extremely grateful for any clarity and/or links to relevant documentation where I can learn more!

Thanks

64
 
 

I recently picked up a new project that uses React. Out of the box, my configuration doesn't seem to be doing very well -- indentation is erratic (sometimes thrown off by JSX), no lsp-rename, and generally things are slow.

Are there any generally recommended approaches for React development with Emacs? Language server, minor modes, tree-sitter, etc? There seem to be a lot of options and modes available.

The codebase is currently JavaScript and JSX, but I'm considering Typescript and TSX down the line. Should I just default to the TypeScript tooling?

65
66
 
 

I'm trying to make the headers view use a smaller font size than my default. At first, I thought I could just fiddle with text-scale-set and the hooks in mu4e-headers-mode-hook, but that doesn't seem to affect the header-line. I've tried also doing a face-remap for the header-line, but when I do it that way I can't then adjust the font size further. Any advice?

67
 
 

I am happy to announce the release of Transient version 0.5.0.

More information can be found in a blog post.

Please consider supporting my work on Magit, Transient and many other Emacs packages and projects.

68
 
 

What ever org-roam command the I run I get the following error Error running timer: (error "Selecting deleted buffer").

This Doom Emacs install is on a fresh Ubuntu 22.04.3 LTS, and I have also tried Ubuntu 23.10.1 (Mantic Minotaur) and still the same error.

This is my org-roam configuration:

(use-package! org-roam
  :ensure t
  :init
  (setq org-roam-v2-ack t)
  :custom
  (org-roam-directory "~/RoamNotes")
  (org-roam-completion-everywhere t)
  (org-roam-dailies-capture-templates
    '(("d" "default" entry "* %<%I:%M %p>: %?"
       :if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))))
  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
         ("C-c n i" . org-roam-node-insert)
         :map org-mode-map
         ("C-M-i" . completion-at-point)
         :map org-roam-dailies-map
         ("Y" . org-roam-dailies-capture-yesterday)
         ("T" . org-roam-dailies-capture-tomorrow))
  :bind-keymap
  ("C-c n d" . org-roam-dailies-map)
  :config
  (require 'org-roam-dailies) ;; Ensure the keymap is available
  (org-roam-db-autosync-mode))

This is the backtrace of the error:

  set-buffer(#)
  (save-current-buffer (set-buffer buf) (org-reveal '(4)))
  (closure ((buf . #)) nil (save-current-buffer (set-buffer buf) (org-reveal '(4))))()
  apply((closure ((buf . #)) nil (save-current-buffer (set-buffer buf) (org-reveal '(4)))) nil)
  timer-event-handler([t 25958 838 237811 nil (closure ((buf . #)) nil (save-current-buffer (set-buffer buf) (org-reveal '(4)))) nil nil 85000 nil])

I have tried the following:

  • Delete the org-roam-db and then run org-roam-db-sync.
  • Going into emacsql directory >> sqlite and running make.

Thank you all in advance.

69
 
 

I'm a "Neovim Refugee" trying to get a deeper/better understanding of how emacs lisp works and how i can use it to expand on my emacs setup. I have never done anything in lisp before and still struggle to understand how single quotes signify a function or what ever.

With that said, i was also planning on doing AoC this year. Originally i wanted to look into zig or go, but now think that this might be the opportunity to dive into lisp for a bit.

But with knowing basically nothing: Is this even "viable", or advisable? Should i be looking at common lisp instead? Or would you say that's a pretty dumb idea and i should rather learn it in a different way?

70
 
 

For example, let's say I were to change backward-delete-char-untabify-method for prog-mode buffers. Naively, I'd write something like,

(add-hook 'prog-mode-hook (lambda ()
                       (setq-local backward-delete-char-untabify-method 'hungry)))

but the documentation recommends against using lambdas in add-hook calls (which makes sense). I can, of course, just make a named function instead of a lambda and pass that to add-hooks. But, rather than do that, is there any other option for setting variables automatically for modes besides a hook like this?

Also, as a bonus question, if I wanted to also do something like enable show-paren-mode for all prog-mode buffers, which of the following do you consider "better" (assume that this is not something that is likely to change frequently):

;; option 1
(defun my-prog-mode-settings ()
  (setq-local backward-delete-char-untabify-method 'hungry))

(add-hook 'prog-mode-hook #'my-prog-mode-settings)
(add-hook 'prog-mode-hook #'show-paren-mode)

;; option 2
(defun my-prog-mode-settings ()
  (setq-local backward-delete-char-untabify-method 'hungry)
  (show-paren-mode))

(add-hook 'prog-mode-hook #'my-prog-mode-settings)

Obviously, I realize that it's not really important, but I feel like bike-shedding this morning.

71
 
 

Imagine selecting a paragraph and having ChatGPT automatically correct grammar and spelling errors, then seamlessly replacing it in your buffer. Well, imagine no more - it's now a reality!

Here's what it does:

  • Selects the current paragraph in Emacs.
  • Sends it to ChatGPT for a grammar and spelling check.
  • Replaces the original text with the corrected version, all within Emacs.

Inception:

The other night I read a post on X that said LLMs would be used to enhance word prediction for texting on phones. I thought another interesting application would be to easily bring spelling and grammar fixes to whatever I'm editing in emacs.

It's not flawless, but in my experience, it's all I need.

Here's a video example: https://youtu.be/hrhoNE2M9Qw

Here's the gist: https://gist.github.com/ckopsa/c55bf8cc25df8a4a87c6993bdce3573e

Leverages chatgpt-shell found here: https://github.com/xenodium/chatgpt-shell

72
73
 
 

Hi, basically it is working well but I want to remove repetitive msg when evaluated to REPL.

for instance, when below code

nums = [1, 2, 3, 4, 5]
def double(x): return x * 2
list(map(double, nums))

is evaluated by C-c C-c

>>> 
__PYTHON_EL_eval("nums = [1, 2, 3, 4, 5]\ndef double(x): return x * 2\nlist(map(double, nums))", "/Users/darren/Work/ace/pyth/codi/01-iterations/binary-gap.py")
[2, 4, 6, 8, 10]

Can I remove this msg?

__PYTHON_EL_eval("nums = [1, 2, 3, 4, 5]\ndef double(x): return x * 2\nlist(map(double, nums))", "/Users/darren/Work/ace/pyth/codi/01-iterations/binary-gap.py")

So it just shows like

>>> 
[2, 4, 6, 8, 10]

Thanks in advance!

74
 
 

Is there a package that provides : commands like evil-ex, but without the rest of evil-mode? I'm specifically interested in regexp replacement :s/old/new/g style.

If not I'll write one

75
 
 

Just found a quick way to have tags always right aligned, taking advantage of font-lock and display property.

(add-to-list 'font-lock-extra-managed-props 'display)
(font-lock-add-keywords 'org-mode
  `(("^.*?\\( \\)\\(:[[:alnum:]_@#%:]+:\\)$"
     (1 `(face nil
          display (space :align-to (- right ,(length (match-string 2)) 3)))
        prepend))) t)
view more: ‹ prev next ›