This channel is a feed for r/emacs. @r_channels @reddit2telegram
Eglot LSP setup help
I still don't get how to setup LSP servers even after reading the manual
I have corfu and eglot installed, completion with clangd works with c files without me making any changes in my config file, but trying to setup pyright for python and eglot cannot connect to it for whatever reason.
I executed eglot-reconnect
and was met with this:jsonrpc-error: jsonrpc-error: "No current JSON-RPC connection", (jsonrpc-error-code . -32603), (jsonrpc-error-message . "No current JSON-RPC connection")
Tried to install jsonrpc package via elpaca, no luck with that at all.
Here are the files I use in my config:
early-init.el https://pastebin.com/9ExGpn6z
init.el https://pastebin.com/UxAApmHP
Package-Manager.el https://pastebin.com/QYFvTK3P
https://redd.it/1aqcd6k
@r_emacs
E-lnk tablet for a computer science student working with Emacs
Hi guys !
I'm a computer science student, and I'm looking for a minimalist, cheap and efficient e-ink tablet for increasing my productivity.
My current workflow is like this: I code and annotate PDFs in Emacs, take notes in Org-Mode, and take hand-written notes for math classes.
I'd like to centralize my work database, and for that the tablet should be able to read and annotate PDF files, but also Org ones and push changes on a cloud service.
I'll take any advice.
Thanks in advance, and have a great day !
https://redd.it/1aq78bu
@r_emacs
Kickstart.emacs is now Stable!
https://github.com/MiniApollo/kickstart.emacs
https://redd.it/1aq3x7x
@r_emacs
Using Emacs with Conda and Direnv
Since I think I'll be using more Python in the near future I decided to see what the ecosysetm looked like these days. Using Emacs with Conda and Direnv is pretty neat:
https://cestlaz.github.io/post/using-emacs-82-conda-direnv/
https://redd.it/1apzg00
@r_emacs
Powerthesaurus
I'm not sure when it started, but recently the powerthesaurus package has started failing with
error in process filter: JSON readtable error: 60
I assume that the website has changed their API and that's broken it, but wanted to make sure it wasn't something I did. I tried to track down the problem but I'm pretty new to elisp.
https://redd.it/1apxbbg
@r_emacs
How to modify n/N to search in one direction in evil mode?
hi experts
​
I am using evil mode(doom emacs). In that i want to do is have `N` always search up in the file and `n` search down in the file ...
​
for that i created this
​
#+BEGINSRC elisp
;; (define-key evil-motion-state-map (kbd "#") 'evil-ex-search-word-forward)
(advice-add 'evil-ex-re-bwd :after (lambda () (setq evil-ex-search-direction 'forward)))
(advice-add 'evil-match :after (lambda () (setq evil-ex-search-direction 'forward)))
#+ENDSRC
​
but it does not reliably work, can one of you experts tell me what i am doing wrong?
​
TIA
https://redd.it/1apu0yx
@r_emacs
Chinese Zodiac Time for Your Emacs Mode Line
https://camdez.com/blog/2024/02/12/chinese-zodiac-time-for-emacs/
https://redd.it/1apltpr
@r_emacs
"edit emacs config")
;; add keybinding for reloading init.el file
;; "C-c r" '((lambda () (interactive) (load-file "~/.config/emacs/init.el")) :wk "reload emacs config")
"C-c r" '(reload-init-file :wk "reload emacs config")
"C-s" 'swiper
"C-c g" 'counsel-git
"C-c j" 'counsel-git-grep
"C-c k" 'counsel-ag
"C-c f" 'counsel-recentf
"C-x x e" 'eshell
"C-x x h" 'counsel-esh-history
"C-c v" 'vterm-toggle
))
(setq backup-directory-alist
`((".*" . "~/.config/emacs/backups"))
auto-save-file-name-transforms
`((".*" "~/.config/emacs/auto-save-list" t)))
(use-package company
:ensure t
:diminish
:custom
(company-idle-delay .1)
(company-minimum-prefix-length 1)
(global-company-mode t))
(use-package diminish)
;; remove startup message when Emacs loads
(setq inhibit-startup-message t)
(setq inhibit-splash-screen t)
;; Emacs GUI improvements
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(global-display-line-numbers-mode 1)
(column-number-mode 1)
(global-visual-line-mode 1)
(set-default 'truncate-lines t)
(delete-selection-mode 1) ;; can select text and delete it by typing
(global-auto-revert-mode t) ;; automatically show changes if the file has changed
(electric-pair-mode 1) ;; turns on automatic parens when pairing
;; the next code prevents <> from auto-pairing when electric-pair-mode is on
;; otherwise, org-tempo is broken when you try to <s <TAB>...
(add-hook 'org-mode-hook (lambda ()
(setq-local electric-pair-inhibit-predicate
`(lambda (c)
(if (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))
;; make electric-indent behave sanely
(setq-default electric-indent-inhibit t)
(setq-default indent-tabs-mode nil)
(use-package flycheck
:ensure t
:after seq
:diminish
:init (global-flycheck-mode))
(if (eq system-type 'darwin)
(set-face-attribute 'default nil :font "Space Mono-18"))
(if (eq system-type 'gnu/linux)
(set-face-attribute 'default nil :font "Space Mono-12"))
;; makes commented text italics
(set-face-attribute 'font-lock-comment-face nil :slant 'italic)
;; setting this so that emacsclient have the correct/same font
(add-to-list 'default-frame-alist '(font . "Space Mono-12"))
(use-package git-timemachine
:after git-timemachine)
(use-package magit
:ensure t)
(use-package counsel
:after ivy
:diminish
:config (counsel-mode))
(use-package ivy
:diminish
:custom
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d ")
(setq enable-recursive-minibuffers t)
:config
(ivy-mode))
(use-package ivy-rich
:after ivy
:ensure t
:init (ivy-rich-mode 1))
;; TODO: Optimize code
(use-package python-ts-mode
:elpaca nil
:hook ((python-ts-mode . eglot-ensure)
(python-ts-mode . company-mode)))
(use-package c-ts-mode
:elpaca nil
:hook ((c-ts-mode . eglot-ensure)
(c-ts-mode . company-mode)))
(use-package typescript-ts-mode
:elpaca nil
:hook ((typescript-ts-mode . eglot-ensure)
(typescript-ts-mode . company-mode)))
(use-package tsx-ts-mode
:elpaca nil
:hook ((tsx-ts-mode . eglot-ensure)
(tsx-ts-mode . company-mode)))
(use-package js-ts-mode
:elpaca nil
:hook ((js-ts-mode . eglot-ensure)
(js-ts-mode . company-mode)))
(use-package lua-mode)
(use-package haskell-mode)
(org-babel-do-load-languages
'org-babel-load-languages
'((C . t)))
(use-package toc-org
:commands toc-org-enable
:init (add-hook 'org-mode-hook 'toc-org-enable))
(add-hook 'org-mode-hook
Unicode bold generator etc in emacs?
Before I write my own...
Are there any emacs packages that include commands for taking the text in the active region and switching between bold, italic, etc using unicode substitutions?
ie like these kinds of text generators.
https://lingojam.com/BoldTextGenerator
I realize such a generator can't handle every character, but I want it just for highlighting words in comments, etc.
Tnx!
​
https://redd.it/1apcmmk
@r_emacs
No way to copy/paste - access the system clipboard - on Android?
I have Emacs for Android installed from https://sourceforge.net/projects/android-ports-for-gnu-emacs/ and it's setup nicely.
I've read the manual and it seems Emacs on Adroid (my Android version is 13) doesn't have the ability to access the system clipboard - indeed it seems to be that way.
Is there really no way to copy/paste - share data with other apps? For simple things - like cope a website's URL in Firefox and paste it to a document in Emacs?
https://redd.it/1apbyfd
@r_emacs
Flowed text in Mu4e has long lines that aren't wrapped
The description in the manual says: "On decoding flowed text, lines with soft newline characters are filled together and wrapped after the column decided by fill-flowed-display-column. The default is to wrap after fill-column."
But what about lines without soft newline characters? When I open mails in mu4e, all longer lines are nicely wrapped. The lines though that can be shown completely in the buffer stick out and are not wrapped, and this looks ugly and makes reading harder because of the long lines. (See the attached screenshot. The lines at the end are much longer than the wrapped ones above.)
https://preview.redd.it/3jvfh0x856ic1.png?width=2554&format=png&auto=webp&s=d483b264fb88b9f4da251a7be0e6b2347bc0a2c8
Has anyone of you found a solution for this?
(In my system, fill-flowed-display-column
is set to fill-column
, and fill-column
is set to 70.)
https://redd.it/1ap1wh4
@r_emacs
C++ ts major mode.
Does the c++-ts-major-mode need the c language installed along with the c++ language? I keep getting a warning about it not being able to find the c language that isn't installed but then the treesit functions, syntax highlighting all take off and work anyway.
My first thought was that this is based on my file extension so I checked the list that stores the extension to major mode settings. I can't remember the variable name right now but it's a huge list of regex strings and the corresponding major modes it opens and changed my files to one that specifically calls c++-mode. My init script overrides that to c++-ts-mode.same error.
https://redd.it/1ap4dat
@r_emacs
[auto-dark] 0.12 - Now supports emacs-mac (MacOS) and allows 'default' Emacs theme
https://redd.it/1ap213j
@r_emacs
Emacs won't really close after C-x C-c (process still running)
I'm using Debian 12 with Emacs-gtk 28.2 installed via apt. When I close Emacs via C-x C-c the window close but I can see the process is still running in background. I need to do a "killall emacs" to actually close Emacs. My .emacs config is pretty basic for python programming. Any help is appreciated, thanks
https://redd.it/1aorx7k
@r_emacs
Python newbie wants Emacs
Hi there!
I'm new to programming and am learning Python!
I decided to go with Emacs, and you might be asking why. Well, I've dabbled a bit with Emacs in the past, and I'm intrigued by its feature set, which I believe could greatly enhance my programming-fu. I'm using Termux with an external keyboard because I do not have access to a computer. Is my approach off-base? Is there a significant difference between using emacs vs emacs -nw ? Can I just stick to the vanilla setup for programming in Python?
Your insights are greatly appreciated.
Thanks!
https://redd.it/1aolheu
@r_emacs
The Ultimate Collection of Emacs Resources
https://batsov.com/articles/2011/11/30/the-ultimate-collection-of-emacs-resources/
https://redd.it/1aq7hu8
@r_emacs
How do I get emms to read metadata using tinytag activated within a python virtualenv
With emms the only success I had reading metadata properly was using python tinytag with the line (setq emms-info-functions '(emms-info-tinytag)). The only other configuration I did was to set "emms-info-tinytag-python-name" to python3.
But on new linux distros you can't install tinytag via pip and your system python package. You have to install it into a virtual environment.
My question is, on new linux distros how do I set emms to use tinytag as installed in a python virtual environment? Do I activate the virtual environment and then set emms-info-tinytag-python-name to the path of python in the virtual environment?
Thanks for any help.
https://redd.it/1apz7o9
@r_emacs
Can get company to work for special blocks in org mode?
I have some latex environments for special blocks in org mode. Is there a way that I can create a list of blocks that company can cycle through and select? Thanks.
https://redd.it/1aq0dkz
@r_emacs
Release 1.7.1 · alphapapa/magit-todos
https://github.com/alphapapa/magit-todos/releases/tag/1.7.1
https://redd.it/1apzuwz
@r_emacs
Relative org table remote references
I want to seperate input data and calculated data in two tables. But how can I reference one table from another if I need relative column and row positions.
Here is an example of what I mean:
| col1 | col2 | col3 | col4 |
| test | 1 | | |
| test2 | 5 | -4 | 6 |
| test3 | 4 | 1 | 9 |
#+TBLFM: @3$3..@>$3=@-1$2-@0$2::@3$4..@>$4=@-1$2+@0$2
In col3 I show the result of subtracting the value in col2 in the current row from the value col2 in the previous row. col4 does the same with adding the rows
But what if I wanted to have two table. One for the input data (col1, col2) and one for the calculated data (col3, col4)
I tried it like this
#+TBLNAME: data
| col1 | col2 |
| test | 1 |
| test2 | 5 |
| test3 | 4 |
| col3 | col4 |
| | |
| -4 | 6 |
| 1 | 9 |
#+TBLFM: @3$1..@>$1=remote(data,@-1$2)-remote(data,@0$2)::@3$2..@>$2=remote(data,@-1$2+@0$2)
But it throws an error that "Row descriptor -1 leads outside table". Obviously because the relative positions are not based on the second table
https://redd.it/1aptsaq
@r_emacs
Emacs doesn't read my config.org
Hello, I am new to Emacs, and I am following Distro Tube's series of videos; I do all he does, but when I restart Emacs, everything remains the same; Emacs does not read my configuration, and I don't know what to do... I'd appreciate it if one of you could help.
https://redd.it/1apnvx8
@r_emacs
'org-indent-mode)
(use-package org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
(require 'org-tempo)
(use-package projectile
:diminish
:config (projectile-mode 1))
(defun reload-init-file ()
(interactive)
(load-file user-init-file)
(load-file user-init-file))
(use-package eshell-syntax-highlighting
:after esh-mode
:config
(eshell-syntax-highlighting-global-mode +1))
(use-package vterm
:ensure t
:config
(setq vterm-max-scrollback 5000))
(add-hook 'vterm-mode-hook (lambda () (display-line-numbers-mode -1)))
(use-package vterm-toggle
:after vterm
:config
;; config from DistroTube
(setq vterm-toggle-fullscreen-p nil)
(setq vterm-toggle-scope 'project)
(add-to-list 'display-buffer-alist
'((lambda (buffer-or-name _)
(let ((buffer (get-buffer buffer-or-name)))
(with-current-buffer buffer
(or (equal major-mode 'vterm-mode)
(string-prefix-p vterm-buffer-name (buffer-name buffer))))))
(display-buffer-reuse-window display-buffer-at-bottom)
(reusable-frames . visible)
(window-height . 0.4))))
(add-to-list 'custom-theme-load-path "~/.config/emacs/themes/")
(use-package ef-themes
:elpaca nil
:ensure t
:init (load-theme 'ef-autumn t)
)
(use-package treesit-auto
:custom
(treesit-auto-install 'prompt)
:config
(treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode))
(use-package which-key
:init
(which-key-mode 1)
:diminish
:config
;; config setup from DistroTube
(setq which-key-side-window-location 'bottom
which-key-sort-order #'which-key-key-order-alpha
which-key-sort-uppercase-first nil
which-key-add-column-padding 1
which-key-max-display-columns nil
which-key-min-display-lines 6
which-key-side-window-slot -10
which-key-side-window-max-height 0.25
which-key-idle-delay 0.8
which-key-max-description-length 25
which-key-allow-imprecise-window-fit nil)
)
(defun +elpaca-unload-seq (e)
(and (featurep 'seq) (unload-feature 'seq t))
(elpaca--continue-build e))
(defun +elpaca-seq-build-steps ()
(append (butlast (if (file-exists-p (expand-file-name "seq" elpaca-builds-directory))
elpaca--pre-built-steps elpaca-build-steps))
(list '+elpaca-unload-seq 'elpaca--activate-package)))
(use-package seq :elpaca `(seq :build ,(+elpaca-seq-build-steps)))
​
https://redd.it/1apj22g
@r_emacs
typescript treesitter mode syntax highlighting problem
new to emacs and been configuring around to setup emacs as my new editor. been doing some c an python and syntax highlighting is okay. typescript on another note seems like it's lacking some syntax highlighting. when i set `treesit-font-lock-level` to 4, i get a message `query pattern is malformed: "Node type error at", 2, "(function name: (identifier) @font-lock-function-name-face)...` and a whole bunch of elisp which i still dont understand since i havent learned elisp yet.
i didnt do any customization in my init.el for treesitter besides adding treesit-auto
should there be customization in my config for typescript-ts-mode to use syntax highlighting?
​
here is my config file (heavily copied from DistroTube's configuring emacs videos) for reference.
(defvar elpaca-installer-version 0.6)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil
:files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca--activate-package)))
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (< emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (call-process "git" nil buffer t "clone"
(plist-get order :repo) repo)))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(load "./elpaca-autoloads")))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
;; Install a package via the elpaca macro
;; See the "recipes" section of the manual for more details.
;; (elpaca example-package)
;; Install use-package support
(elpaca elpaca-use-package
;; Enable :elpaca use-package keyword.
(elpaca-use-package-mode)
;; Assume :elpaca t unless otherwise specified.
(setq elpaca-use-package-by-default t))
;; Block until current queue processed.
(elpaca-wait)
;;Turns off elpaca-use-package-mode current declaration
;;Note this will cause the declaration to be interpreted immediately (not deferred).
;;Useful for configuring built-in emacs features.
(use-package emacs :elpaca nil :config (setq ring-bell-function #'ignore))
;; Don't install anything. Defer execution of BODY
;; (elpaca nil (message "deferred"))
(setq package-enable-at-startup nil)
(package-initialize)
(use-package general
:config
(general-define-key
;; remap list buffers to use ibuffer
"C-x C-b" 'ibuffer
;; remap switching windows
"M-o" 'other-window
;; add keybinding for opening config.org file
"C-c c" '((lambda () (interactive) (find-file "~/.config/emacs/config.org")) :wk
Org Capturing Introduction - Howardism
https://howardism.org/Technical/Emacs/capturing-intro.html
https://redd.it/1apbwin
@r_emacs
TIL to use cl-callf to toggle a var without repeating the name
Tired of writing lines like this?
(setq long-stupid-variable-name (not (long-stupid-variable-name)))
TIL you and just do
(cl-callf not long-stupid-variable-name)
How have I written lisp so long and not known this? My life is complete now.
https://redd.it/1ap9azk
@r_emacs
Elpaca package manager
Hey guys, does anyone knows how to exit "elpaca-ui-mode"? I entered it by accident, trying to search for a package, and now I can't write anything on my files, as it says "buffer is read-only"
Thanks!
https://redd.it/1aozt9y
@r_emacs
how can i make a cl-defun fast
so i took some code from alphapapa's config for configuring the elfeed interface but i am facing a substantial difference in loading time of elfeed it just get hang from some seconds and afther that i can move up and down is it due to the cl-lib function or smthng else if yes then how can i replace it with emacs lisp or any other hack to make it fast
(add-hook 'elfeed-search-update-hook #'ap/elfeed-search-add-separators)
(cl-defun ap/elfeed-search-add-separators (&key (min-group-size 2))
"Insert overlay spacers where the current date changes.
If no group has at least MIN-GROUP-SIZE items, no spacers will be
inserted. "
;; TODO: Use column-specific functions so that, e.g. date column could be grouped by month/year
(cl-labels ((count-date-items (date)
(cl-loop for entry in elfeed-search-entries
when (equal date (elfeed-search-format-date (elfeed-entry-date entry)))
count it))
(insert-date (date &key count)
(ov (line-beginning-position) (line-beginning-position)
'before-string (propertize (format "%s (%s)\n" date count)
'face 'elfeed-search-date-face)
'type 'date-separator))
(entry-date (offset)
(when-let ((entry (nth offset elfeed-search-entries)))
(elfeed-search-format-date (elfeed-entry-date entry)))))
(ov-clear)
(save-excursion
(goto-char (point-min))
(cl-loop with largest-group-size = 1
with offset = (- 1 elfeed-search--offset) ; 1 is first line
with prev-data = (entry-date offset)
initially do (insert-date prev-data
:count (count-date-items prev-data))
while (not (eobp))
do (progn
(forward-line 1)
(cl-incf offset))
for current-data = (entry-date offset)
if (not (equal current-data prev-data))
do (progn
(insert-date current-data
:count (count-date-items current-data))
(setq prev-data current-data))
else do (cl-incf largest-group-size)
finally do (when (< largest-group-size min-group-size)
(ov-clear))))))
Is there a way to access and use bookmarks (or similar) from within insert-file or find-file ?
When I am editing file-a and want to insert file-b and if both files live in different directories (lets say dir-a and dir-b), things become cumbersome: Invoking insert-file gives me the usual dialog starting at dir-a and I then need to navigate to dir-b before I am able to insert file-b. If dir-a and dir-b are far away from each other, this may take a lot of keystrokes.
This could be made easier, if insert-file would allow me to jump to a bookmarked directory (which might be closer to dir-b). Do you know any such solution ?
Please note, that in this special use-case (insert-file), the command bookmark-bmenu-list (or similar) does not provide an alternative as far as I can see.
Thanx
Marc
https://redd.it/1ap0196
@r_emacs
Checking HTML syntax errors in Emacs?
I am trying to setup Emacs for web development. I have installed packages like yasnippet, web-mode, company, company-web, web-beautify, projectile, html-mode, lsp-mode, js2-mode, and flycheck. However they don't seem to highlight a misspelled HTML tag like 'foooter' which VSCode will highlight in red. Is there a way to get this kind of behavior in Emacs?
https://redd.it/1aofhwm
@r_emacs