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
301
 
 

So my BT keyboard + trackpad is looking worse for wear.

It was cheap and cheerful with a winning form factor. Other KBs came and went, but it survived.

I need a replacement.

It's been used with emacs (DooM) with my tablet and / or phone for a few years, and has a few shortcomings (see yellow sticker).

I now also have a SteamDeck, which is basically an Arch box, and I'd love a BT keyboard with that.

Does anyone have a portable setup they'd like to share?

Also, is there an emacs-y way to lisp my way out of things like:

  • keys being missing (#);
  • ESC being on a function layer?
302
303
 
 

ellama is a tool for interacting with LLMs from Emacs. It now uses llm library as a backend and supports various providers.

304
 
 

As the title says, when i run M-x ispell when it reaches a word under an org mode heading it won't unfold the heading, so my cursor is just on the actual heading and not the incorrect word and then when i quit ispell i can't unfold that heading with tab. I have to kill and yank the heading to get it working again. I pasted some of my init file below incase that helps.

  • I've tried this with flyspell disabled and get the same results, so i think it is an ispell issue.
  • I have also tried this with emacs -q and running M-x ispell and get the same issue.
  • I'm using emacs+ on mac

Thanks!

Org settings:

* Org mode
** General tweaks
#+begin_src emacs-lisp
  ;; indent with tabs for better readability
  (add-hook 'org-mode-hook #'org-indent-mode)
  ;; (setq org-indent-indentation-per-level 4)

  ;; them source blocks as they would in their native mode.
  (setq org-src-fontify-natively t
        org-src-tab-acts-natively t
        org-confirm-babel-evaluate nil)
#+end_src

** Packages
*** org-bullets
#+BEGIN_SRC emacs-lisp
  ;; Org bullets makes things look pretty
  (use-package org-bullets
    :ensure t
    :config
    (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
  #+END_SRC

ispell and flyspell settings:

** spell checking
*** ispell
#+begin_src emacs-lisp
  (use-package ispell
    :ensure t)

  (setq ispell-program-name "aspell")
  (setq ispell-extra-args '("--sug-mode=ultra"))
  (setq ispell-dictionary "english")
#+end_src

*** flyspell
#+begin_src emacs-lisp
  (use-package flyspell
    :ensure t
    :config
    (setq ispell-program-name "aspell")  ; Use Aspell as the spell checker
    (add-hook 'text-mode-hook 'flyspell-mode)
    (add-hook 'prog-mode-hook 'flyspell-prog-mode))

  ;; recommended to speed up flycheck
  (setq flyspell-issue-message-flag nil)

  ;; easy spell check
  (global-set-key (kbd "") 'ispell-word)
  (global-set-key (kbd "C-S-") 'flyspell-mode)
  (global-set-key (kbd "C-M-") 'flyspell-buffer)
  (global-set-key (kbd "C-") 'flyspell-check-previous-highlighted-word)
  (defun flyspell-check-next-highlighted-word ()
    "Custom function to spell check next highlighted word"
    (interactive)
    (flyspell-goto-next-error)
    (ispell-word)
    )
  (global-set-key (kbd "M-") 'flyspell-check-next-highlighted-word) 

305
306
 
 

I have been using `find` with `consult-find`, but it's a bit slow. I'm wondering if it would be possible to speed it up using some other tool such as `fd`. I noticed that the consult README talks about `consult-fd` but I cannot locate that function anywhere in my version which is I think the latest `0.35`. Can anyone help with this?

Also, similarly, consult-grep is a bit slow. Wondering if one can swap in `ag` for example?

307
 
 

I want to use set google as the search engine for emacs but can't figure out the process

308
 
 

I'm using the adwaita-dark theme but the mode-line is too wide for my liking. In the theme code there's a variable (mode-line-padding 10) which I assume sets the width of the mode line. Is there a way for me to reset this value in my init file, either before or after loading the theme code, to make it narrower? I'm using the code below to load it.

(use-package adwaita-dark-theme
  :ensure t
  :config
  (load-theme 'adwaita-dark t))

309
 
 

Hi.

Ainother day, another emacs doubt.

I'm using ivy-mode, and when I do M-x and write, the order of candidates for completion seems weird for me. I figure it obeys some logic, but I'd like to change it. For example:

I do M-x and write coun bu

Results are:

counsel-switch-buffer (this one is selected by default)

counsel-ibuffer

counsel-buffer-or-recentf

counsel-minibuffer-history

For me, counsel-buffer-or-recent should be the first candidate, since that's the one with shortest "distance" between a match for coun and a match for bu. Is there a way to make results be sorted by this? So that those 4 candidate should appear like:

counsel-buffer-or-recentf

counsel-ibuffer

counsel-minibuffer-history

counsel-switch-buffer

Another example. I make M-x package-install then write consu. There are almost 15 results before consult. Being the shortest one matching perfectly the string, IMHO this should be the first candidate.

Another example, M-x dire. Results:

A couple of logical results (because they start with dired-)

tramp-crypt-add-directory

dired-jump-other-window

How is it that dired-jump appears after tramp-crypt-add-directory if the match for dire is further in the tramp-... candidate?

Any hint on this?

Thanks in advance.

310
 
 

I know this question has been asked before and I know about org-roam, I am just not sure if org-roam is the right solution for me. Right now, I use one big org file to take notes which I export to pdf. This works nicely, but it would be nice to also have access to the concepts in the larger org file at a granular level (ie. bite-sized notes which reference one another and are organized based on their subject matter). I would also like to tag information that is not in org format, if possible. I was thinking that org-roam & org-transclusion could be used to make main subject files, while org-roam could be used to make a link to an embedded pdf that comes from the concept I am referencing, when I don't need to explicitly review the material in whatever notes I am taking. Has anybody done anything like this? Any tips are appreciated. Thanks.

311
 
 

I am trying to use dired on Windows. But, when I attempt to follow a shortcut in dired, it seems to open the shortcut file itself in a buffer instead of following the shortcut to the target directory.

I attempted to follow the installation instructions in this file starting on line 51: https://github.com/hidsh/elisp/blob/master/w32-symlinks.el.

When I byte-compiled the w32-symlinks.el file, Emacs informed me that there were incorrectly escaped quotes in the function located on line 171. I removed those parts of the docstring and byte-compiled the file without error. I also used the following code as specified in the directions.

(add-hook 'dired-load-hook

(lambda () (require 'w32-symlinks)))

But, when I use dired to follow a Windows shortcut it still opens it as a file.

Is there another file explorer package that I can use? Is there another solution?

Thank you for your time.

Edit 1:

I did end up making some progress. I deleted my configuration, reinstalled emacs, and then followed the instructions again. Emacs now starts with configuration choices related to the w32-symlinks package. I have tried a few different combinations. But, now when I attempt to use dired to open a windows shortcut I get the error "Wrong type argument: stringp, t" in the mini-buffer.

312
 
 

I know I can use M-x browse-url-of-buffer to create a temp file and render it on my default browser. But how could I render it with eww?

I tried the function suggested here, but I get the error message that says:

eww-display-html: Buffer nil doesn’t exist

The use case is the following:

  1. Export org as HTML (to a temp buffer);
  2. Render the HTML to a browser, my default browser or eww.

Any suggestions?

313
 
 

Code is:

(progn 
  (with-temp-buffer
(insert
 (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/alphapapa/org-ql/bd2dd12a417df5403954576756d9c24273d94379/tests/data.org")
   (goto-char url-http-end-of-headers)
   (buffer-substring (point) (point-max))))
;; remove sunrise stuff throwing error
(goto-char (point-min))
(while (re-search-forward "^%%(org-super-agenda--test-diary-sunrise)\\|^%%(org-super-agenda--test-diary-sunset)" nil t)
(replace-match "" nil nil))
(write-file "/tmp/tmp.org"))
  (let ((org-agenda-files '("/tmp/tmp.org"))
(org-agenda-finalize-hook nil))
(org-agenda-list nil "2017-07-05"))
  (delete-other-windows))

Thanks to /u/alphapapa for good data for this purpose.

I've attached what mine looks like, but basically just default modus dark theme.

Why? If you live in your org-agenda, you probably care about how it looks to some extent.

Maybe we can share cool parts that improve our living spaces :)

314
 
 

The emacs website has versions down to 22, but none of them seem to work correctly on Windows 98. I managed to get emacs 22 running, but it does not display correctly on screen. Only the -nw version runs correctly.

Is there any version that works well on the older OSes?

315
 
 

I just switched from neovim to emacs and one thing I miss is coc.nvim. It has a power to turn a barren neovim into anything I ever want from IDEs. I tried to do something like this and emacs learning curve got me. I cobbled together a simple config with eglot, company and rust-mode, but I can't get import completion to work. Any suggestions?

316
 
 

If I manually set dired-mouse-drag-files, open dired, then perform a mouse drag on any file Emacs immediately crashes. (Emacs 29.1 installed from the homebrew cask on macOS Ventura)

Checking here to see if anyone else has experienced this.

I searched the GNU bug tracker and (tbh I might not have searched in the right way) but I didn't find anything.

317
 
 

Hey there.

I'm a fan of Emacs, like you folks.

I use Emacs org every day, mainly for my teaching class. Furthermore, I learn Emacs for three years ago.

But I struggle to achieve my learning of Elisp. For example, taping lisp and elisp code with evil/lispy is a true nightmare (I use Prelude with few modes, btw), not to mention when I type code block within org.

I knew the learning curve is hard. But I didn't expect that much frustration to learn it. The documentation is austere. So few examples are given. There is too little blogs or books about Emacs, specifically about org and babel.

To illustrate my point, let's take the «*this*» kind-of macro in babel, that I found TODAY by CHANCE in this page : https://orgmode.org/manual/Results-of-Evaluation.html.

It's a game changer for a lot of my code, and would deserve a whole page to illustrate it. But no, it's given in a «niche» example.

Don't be mistaken, I found Babel/Org/Emacs wonderful, but what a pain in the ass to learn it !

For such an old and wise piece of software, I can't understand why we don't have a smooth learning experience with Emacs. A lot of people could benefit Org/Emacs, without the big hinder of the «lack» of documentation (mostly examples).

Am I the only one to experience this ?

318
 
 

Am I missing something or does the new yaml-ts-mode not having any rules for indentation? Seems odd in a language where indentation is semantically relevant.

GNU Emacs 29.1 (build 2, x86_64-unknown-linux-gnu, GTK+ Version 3.24.38, cairo version 1.16.0) of 2023-08-03

Treesitter grammar installed and loaded via:

(use-package treesit-auto
  :config
  (add-to-list 'global-treesit-auto-modes '(not org-mode))
  (setq treesit-auto-install t)
  (global-treesit-auto-mode))
319
320
 
 

Repository: mini-echo

Echo buffer status in minibuffer window, get rid of mode-line.

features:

  • light-weight, very simple structure and no many configs compared to feebleline, mini-mdoeline, awesome-tray...
  • don't use mode-line at all, same experience in terminal
  • port lots of segments from doom-modeline

Have a try!

321
 
 

Thanks to Andreas (the original author of gccmacs), we can now "redump" Emacs even with some natively compiled elisp in the mix. I've been cautious in my experiments so far, but: this works on Windows!

From a MSYS2/MINGW64 bash shell:

$ bin/emacs --batch -Q -eval '(let ((custom-theme-load-path (list "/.emacs.d/elpa/cyberpunk-2019-theme-20191008.1133/"))) (require '"'"'erc) (load-theme '"'"'cyberpunk-2019 t) (enable-theme '"'"'cyberpunk-2019) (dump-emacs-portable "erc.pdmp"))'

$ bin/runemacs.exe --dump-file erc.pdmp -fs -l

This seems to get a "fullboth" frame with my theme pretty fast. Note, I can't trigger connection quite yet at that point; the runemacs call is loading my full init, and some parts that take a further moment.

Also, the first command, which created the custom portable dump called "erc.pdump" loaded by the second command, was nearly instant. Here's a look at what this did to size of the the pdmp file.

-rw-r--r-- 2 corwi corwi 16200096 Oct 24 18:10 src/emacs.pdmp
-rw-r--r-- 2 corwi corwi 16200096 Oct 24 18:10 src/emacs-30.0.50.3.pdmp
-rw-r--r-- 1 corwi corwi 16200096 Oct 24 18:10 src/bootstrap-emacs.pdmp
-rw-r--r-- 1 corwi corwi 16506656 Oct 24 18:35 +cl-lib.pdmp
-rw-r--r-- 1 corwi corwi 20006368 Oct 25 00:30 erc+cl-lib.pdmp
-rw-r--r-- 1 corwi corwi 19764904 Oct 25 00:43 erc.pdmp

322
 
 

I built Emacs 29.1 from source a few months ago and it was working pretty smoothly as far as I could tell -- I was mainly using the elfeed-webkit package -- until I tried to use it today and my Emacs session crashed. I was mainly using it in daemon mode, but evem just running emacs -Q and then M-x xwidget-webkit-browse-url RET wikipedia.org results in the error at the end of this post (sorry for the wall of text).

From the EmacsWiki and from reading /etc/PROBLEMS, I tried to use xwidgets-webkit again with SNAP=1 SNAP_NAME=1 SNAP_REVISION=1 emacs -Q, but it results in the same error.

It's probably an issue with my system rather than Emacs -- I'm running this on Manjaro Linux, and emacs-version gives:

GNU Emacs 29.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-08-28

What can I do to fix this?

(Below follows the error message referred to previously:)

Overriding existing handler for signal 10. Set JSC_SIGNAL_FOR_GC if you want WebKit to use a different signal
X protocol error: GLXBadWindow on protocol request 152
Serial no: 9165

When compiled with GTK, Emacs cannot recover from X disconnects.
This is a GTK bug: https://gitlab.gnome.org/GNOME/gtk/issues/221
For details, see etc/PROBLEMS.
Fatal error 6: Aborted

(emacs:1651212): GLib-WARNING **: 19:56:32.608: g_main_context_prepare() called recursively from within a source's check() or prepare() member.

(emacs:1651212): GLib-WARNING **: 19:56:32.608: g_main_context_check() called recursively from within a source's check() or prepare() member.
Backtrace:
emacs(emacs_backtrace+0x53)[0x55895d109393]
emacs(terminate_due_to_signal+0xb1)[0x55895cf87759]
emacs(+0x8e777)[0x55895cf88777]
emacs(+0x1b5484)[0x55895d0af484]
emacs(+0x1b5564)[0x55895d0af564]
emacs(+0x1b583b)[0x55895d0af83b]
/usr/lib/libX11.so.6(_XError+0x11c)[0x7f99d59b374c]
/usr/lib/libX11.so.6(+0x44858)[0x7f99d59b3858]
/usr/lib/libX11.so.6(+0x44915)[0x7f99d59b3915]
/usr/lib/libX11.so.6(_XEventsQueued+0x5a)[0x7f99d59b39aa]
/usr/lib/libX11.so.6(XPending+0x58)[0x7f99d59a62c8]
/usr/lib/libgdk-3.so.0(+0x87a28)[0x7f99d618ea28]
/usr/lib/libglib-2.0.so.0(+0x5a40b)[0x7f99d5b2a40b]
/usr/lib/libglib-2.0.so.0(+0xb8099)[0x7f99d5b88099]
/usr/lib/libglib-2.0.so.0(g_main_context_pending+0x2d)[0x7f99d5b280ad]
/usr/lib/libgtk-3.so.0(gtk_events_pending+0x13)[0x7f99d63ecfe3]
emacs(+0x1a58bd)[0x55895d09f8bd]
emacs(gobble_input+0x109)[0x55895d0f57a9]
emacs(unblock_input+0x56)[0x55895d0f5be6]
emacs(Fmake_xwidget+0x467)[0x55895d223ed7]
/home/nonreligous/.emacs.d/eln-cache/29.1-b9da317a/xwidget-9ccb93b3-12fdd1c0.eln(F787769646765742d696e73657274_xwidget_insert_0+0x4d)[0x7f99a215a1cd]
emacs(funcall_subr+0x2a4)[0x55895d1912d4]
emacs(Ffuncall+0x10b)[0x55895d18efeb]
/home/nonreligous/.emacs.d/eln-cache/29.1-b9da317a/xwidget-9ccb93b3-12fdd1c0.eln(F787769646765742d7765626b69742d2d6372656174652d6e65772d73657373696f6e2d627566666572_xwidget_webkit__create_new_session_buffer_0+0x1d1)[0x7f99a215e971]
emacs(Ffuncall+0x10b)[0x55895d18efeb]
/home/nonreligous/.emacs.d/eln-cache/29.1-b9da317a/xwidget-9ccb93b3-12fdd1c0.eln(F787769646765742d7765626b69742d6e65772d73657373696f6e_xwidget_webkit_new_session_0+0x52)[0x7f99a215eae2]
emacs(Ffuncall+0x10b)[0x55895d18efeb]
/home/nonreligous/.emacs.d/eln-cache/29.1-b9da317a/xwidget-9ccb93b3-12fdd1c0.eln(F787769646765742d7765626b69742d676f746f2d75726c_xwidget_webkit_goto_url_0+0x106)[0x7f99a215f056]
emacs(Ffuncall+0x10b)[0x55895d18efeb]
/home/nonreligous/.emacs.d/eln-cache/29.1-b9da317a/xwidget-9ccb93b3-12fdd1c0.eln(F787769646765742d7765626b69742d62726f7773652d75726c_xwidget_webkit_browse_url_0+0x109)[0x7f99a215b2e9]
emacs(Ffuncall+0x10b)[0x55895d18efeb]
emacs(Ffuncall_interactively+0x37)[0x55895d187737]
emacs(Ffuncall+0x10b)[0x55895d18efeb]
emacs(Fapply+0x149)[0x55895d1918d9]
emacs(Fcall_interactively+0x45b)[0x55895d187bab]
/usr/bin/../lib/emacs/29.1/native-lisp/29.1-b9da317a/preloaded/simple-fab5b0cf-a050dc2b.eln(F636f6d6d616e642d65786563757465_command_execute_0+0x2b5)[0x7f99bc7cb975]
emacs(Ffuncall+0x10b)[0x55895d18efeb]
/usr/bin/../lib/emacs/29.1/native-lisp/29.1-b9da317a/preloaded/simple-fab5b0cf-a050dc2b.eln(F657865637574652d657874656e6465642d636f6d6d616e64_execute_extended_command_0+0x1e9)[0x7f99bc7ca649]
emacs(Ffuncall+0x10b)[0x55895d18efeb]
emacs(Ffuncall_interactively+0x37)[0x55895d187737]
emacs(Ffuncall+0x10b)[0x55895d18efeb]
...
[1]    1651212 IOT instruction (core dumped)  emacs -Q
323
 
 

I want to write a script to process the contents of a text file line by line, and came across this example on Emacs wiki - https://www.emacswiki.org/emacs/BatchMode

emacs --batch --eval "(while t (print (eval (read))))"

So I adjusted it to emacs --batch --eval "(while t (print (read)))" and the prompt Lisp expression: is always displayed.

─○ emacs --batch --eval "(while t (print (read)))" 
Lisp expression: fdfdfds

fdfdfds
Lisp expression: dsfdsfdfds

Lisp expression: ^C%              

When I try a command like cat text1.txt | emacs --batch --eval "(while t (print (read)))" it barfs completely, so read is definitely not the function for this, unless I'm failing to pass some necessary options to it.

324
325
 
 

Hi,

Can you give a little help which package/function (maybe one from the title ones) what can give me an experience like other editors "go back" function.
Please share yours configuration if you have one.

view more: ‹ prev next ›