r_emacs | Unsorted

Telegram-канал r_emacs - /r/emacs

-

This channel is a feed for r/emacs. @r_channels @reddit2telegram

Subscribe to a channel

/r/emacs

Why use tabs (even the tab line variant) on emacs

[https://www.youtube.com/watch?v=r3T\_R9wpB\_o](https://www.youtube.com/watch?v=r3T_R9wpB_o)

I've posted a few times about my tab line config so my love for tabs is public. Recently I've seen several other folks posting as well on the topic and I noticed a trend in the comments with some repeated questions along these lines:

<slight exaggeration>

* But seriously they look nice but do you use them?
* What's the point / I don't see what it adds beyond switch-buffer?
* I have a lot of files, hundreds really, open - this doesn't look like it will scale.

</slight exaggeration>

So I decided to make another tabs video with
my answers and perspective on why I really find them useful and how they work in practice.



https://redd.it/1c46jla
@r_emacs

Читать полностью…

/r/emacs

force flake8 over lsp checker

I'm stuck. I am trying to force flake8 to be the first flycheck checker for python-ts-mode. I've tried several different things and can't get it to work. I can manually set flycheck to flake8 with C-c ! s so I know its finding the executable. Flake8 also works in terminal. I'm using lsp-mode and pyright. The two most recent things I've tried:

;; dir-locals.el
((nil . ((flycheck-checker . 'python-flake8)
(devdocs-current-docs . python~3.12))))



;; init.el attempt
(eval-after-load 'flycheck
(when (eq major-mode 'python-ts-mode)
'(add-hook 'flycheck-mode-hook (flycheck-select-checker 'python-flake8))))

https://redd.it/1c41zpw
@r_emacs

Читать полностью…

/r/emacs

denote silos: does everything or nothing have to be in a silo?

I'm exploring using silos in denote, which I think are potentially very helpful.

Am I correct in saying that, at present, once I switch to a silo (e.g. with `denote-silo-extras-create-note`), I can't switch back to the default `no-silo` (`denote-directory`) without switching to the `denote-directory` directory in dired? Or is the intention that everything should be in a silo, rather than in the default `denote-directory`?

Either way, I think things could get complicated working in different silos (assuming the goal is to keep them separate). Perhaps what is needed is some indication prepended to buffer-name of the silo - e.g. if the silo is in \~/Orgs/Silo1 and the #+title is "My plain title", the buffer name would be "Silo1:My plain title". If we were in the default `denote-directory` , buffer-name would just be "My plain title".

Thanks

Nick

https://redd.it/1c3zrej
@r_emacs

Читать полностью…

/r/emacs

lsp-mode not working

Hello I am totally new to emacs looking to try it out, and I have run into some problems setting up lsp-mode. Whenever I try to do M-x package install RET lsp-mode RET, it begins downloading as normal, but then it runs into 123 errors all going along the lines of:

lsp-actionscript.el:27:2: Error: lsp-execute-command is already defined as something else than a generic function

The other 122 errors are the exact same but for all the lanuages the lsp supports.

If I go in the lsp-actionscript.el and go to line 27, then it's this command which throws the error:

(require 'lsp-mode)

The same goes for all the other errors. I can't seem to find anything about this online. Hope u can help:)

Btw, I use windows 11 if that makes any difference

https://redd.it/1c3vocu
@r_emacs

Читать полностью…

/r/emacs

SVG Animation in GNU Emacs

&#x200B;

https://i.redd.it/l47tjxu4ieuc1.gif

Synchronized Multimedia Integration Language (SMIL) is an SVG extension which allows one to create simple animation without Javascript.

Demo: **https://youtu.be/uYp08wHgJVQ**

Details: https://lifeofpenguin.blogspot.com/2024/04/svg-animation-in-gnu-emacs.html

https://redd.it/1c3o7ft
@r_emacs

Читать полностью…

/r/emacs

Is anybody willing to help a complete n00b configure emacs on windows?

I feel like a complete idiot and have been banging my head against the wall all day with no progress at all. I cannot get this program to work with the packages I am trying to install per the recommendations of a tutorial I am following. It would be really helpful if someone who knows what they are doing could help me on screen share with discord because I feel like I am close to fixing this because I think everything that is supposed to be installed is there and I feel like probably just one of my directory paths is wrong but I don't know where or how.

I have posted on the tutorial and also asked on stack overflow and nothing has been helpful and I am just getting the same errors over and over. I just want to start coding but I can't because I can't even get this editor set up.

https://redd.it/1c3jxzo
@r_emacs

Читать полностью…

/r/emacs

how to follow org-links from elisp

What function should I call to follow the org-link like following from elisp:

[org:filename.org::#custom-id]

I want to follow this kind of links from function. I do not find the function-name to pass the link string (argument).

Thank you.

https://redd.it/1c3gx2h
@r_emacs

Читать полностью…

/r/emacs

Any good way to define "project launch" commands?

I'll preface by stating that I use project.el, and not projectile. Any solutions involving the latter won't do for me.

In most other editors, you can create a file at the project root (or some other predefined path) that specifies settings and, among other things, launch commands.

These commands are for anything related to the project, be it running, compiling, testing, debugging, whatever.

I want something like this for emacs. So, I've been investigating possible ways to do it.

I created a .dir-locals.el file on the project root. Emacs automatically loads this file. In it, I defined numerous variables with commands. I defined compile-command and created my own, like run-command and test-command.

I would then need to create functions that read these variables and run their values, similar to how compile-command is handled. This would work just fine, but there's an issue.

Since the variables I'm creating are unknown to emacs, it marks them as risky. So, what ends up happening is that every time you open a file where these variables would apply, you get a prompt asking you if you want to apply the variables.

I managed to fix this by setting these variables as safe when giving them strings like this:

(put 'compile-and-run-command 'safe-local-variable #'stringp)
(put 'run-command 'safe-local-variable #'stringp)
(put 'test-command 'safe-local-variable #'stringp)

And while this works, it irks me the wrong way, since this file would obviously be bundled with the project. So, if anyone else downloads this project and opens it with emacs, they won't have this extra config and they will be bugged by it, and for no good reason since they won't have the functions that use these variables anyway so it's of no use to them.

So, I'm looking for a way to:

1. Define an arbitrary amount of commands to run on a project.
2. Have this configuration loaded automatically.
3. Not be a nuisance to third parties.

Any ideas?

https://redd.it/1c3e228
@r_emacs

Читать полностью…

/r/emacs

Changing the value of a function with push?

In the following code:

(defclass foo ()
((bar :accessor bar
:initarg :bar)))

(defun def-bar ()
'(1))

(def-bar) ;; returns (1)

(setq main-foo (make-instance 'foo :bar (def-bar)))

(push 1 (nthcdr 1 (slot-value main-foo 'bar)))

(def-bar) ;; returns (1 1)

shouldn't (def-bar) always return (1)?

https://redd.it/1c36z73
@r_emacs

Читать полностью…

/r/emacs

Problems with HTML project export with references

I am trying to publish a HTML webpage using an Org file. I am using a very standard Lisp script that I execute in the terminal as: emacs -Q --script script.el following some of the work of System Crafters and some references on oc.el and CSL.

(require 'ox-publish)

(setq org-publish-project-alist
'(
("org-notes"
:base-directory "./content"
:base-extension "org"
:publishing-directory "./public"
:recursive t
:publishing-function org-html-publish-to-html
:headline-levels 4
:auto-preamble t
)
("org-static"
:base-directory "./content"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|txt\\|cur\\|svg\\|csv\\|json"
:publishing-directory "./public"
:recursive t
:publishing-function org-publish-attachment
)
("org"
:components ("org-notes" "org-static"))))

(org-publish "org")

I am using a csl file rather than the basic or bibtex options in my Org file:

#+AUTHOR: Me
#+BIBLIOGRAPHY: ~/bib/references.bib
#+CITEEXPORT: csl ~/Zotero/styles/apa.csl

When I export directly from Org-mode to a PDF or a HTML there is no error, but when I run my `script.el`, which is my preferred approach, I get the following error:

eval-buffer(#<buffer *load*> nil "/Users/topcat/projects/notes
org/build-site.el" nil t)
#f(compiled-function (buffer file) #<bytecode 0x146acef1111a2e2b>)(#<buffer load> "/Users/topcat/projects/notesorg/build-site.el")
load-with-code-conversion("~/projects/notes
org/build-site.el" "/Users/topcat/projects/notesorg/build-site.el" nil t #f(compiled-function (buffer file) #<bytecode 0x146acef1111a2e2b>))
command-line--load-script("~/projects/notes
org/build-site.el")
command-line-1(("-scriptload" "./build-site.el"))
command-line()
normal-top-level()
Citeproc library is not loaded

I am bit lost and haven't found good documentation regarding references using oc.el in HTML project exports. Does anyone here has more experience with it?

https://redd.it/1btn6bq
@r_emacs

Читать полностью…

/r/emacs

Fight the good fight!

Emacs is good, maybe the best but being the best comes with a lot of baggage. With the global obesity epidemic, we don’t need our software bloated with functionality too. Leave the productivity hamster wheel to the AIs.

Let the lean times begin. We are stripping down our software as we do our souls. You are all invited to help us build Emins. Emins will run only on 8086 processors attached to VT52 terminals, eliminating all that overhead of window systems, multitasking OSes and all that #ifdefed C code. Lisp will be replaced with the direct control and numeric accuracy of the native instruction set. Key bindings will be limited to standard ones on C-a to C-z. Although this will make writing hard, it will save a lot of work and compositions that, let’s face it, are often written but not read. With all that extra time, we could finish the HURD, embed Scheme everywhere and write tools in simple languages to support all the complex languages people actually use.

Come join us as we build Emins and keep a lid on the software complexity that only graybeards can handle.

https://redd.it/1btn46t
@r_emacs

Читать полностью…

/r/emacs

Change color for doom modeline modified buffer indicator

Hi, I would like to change the color of the modified buffer indicator in doom-modeline. I am not sure how to do it. I have tried (setq doom-modeline-buffer-modified (doom-color 'red)), but it does not seem to work, neither does it give any error. Any help is appreciated. Thanks a lot.

https://redd.it/1btjelc
@r_emacs

Читать полностью…

/r/emacs

Eglot symbols view pane

I'm trying out eglot after using lsp-mode. I had been using lsp-treemacs to view symbols and want a similar capability. What are the options people are using with eglot?

https://redd.it/1btez7y
@r_emacs

Читать полностью…

/r/emacs

Python Jetbrains-like LSP

Im migrating from Jetbrains Pycharm into Emacs and I was wondering if there is a way I can get autocompletions similar to Pycharm, this is:
1 - Some way of "auto importing" modules (or at least some way of given a class/function get the option to import it)

2 - LSP for internal stuffs, atm my lsp desnt seem to "know" about many homebrew classes' methods we have in our project.

Here is the current LSP cfg i have on my emacs
(use-package pyvenv

:config

(pyvenv-mode 1))

(use-package python-mode

:ensure t

:hook (python-mode . lsp-deferred)

:custom

;; NOTE: Set these if Python 3 is called "python3" on your system!

(python-shell-interpreter "python3")

(dap-python-executable "python3")

(dap-python-debugger 'debugpy)

:config

(require 'dap-python))

&#x200B;

&#x200B;

(use-package company

:after lsp-mode

:hook (lsp-mode . company-mode)

:bind (:map company-active-map

("<tab>" . company-complete-selection))

(:map lsp-mode-map

("<tab>" . company-indent-or-complete-common))

:custom

(company-minimum-prefix-length 1)

(company-idle-delay 0.0))

&#x200B;

(use-package company-box

:hook (company-mode . company-box-mode))

&#x200B;

(use-package importmagic

:ensure t

:config

(add-hook 'python-mode-hook 'importmagic-mode))


&#x200B;

&#x200B;

Maybe I just need a clear example of how to set up LSP properly, thanks in advance guys, sorry if im asking anything too obvious/stupid

https://redd.it/1btbbbe
@r_emacs

Читать полностью…

/r/emacs

Magit and listing changes to files in a particular sub-directory?

Magit enables for checking all changes to a files via the l----select-file-l option, but does it allow to select the directory rather than the file?

I can't see anything like that in the options.

Is there some way to do that directly in Git?

https://redd.it/1bsv91g
@r_emacs

Читать полностью…

/r/emacs

Corfu candidates truncated

I am having trouble figuring out why I get truncated results when using corfu. Ideally, I would like the list to auto-resize as needed, depending on the candidate.

&#x200B;

&#x200B;

https://preview.redd.it/oguwh8dspiuc1.png?width=1114&amp;format=png&amp;auto=webp&amp;s=e73f08c76e3d5ceed24c2de592df895ef9d187a9

https://redd.it/1c45n2e
@r_emacs

Читать полностью…

/r/emacs

Emacs crashes with Treesitter update

On Arch Linux, there was a new Treesitter update today(0.22.4-1). After that update, Emacs crashes when opening any file with Treesitter enabled. Sadly I've also lost some java files after crashing.

Anyone else having the issue?

https://redd.it/1c3wpbt
@r_emacs

Читать полностью…

/r/emacs

latex environment transclusions
https://redd.it/1c3wbrt
@r_emacs

Читать полностью…

/r/emacs

Modern tabs in Emacs
https://redd.it/1c3oqqh
@r_emacs

Читать полностью…

/r/emacs

is creating a minor mode to browse a certain website crazy?

Just an idea I had cause I want to write some elisp.

Website in question has a read only JSON api, so I would need to figure out posting

ideas/comments?

https://redd.it/1c3ljyc
@r_emacs

Читать полностью…

/r/emacs

configuring lsp-java to resolve external jar

# tl;dr:

add <classpathentry kind="lib" path="path/to/jar.jar"/> to .classpath file in the corresponding workspace folder of your project in you .emacs.d that may looks like ~/.emacs.d/.local/etc/java-workspace/nameofworkspace_253tft34t or ~/.emacs.d/workspace/nameofworkspace_253tft34t, nameofworkspace being the name of the root folder of your project, and 253tf34t is some random string.

After which it should looks like this:

https://preview.redd.it/zgcc141ekcuc1.png?width=1920&amp;format=png&amp;auto=webp&amp;s=6aeb82f4f6b7ab4a39db4db5e21f729064b02d65

below is the longer explanation

# Facts

lsp-java use jdtls
when using lsp-java, codes are organized into workspace(aka project). as lsp-java uses jdtls, this workspace(aka project) follows jdtls project structure = eclipse project structure. This structure looks like this in eclipse:

├── .classpath (xml holding paths to build path resources locations)

├── .settings/ (plain text files holding something I don't care about)

├── bin/ (where class files are at)

├── src/ (where java source files are at)

└── .project (xml holding something I don't care about)

lsp-java keeps everything in the eclipse project structure other than `src/` in emacs's cache. for doomemacs, it is `~/.emacs.d/.local/etc/java-workspace/nameofworkspace_253tft34t` . If you don't use doomemacs, it probably is in `~/.emacs.d/workspace`. Just `find` your `.emacs.d` and grep lines with`.classpath (find ~/.emacs.d/|grep .classpath)`
to get your jdtls to resolve an external jar, you need to add something to the .classpath configuration file, so that jdtls search/cache for that external jar.

# Getting a project configuration with external jar that works

Install eclipse, create a new project with their wizard. From there:

1. delete module-info.java (see this post for why)
2. go to your project directory and look at .classpath there.
3. import a jar into your project with their wizard (see this post for tutorial)
4. go to look at .classpath again, to see what have changed.

I did the 4 steps, and I see no change in .project and this new line <classpathentry kind="lib" path="/home/linfeng/playground/projects/uol/comp329/webots/lib/controller/java/Controller.jar"/> in the <classpath> tag. I inserted that line in the .classpath file in my lsp-java workspace folder in ~/.emacs.d/.local/etc/java-workspace/nameofworkspace_253tft34t, and restarted emacs(because lsp-restart-workspace takes forever and raise new issues), and I can get code completion from my externel jar, and lsp-java can resolve the packages in it.

# Use the wizard

As there's zero-to-none tutorial/wiki on how to configure lsp-java workspace, I think doing the operation in eclipse with their gui wizard and copy the update of project configuration probably is the best way to try to find way to make lsp-java work.

# thanks to

this post. I spent weeks trying to make lsp-java to resolve anything other than the builtin before finding out that it supports gradle and pom.xml and stuff. But to use them you need the heavy build system, everything looks like a mess, so I just gave up and wrote my java programs without code completion.

Tonight I read that post above. Sadly that solution did not work out for me, but that reminded me of times when I use eclipse to generate shell commands(BaseX at that time only provide eclipse project download), so I go installed eclipse, use the wizard, copy the result, and it worked!

https://redd.it/1c3i4y0
@r_emacs

Читать полностью…

/r/emacs

is it possible to enable a minor mode in the minibuffer?

I am writing a mode that prompts the user for some latex code in the minibuffer. In order to type this faster, it would be nice to enable cdlatex mode in the minibuffer only when prompted by my mode, is this possible?

https://redd.it/1c3dzr0
@r_emacs

Читать полностью…

/r/emacs

how to get wrapping isearch with ivy?

I've currently set up my ivy search to work almost to my liking:

(global-set-key "\C-s" 'counsel-grep-or-swiper)
(global-set-key "\C-r" 'counsel-grep-or-swiper)
(define-key swiper-map "\C-r" 'ivy-previous-line-or-history)
(define-key swiper-map "\C-s" 'ivy-next-line-or-history)

but is there a way so that within swiper if I hit the very top of the file and say previous-line that it wraps to the bottom of the available search items? Vice versa for if I hit the bottom.

https://redd.it/1c3d6mf
@r_emacs

Читать полностью…

/r/emacs

how to disable symbols for Org-mode?

It will auto convert LaTeX to HTML code.

I know it can be used Escape Character, But I want to disable it.

https://orgmode.org/worg/org-symbols.html

https://redd.it/1c331vn
@r_emacs

Читать полностью…

/r/emacs

Unable to use cdlatex's math abbreviations

How do i use cdlatex's math abbreviations, like `fr TAB`, all the TEXT abbreviations work, but none of the MATH one's do.

https://preview.redd.it/he4nz4g8vyrc1.png?width=680&amp;format=png&amp;auto=webp&amp;s=6344587590d2ecd38ce16a12648c296e5609bf28

https://redd.it/1btlu0i
@r_emacs

Читать полностью…

/r/emacs

How to stop evil mode from changing cursor location and highlighted region

Hello everyone, I just fixed a long-time annoyance I had with evil-mode. I couldn't find this info online so I thought I'd share it.

## Problem:

In regular evil-mode, when you copy or format some text, evil will mess with your highlighted region (if you are in a visual mode) and your cursor. The cursor position will always be set to the original point or mark preferring the one which comes first. If you are in visual mode it will always unhighlight your region, which I also find annoying.

## Cursor Example

1. If you highlight from left to right and yank, your cursor will jump to where you started highlighting.
2. If you highlight from right to left and yank, the cursor will stay where you stopped highlighting.
3. If you highlight top to bottom and yank, your cursor will jump to where you started highlighting.
4. If you highlight bottom to top and yank, the cursor will stay where you stopped highlighting.

This also applies to something like "y%" or "ya(". If you start on the "(" your cursor will be left there. If you started on the ")" your cursor will be moved to the "(".

As you can see, the point always ends up on whichever, mark or point, comes earlier in the buffer.

## Solution

(defun my/evil-dont-move-cursor-or-unhighlight (orig-fun &rest args)
"Stop evil mode from unhighlighting region or moving the cursor."
(let ((orig-point (point))
(orig-mark (mark))
;; note: calling (evil-visual-direction) actually doesn't give correct results so use the variable
(orig-direction evil-visual-direction))
(apply orig-fun args)
(if (eq evil-state 'visual)
(progn
(evil-visual-make-region (mark) (point))
(when (= orig-direction 1)
(exchange-point-and-mark)))
(goto-char orig-point)
(set-mark orig-mark))))

(advice-add 'evil-yank :around #'my/evil-dont-move-cursor-or-unhighlight)
(advice-add 'evil-indent :around #'my/evil-dont-move-cursor-or-unhighlight)

Here we add advice to the evil-yank and format functions. Looking at the source code, all of the other evil-yank functions are subroutines so we should be okay only adding advice here. This seems to alleviate the grievances I had with the out-of-the-box functionality. Not sure why the default behavior is so strange, but I didn't see any configuration options to change it.

I hope you find this useful, please let me know if I overlooked anything.

https://redd.it/1btmcwv
@r_emacs

Читать полностью…

/r/emacs

NNO Writer Mode
https://redd.it/1btgvnr
@r_emacs

Читать полностью…

/r/emacs

How I can use Emacs on my own machine as $EDITOR on a remote machine?

I have two machines: my laptop and a VPS. They do not share a filesystem. I regularly ssh into the server from the laptop and work on the commandline. I use a terminal emulator which runs in emacs on the laptop. Sometimes this involves opening files, often automatically, in $EDITOR (e.g. for a git commit). I want to configure $EDITOR so that the instance of emacs running the terminal emulator is also used as $EDITOR on the server, when I'm sshed into it. Ideally, I'd like to set it up so that if I ssh from a terminal which isn't running in emacs, a different program (one local to the server, e.g. nano) will be used, but that's a later question.

How can I do this? I've read a cursory explanation here, but that seems to require a shared filesystem, and it's pretty brief -- I'm new to any kind of networking. I do like the idea of using emacsserver to achieve all this though.

TIA!

https://redd.it/1btdurw
@r_emacs

Читать полностью…

/r/emacs

Why doesn't this piece of advice-add code work?

Hi, greetings, guys. I'm trying to disable all enabled themes before using (load-theme) to switch to another theme, but the following code has encountered a problem:

(defun my/disable-all-themes ()
(mapcar 'disable-theme custom-enabled-themes))
(advice-add 'load-theme :before 'my/disable-all-themes)

The debugger outputs:

apply: Wrong number of arguments: (lambda nil (mapcar 'disable-theme custom-enabled-themes)), 3

https://redd.it/1bt41m1
@r_emacs

Читать полностью…

/r/emacs

Installing theme files and the relevance of the additional files in their directories

After installing themes from repos by cloning them mostly from Github into my themes directory it looks I need to copy the theme-xx.el files to the top-level themes directory to get them to be detected.

I am not sure whether some or all of the files which remaining in the repo subdirectories need to be copied to the top level themes directory, but I presume that some of the files may be necessary to the full and correct functioning of the themes, such as the contents of their img directories.

There is also the matter of not being able to commit their directories because they are git repos themselves and I don't know how useful it may be to add them as sub-repos.

How do I work my way around this?

Is there some means of installing a theme by running some additonal code in some files it is associated with or is just copying the main theme files to your themes folder enough?

Maybe my theme installation code needs to iterate every directory in the themes directory and execute a file .el matching the directory name, rather than just placing them in the themes directory?

https://redd.it/1bsuyu0
@r_emacs

Читать полностью…
Subscribe to a channel