Emacs

313 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
201
 
 

By forward function declarations I mean what is needed when a function defined later in the file is called from a preceding one.

By circular I mean file A requires a function in file B which requires a function in file A. Something along those lines

PS. Apologies for inquiring about this again. I am sure I enquired sometime in the past and forgotten the actual question and the response to it.

202
 
 

If I understand it right, goto-last-change should go to the places where I made the last edits. But often, when I want to go back, it seems to have "forgotten" them, jumps to a very old edit, and then displays "No further change info" in the minibuffer.

I just had the problem again. I made sure the edits are very far away, many lines in the same org-buffer. Neither goto-last-change-reverse nor goto-last-change does find them. But when I use undo-redo, all my "forgotten" edits are found and subsequently undone. How can that be?

Do you use a different function for going back to the last edits? Or am I using goto-last-change in a wrong way? The variable glc-default-span is set to 8, and I am using Org mode version 9.6.9 and Emacs 29.1. Thank you for any advice!

Edit: I also use undo-fu-session, could it be that this interferes with goto-last-change?

203
 
 

I have this code:

(defun send-raw-key-fun (str)
  (lexical-let ((str str))
    (lambda ()
      (interactive)
      (term-send-raw-string (read-kbd-macro str)))))

 (define-key term-raw-map (kbd "C-c c") (send-raw-key-fun "C-c"))

and it doesn't work anymore with ansi-term. I'm not able to end the process inside.

Got error:

(wrong-type-argument stringp [3])

Does anyone know what to do to make this code work again?

204
 
 

The context here is, I'm working in a company environment that is using https://trunk.io in its dev environment, which is kind of a meta-linter for many languages. It wraps a bunch of backend lint tools and combines their results, and enforces a company wide policy on all of them. They provide integrations for a few IDEs, but nothing specific to emacs yet. What they do provide is an LSP proxy to their tool. I have been looking if there is any support in flymake or flycheck to use a generic LSP server as the checker backend, and I haven't found anything. Does anyone know if this is possible? Or if there's an existing backend that's close enough that could be tweaked to do this? I've attempted to duplicate the trunk configuration using individual flymake backends, and the maintenance is just too much. It would be way easier to just make use of the tool directly.

205
 
 

I have rebuilt Emacs 29 with PGTK in order to get Emacs running natively and to fix the fonts, and i already have another emacs 29 build (Lucid) installed with i use On X.
I was surprised to see Emacs on wayland was running slower than its counterpart on Xwayland. Also the fonts issue was not fixed.
While zooming in makes the fonts look better. On X i don't have this issue.
Below is screenshots of fonts on Wayland - Xwayland and X

On wayland (PGTK)

Xwayland (Lucid)

Xorg (Lucid)

206
207
 
 

Hi. I'm getting really frustrated by how unpredictable `C-` mappings are when it's bound to both uppercase and lowercase character. What I've tried:

(global-set-key (kbd "C-q") 'cmd)
(global-set-key (kbd "C-Q" | "C-S-q" | "C-S-Q" | "C-\S-q" | "C-\S-Q" | ...) 'cmd-2)

and swapping the lines.

I never manage to get the intended behaviour – it keeps translating the uppercase to lowercase or vice-versa. And sometimes it doesn't – there seems to be no pattern.

Could someone help me out?

208
 
 

I'm losing my mind over emacs as a python IDE. It seems that no matter which LSP concept I attempt, the experience is suboptimal. At best it is riddled with odd issues, and at worst almost bordering unusable.

I work as a python developer, and I work on quite large code bases. The LSP experience is essential for me given the complexity, but I'm at the point of giving up, even though I've been an emacs user for the better part of a decade.

I use doom emacs, by the way, but I'm quite happy to try anything to solve this. I have considered to build an emacs config from scratch again to see if I can narrow down the experience, but right now I have not invested the time. But again, considering how frustrated and desparate I am, everything is on the table.

Let me describe what I need and what I've tried.

My requirements

I need my lsp to understand my environment in order to load in a custom PYTHONPATH variable. This I handle with a .envrc file and the emacs module envrc. This has worked without any problems so far.

For the actual LSP, I use python-lsp-server but I am not at all religious about it.

I run mypy on my codebase, and I'd like to use ruff for checking/formating, but I've used the other tools (pycodestyle/black) for now.

lsp-mode

The lsp-mode is the one that is closest to being good, had it not been for the abysmal behavior over time. It seems that some memory leaking happens, and over time it becomes sluggish, sometimes blocking emacs for multiple seconds.

eglot

Eglot seems a lot faster, but has functional problems. I've often had to restart eglot when opening new python modules. I've tried to use eglot for months now, accepting the quirks to gain the speed, but the restart behavior is annoying, and I often get weird errors such as error in process filter: Wrong type argument: plistp, [] repeatedly until I restart eglot again. No luck debugging that error so far either.

I'm also not super excited about the .dir-locals.el approach to customization, but should the other issues resolve, I'm willing to figure that one out.

lsp-bridge

I was quite excited to hear about a third option that was super fast. However, I've not manage to get it to work with the envrc package, so I've parked that one.

So, I turn to you, kind strangers on the internet. Do you have a well-functioning python LSP setup in emacs? Have you experienced some of the issues that I have described and did you manage to solve it?

Do you perhaps have a described approach to building a great python setup with emacs? Please help me!

209
 
 

Hi everyone! I'm currently using doom emacs with eglot. And I'm quite happy of how lightweight it is. However, I'm only able to see the diagnostics message when hovering the cursor over some error.

I wonder if there is any similar package or eglot configuration to replicate what Error Lens does in vscode? Thank you in advance.

My config looks as follows, I'd kindly appreciate any suggestion that could help me to improve my eglot experience:

(use-package! eglot
  :defer t
  :init
  (setq eglot-autoshutdown t)
  :config
  (setq eglot-ignored-server-capabilities '(:hoverProvider :documentLinkProvider :inlayHintProvider :documentOnTypeFormattingProvider))
  (add-to-list 'eglot-server-programs '(rust-mode "rust-analyzer"))
  (add-to-list 'eglot-server-programs '(scala-mode "metals"))
  (add-hook 'eglot-managed-mode-hook (lambda () (flymake-mode -1)))
  :hook
  ((rjsx-mode rust-mode typescript-mode js2-mode scala-mode) . eglot-ensure))

210
 
 

I don't want to export the entire file as markdown, I want to copy a region which assumes org syntax with the syntax converted to markdown syntax. Also, I want to be able to paste something that was copied using markdown syntax as org syntax. Does anyone currently have anything for this?

211
 
 

I came across an issue using Emacs when switching to a wayland compositor (hyprland).
The fonts don't look right as you can see at the screenshot below, but zooming in makes it better.
My current emacs build is using LUCID no PGTK.
I'm thinking of building another Emacs build with PGTK support that runs natively on Wayland without Xwayland. However i'd like to install them both.
As i use Lucid version on XMonad most the time, but still when i switching to wayland i could still have a better font.

u

https://preview.redd.it/nnoue1xr470c1.png?width=685&format=png&auto=webp&s=544a2c57604eeff12de176ca12b83528e752d68e

u

212
 
 

According to the documentation of the CL library, it is allowed to have code like

(cl-check-type '(a b) proper-list)

where the undefined type symbol proper-list will be automatically interpreted as

and indeed it does work. However, after upgrading from Emacs 27.1 to 29.1, I am suddenly getting a compiler warning

Warning: Unknown type: proper-list

for such lines, unless I either rewrite it more verbosely as

(cl-check-type '(a b) (satisfies proper-list-p))

or provide an explicit type definition

(cl-deftype proper-list () '(satisfies proper-list-p))

Is anyone aware, if this is intended behavior?

213
 
 

I'm wondering if there's any way to make a variable automatically save its old value, so that I can, e.g., write a minor mode that will automatically restore the old values of variables when it's deactivated (without having to declare a bunch of -old-value variables).

214
 
 

I'm a noob (of nearly 3 years using emacs).

Buffer / window management still confuses me.

I haven't really learned to use / position / switch windows and buffers. Simply because I used to one org-mode window most of the time.

Now I'm using org-roam, amd dealing with multiple small files, I keep getting stuck in silly situations, like ending up with:

  • a roam buffer and my fallback buffer vertically stacked - when I want to "fullscreen" the window with the roam buffer, I can't delete or kill the fallback window / buffer.

  • two fallback buffers vertically stacked. Neither of which I can kill or delete.

Is there a good guide somewhere?

215
 
 

I do use desktop-mode to restore my tab and window layouts and loaded buffers. I also switch workplaces regulary and use different monitor layouts with different scaling factors.

It would be great to use dekstop save mode without saving/restoring frame postion and size.

I am aware of desktop-restore-frames but unlike it's name, at least on Emacs 29, setting this to #f also doesn't restore tab configuration and window layouts what I don't want.

216
 
 

Hi

I managed to setup lsp and java for emacs. I can compile and all works fine.

I set compile command in init.el to run javac and java command so I see the result, as below.

(setq compile-command "javac YourJavaFileName.java && java YourJavaClass")

For now I have to replace "YourJavaClass" with current class. Can anyone help me to automatically pass currently opened class name to that command, please?

Thanks!

217
 
 

I'm looking for something that would make my coding more bearable.

Currently I'm using neovim plugin in VSCode, but Vim have bad support for mouse, like it's really weird, when I select text, I needed to setup in VSCode for it to pass to neovim, just so neovim could see it as visual selection. And if I give up on selection, I can't just select anywhere on text, to get rid of selection (like in normal editors), but need to Esc, or else, it would jump to place in text where I clicked.

But tried getting into emacs, just for the sake of better mouse support, but I'm not sure, if emacs is like Vim or not ? Like, I could see, it uses M- (Alt) and C- (ctrl) key.

Problem, is that it's inacesible for me to use those keys, like, I'm relying on touch typing, and typing Alt or ctrl everytime when I need to do something in emacs, would slow me down, and it would make touch typing super hard.

Alt key, is close to space, but it will cause me a lot of strain on fingers and cause RSI.

That's reason why I stayed with Vim, but also, wondered, if Emacs, can be like Vim, at least basic motions , moving etc. I don't use Vim that advanced anyways, just do basic motions, and stuff, and it greatly improves my work. But still, mouse support is major problem, that alone, completely slows down my coding. But yet, don't know what alternative I would have.

I heard about evil-mode, or spacemacs, but I don't like idea, that someone else remapped keys, their way. And also tried getting into emacs once, and got confused when trying to change configuration, like, everyone mentions, that I need to code some functions in some Lisp language (new for me), in order to have keybinding change or stuff.

Like, I haven't ever used VimScript, just need it for motions and a few plugins that helps with moving in file.

218
 
 

Is there some way to make visual-line-mode more smart about line-breaks? As depicted in fig.1, visual-line-mode doesn't really handle overly-long lines (e.g. due to URLs) well. Disabling it entirely makes a bad overall trade-off in files containing mostly textual lines (fig.2).

It could improve by allowing line-breaks on some non-whitespace characters (like "-" or "/") or simply disabling visual-line-mode entirely for "words" that anyway need more than one line. Better yet, for any word exceeding a maximum character-length (e.g. 50) in order to better handle lines containing a few words, but also a moderately long URL (e.g. when using the markdown syntax [link name](link url)).

I've found no existing options in the M-x customize interface, nor any relevant packages in M-x package-list-packages (including MELPA).

Fig.1 When breaking long \"words\" like URLs, visual-line-mode is not very smart about where to break the lines.

Fig.2 For URLs, having no visual-line-mode line breaks active would be preferable, but the disadvantage of disabling visual-line-mode for lines with actual text is too big to just disable visual-line-mode entirely.

219
 
 

With apologies to Mickey Peterson, a GPT for yak shavers:

https://chat.openai.com/g/g-ceQ8Ju6Rg-emacs-expert

220
221
 
 

Are there any existing plaintext file format to for storing discussion forums posts like this one or ubuntuforums. I want to archive the discussion I like locally. i have been using singlefilez for download the whole page into my machine, but i prefer plaintext formats. When I tried Org-web-tools, it does not seem to properly extract reddit discussion pages for example.

I suppose I can write a scraper and dump content in json format. I'd prefer a plaintext format like org-mode and was designed with some thought put into this, instead of me cobbling something together.

222
 
 

How do I use the fixed-pitch font for math fragments in org-mode buffers? I.e., I want to use a monospace font for all strings of the form \(...\) or \[...\], where ... may include newline characters as well, as is common for equations written in math display mode.

I'm an Emacs newb, so the best I could come up with was a regex-based font-lock:

(progn
  (setq-local font-lock-keywords
              `((,(rx (group
                       (or "\\[" "\\(")
                       (zero-or-more anything)
                       (or "\\]" "\\)"))) (1 'fixed-pitch))))
  (font-lock-fontify-buffer))

And then running this on an org-mode-hook.

But this is definitely wrong. Not only does it remove all the nice org-mode styling applied to things like section headers, but it's also applying the fixed-pitch font to more than just the intended math fragments, suggesting issues with the regex at least.

223
 
 

So, finally it's ready: https://github.com/SebastianMeisel/journalctl-mode v1.1 is now available on MELPA:
- transient menus
- asynchronous process calls
Overall: more accessible a much faster, less resource intensive. Thanks for all feedback in the last days, that helped me bring it forward!

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

224
 
 

idk what these icons symbolise i don't want any lavish gif as icons but these icons just don't make sense to me is there any font pack i have to modify or do i have to modify any icons file contents

i want to patch this issue i'm just annoyed with this issue at this point i have been using this since last two years i didn't care much to resolve this but now it's just annoying

225
 
 

Eglot is a lot more bare-bones than lsp-mode – leaving 'UI chrome' to external packages that can work generically with emacs' existing ecosystem (flymake/eldoc/etc.) – and this generally works for me. Making similar migrations in my config has worked out very well – notably to use vertico family of packages for completions.

Are there packages you like that provide additional chrome on what eglot makes available? I'm particularly interested in project diagnostics from flymake, but I'm curious to see what else folks have come across.

view more: ‹ prev next ›