Emacs

352 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
51
 
 

What's the best practice to have your custom elisp natively compiled, along with external packages?

So far I've only succeeded by doing the following:

  • Move my custom elisp to a new file (emacs-lib.el) which starts with (provide 'emacs-lib)

  • Manually run emacs-lisp-native-compile-and-load while visiting that file

  • Change my init file to load the library:

    (setq elisp-dir "~/config/elisp") (add-to-list 'load-path elisp-dir) (require 'emacs-lib)

After restarting Emacs, I've checked that many of my custom functions are indeed native-compiled.

It would be nice if I could have my init file take care of compiling the library when missing or outdated. Even better if I didn't need the separate file, but that's no big deal.

52
 
 

I wrote a library that lets you cycle through the available themes in Emacs. F10 and shift-F10 keys will cycle forward and backward through the themes. The theme name is printed for reference.

https://github.com/tsengf/theme-cycle

Installation
Download theme-cycle.el into ~/.emacs.d.

Add the following to your Emacs configuration

(add-to-list 'load-path (expand-file-name "~/.emacs.d)
(require 'theme-cycle)
;; Load as many themes as you are interested in exploring.
(use-package doom-themes)
(use-package ef-themes)
(use-package modus-themes)
(use-package solarized-themes)

To Use

Use F10 to cycle forward through the themes. Use shift-F10 to cycle backward through the themes.

53
 
 

I have a setup that sort of gives what I'm looking for, but Emacs complains that I'm not doing it right.

I have a large number of org-mode appointments that depend on the date of Easter. They are currently in the form of diary sexp, but I don't really care what form they're in; what I'm really trying to find is a general solution to "When today is X days before Easter, show arbitrary message 'X' in the org agenda. When today is Y days after Easter, show arbitrary message 'Y' in the org agenda." (In all of my cases, Easter means "the Easter within the current calendar year".)

Emacs elegantly figures out the correct date for Easter, but Emacs also has a hard-coded list of Christian holidays that aren't useful to me. Instead of a new hard-coded list of holidays, I'm looking to make arbitrary and changeable use of the Easter calculation - compared to today - without showing any holidays at all.

54
 
 

TLDR: I really want to learn emacs, getting frustrated with the basics and seeking help. Can't install use-package on my mac installation of emacs.

I've been using neovim for awhile but have been increasingly frustrated with not being able to understand how things work when they break down. Hoping to learn emacs for fun and maybe to even replace/improve my nvim workflows.

Things went well at first. I followed the tutorial and got used to some basic navigation as well as window and buffer navigation. I LOVE being able to `C-h` for functions, keys, and variables.

I decided it was time to start trying to configure things and installing packages. I'm not patient enough to watch 10 hours of system crafters videos and didn't really want to buy Mastering Emacs, so I decided to do some googling and figure things out myself. I came across a guide with some basic starting points and was feeling good about things until I got to this part: https://medium.com/@suvratapte/configuring-emacs-from-scratch-use-package-c30382297877

I am completely unable to install use-package and that feels pretty defeating. I followed the instructions and the package was not found. I tried `package-refresh-contents` and found use-package-hydra use-package-chords and use-package-el-get. Can't seem to find use-package.

After some googling I thought it might be that my mac-homebrew-installed version of emacs was missing TLS support, so I deleted it, pulled the emacs-mac repo, and installed it with no issues. Started up my new install and had to navigate the fact that my alt key was no longer bound and my command key was magically mapped to meta which I don't want. It was really frustrating to run into this and have no idea how to C-h my way out of it. I managed to map alt to meta and map command to super, but not I can't command-c any more which is an annoyance.

On top of this, I still can't install use-package, the exact same thing happens. I deleted the part of my config that sets up melpa and used the instructions from their site. I confirmed using eww that I have TLS support working. I tried a number of commands from reddit and elsewhere and have not made any progress. I feel like I'm back in my vim config hopelessly adding lines to my config until it's not broken.

Primarily I need help passing this hurdle so that I can try and set things up myself. It would also be super nice to understand why these things have been failing and how I can better use resources to fix issues like this in the future.

55
 
 

Hello Everyone,
This is my first post every on reddit I hope I don't get RTFM ed.
Problem: Until about a week ago I used to use a doom emacs config I got off of the internet with some modifications just for references in latex. this week I finally decided to code my own literate gnu emacs config but there is one feature I am sorely missing. In the image attached in a org-mode document there is syntax highliting for latex code outside of src_code blocks I want that but I don't know how to get it into my new config. Further information can be provided on request.

https://preview.redd.it/lglj2nzsbj3c1.png?width=1902&format=png&auto=webp&s=c4a77a9df21eeb9d4f450348b4717f7bb1fb61a4

56
57
 
 

Hi there, I'm trying to brush off my emacs and Orgmode since it's been years. I'm hitting a few snags and am also wondering about current standards since there has been many updates.

My goal:

Use Orgmode to customise my emacs and init files while using the Dropbox directory. I would also like to use a custom named init file so it's like eckoinit.el instead of init.el (For easier recognition and modification).

Overall, I'd like to sync and use emacs from different computers using the same configs.

I know one of my current snags is I can't remember how to tell emacs from Orgmode to use a differently named init file. I feel like this should be an obvious answer that I should have found by now and I feel silly.

Thanks for your time!

58
 
 

Hello Emacs Community!,

I'm a long time Emacs user, right now using the Doom framework and, I recently took a look at the power Nix, specifically the devenv.sh project. I wonder if someone is using it in some manner. As it being quite powerful and allowing having separate development environments.

Are there any packages for this?, and if not, how complicated would it to be to for example, once entering a project, Emacs gets all of its PATHs (languages like NodeJS and other niceties) so that little by little, the project can be replicated and used completely with devenv and Emacs without having to installing anything globally.

Thank you, I would love to hear your workflows!, just wanting to be sure I'm getting the best of the best in my environment, I will be coding in Javascript, Angular and so on.

59
1
Rate my setup (alien.top)
submitted 1 year ago by ZeStig2409@alien.top to c/emacs
 
 

Emacs on Hyprland

This Emacs config's built from scratch by this humble Elisp noob. I want it to be minimal and plain. Love some feedback!

60
61
 
 
62
63
 
 

I have been trying to get dap-mode for c++ to work. Below is my config related to dap-mode

(use-package dap-mode
  :after lsp-mode
  :commands dap-debug
  :hook ((c++-mode python-mode . dap-ui-mode) (python-mode . dap-mode))
  :config
  (dap-auto-configure-mode t)

  (setq dap-python-debugger 'debugpy)
  (require 'dap-python)

  (require 'dap-gdb-lldb)
  (require 'dap-lldb)
  (setq dap-lldb-debug-program "/usr/bin/lldb-vscode")
;;; ask user for executable to debug if not specified explicitly (c++)
  (setq dap-lldb-debugged-program-function (lambda () (read-file-name "Select file to debug.")))

  ;;; default debug template for (c++)
  (dap-register-debug-template
   "C++ LLDB dap"
   (list :type "lldb-vscode"
         :cwd nil
         :args nil
         :request "launch"
         :program nil))
;; (defun dap-python--pyenv-executable-find (command)
;;   (with-venv (executable-find "python")))

(add-hook 'dap-stopped-hook
	  (lambda (arg) (call-interactively #'dap-hydra)))

(defun dap-debug-create-or-edit-json-template ()
    "Edit the C++ debugging configuration or create + edit if none exists yet."
    (interactive)
    (let ((filename (concat (lsp-workspace-root) "/launch.json"))
	  (default "~/.config/emacs/default-launch.json"))
      (unless (file-exists-p filename)
	(copy-file default filename))
      (find-file-existing filename))))

The problem I am facing currently is that every time i run

dap-debug

while the file is open i get prompted for executable and when i select the candidate, I get the error

Wrong type argument: stringp, nil

From what I learned we get the above error when a function get a nil value while expecting a string but I don't understand why the function will get a nil value when i selected the correct executable with appropriate compiler flags.

I would appreciate any help in the matter.

64
65
 
 

Hey everyone, quite a while ago I created the Naga theme; it's also on MELPA. I used it for a long time (and I'm still using it in the evenings), but I'm not totally happy with it. I'd like to spend a little more time on it, changing some colors, updating the slightly outdated screenshots in the readme and so on. While I'm at it, I could have a look at packages that don't work well with it as well. I have some other ideas for themes, and an improved naga would also give me a better base to work from for these.

I'd be glad if some of you could maybe test-drive it and give me feedback, especially if it perhaps breaks or looks plain bad with some packages you use.

The main idea of the theme was to get a "more modern retro green" theme, with high contrast, but a non-standard foreground color -- green in this case.

Thanks in advance!

66
 
 

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

67
 
 

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.

68
 
 

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.

69
 
 

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!

70
 
 

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.

71
 
 

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

72
 
 

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?

73
 
 

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.

74
 
 

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.

75
 
 

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?

view more: ‹ prev next ›