r_emacs | Unsorted

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

70

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

Subscribe to a channel

/r/emacs

emacs29 treesit support

I'm trying emacs29 treesit support for C/C++, reading around I configure the builtin package as follows:

(use-package treesit
:ensure nil ;; emacs built-in
:preface
(defun my/setup-install-grammars ()
"Install Tree-sitter grammars if they are absent."
(interactive)
(dolist (grammar
'((c "https://github.com/tree-sitter/tree-sitter-c/" "master" "src")
(cpp "https://github.com/tree-sitter/tree-sitter-cpp/" "master" "src")))
(add-to-list 'treesit-language-source-alist grammar)
(unless (treesit-language-available-p (car grammar))
(treesit-install-language-grammar (car grammar)))))

(dolist (mapping '((c-mode . c-ts-mode)
(c++-mode . c++-ts-mode)))
(add-to-list 'major-mode-remap-alist mapping))
:config
(my/setup-install-grammars)
(setq treesit-font-lock-level 4))


But then how do I configure different modes, for example, currently (before enabling treesit), this is how I configured C/C++:

(use-package cc-mode
:ensure nil ;; emacs built-in
:preface
(defun my/c-indent-then-complete ()
(interactive)
(if (= 0 (c-indent-line-or-region))
(completion-at-point)))
:config
(dolist (map (list c-mode-map c++-mode-map))
(define-key map (kbd "<tab>") #'my/c-indent-then-complete))
(add-hook 'c-mode-common-hook
(lambda ()
(c-set-style "stroustrup")
(c-set-offset 'innamespace [0]) ; Do not indent in namespaces
(c-set-offset 'cpp-macro 0 nil) ; Indent C/C++ macros as normal code
(c-set-offset 'substatement-open 0) ; Align braces with the if/for statement. If not set, a half indent will be used
(c-set-offset 'arglist-intro '+) ; Align multiline arguments with a standard indent (instead of with parenthesis)
(c-set-offset 'arglist-close 0) ; Align the parenthesis at the end of the arguments with the opening statement indent
(setq-local c-basic-offset 4) ; Base indent size when indented automatically
(setq-local tab-width 4)
(setq-local indent-tabs-mode nil)))
:init
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.cpp\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.hpp\\'" . c++-mode)))


Is that config still valid? Do I need to do something else?
Also, when being on a C++ buffer, how do I know if treesit is actually being used? Should the major mode be something like c++-ts-mode?

https://redd.it/16wfrp3
@r_emacs

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

/r/emacs

Having to quit(), start the interpreter and import every time I edit the code?

Hello!

I'm new to emacs and so far it's really easy to use and it's very effective. One annoying thing however is that every time I edit the code I'm writing, I have to quit() in the interpreter, close the window (Ctrl-x + 0), restart the interpreter (Ctrl-c + Ctrl-p) and reimport the code.

I edit the code and then just write "import *script*" but the changes don't appear unless I do it as mentioned above.

Even if I just quit(), I can't just (Ctrl-c + Ctrl-p) again because I have to close the buffer for it to start again.

Is it supposed to be like this? Or am I doing something wrong?

Thanks in advance!

https://redd.it/16wdbwc
@r_emacs

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

/r/emacs

How do I get a left pointer for file searching and interactive commands?

I saw this video where at one point he goes through his buffer list and has a visible pointer to the item currently selected.

pointer

How do I get this too?

https://redd.it/16w8tol
@r_emacs

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

/r/emacs

emacs org mode on windows

i'm not a expert in emacs org mode, i just find out a while ago and i've become very interested in this way to kind of take notes and organize files

i'm a windows user since 2013 and i want to know if i can install emacs and org mode extension in my windows device, once idk if i really want to switch for ubuntu

https://redd.it/16vdvgo
@r_emacs

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

/r/emacs

Emacs Module Critique

I started using emacs this week and have been interested in using org. I went for a modular config and attached my very simple org module below.

From what I've read so far there isn't necessarily a "correct" way to configure emacs but I'm asking for a critique on anything in this module. Whether that be my use of use-package (especially as I've found its documentation somewhat unclear), my custom function, code style, or anything. I would appreciate any two cents or bits of wisdom as I begin my journey configuring emacs.

&#x200B;

https://preview.redd.it/gy7ltd4219rb1.png?width=1480&amp;format=png&amp;auto=webp&amp;s=fabdaf448f088953cef10e5e305a36915da96e6b

https://redd.it/16vlemn
@r_emacs

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

/r/emacs

how to make lsp and eglot way faster like neovim?

through little bit of research i have found a way to make Emacs faster with lsp and eglot none of this are my code i just found it from browsing on reddit

(fset #'jsonrpc--log-event #'ignore) remove laggy typing it probably reduces chatty json from lsp to eglot i guess

(setq eglot-events-buffer-size 0) disabling event logging in eglot

(setq eglot-sync-connect nil) disabling elgot freeze the UI for up to 3s when you open file maybe large one

install gcmh package to increase the gc value when necessary and decrease it. nice package btw

(add-hook 'focus-out-hook 'garbage-collect) optional, if you don't want to use gcmh package

(setq eglot-connect-timeout nil) optional "my code actually"

set this values on company package or

(setq company-idle-delay 0) how long to wait for company mode to wait after it got completion obviously you don't want to wait so just set it to 0

(setq company-minimum-prefix-length 1) how many characters you want to type before popping up the completion UI obviously 1 right

if there is anything that i am missing pls let me know guys, am new to Emacs i want to learn from you all. i would love to see your config too to learn how to configure mine too

https://redd.it/16vixg6
@r_emacs

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

/r/emacs

paragraph.

https://redd.it/16vdsuy
@r_emacs

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

/r/emacs

ob-ledger-convert: Convert anything to ledger using Babel

After struggling for years to manage my personal finances, found ledger/hledger. My goal is to find my yearly expense so that I can make FIRE plan. Ledger is great, but required to create transactions in ledger. Struggled with parsing bank/card pdfs, manually creating entries and nothing worked. Eventually realized that I can just copy the text from pdf into emacs and then format it using emacs macros. Then next task was to convert the transaction lines into ledger entries. This gave birth to `ob-ledger-convert` or `ob-lc` to provide `lc` src blocks in the org mode which when executed convert the given transactions into ledger format. It does need parsers and I have provided some of the parsers used by me in the `ob-lc` module. New parsers can be added easily.

This post is to share the enthusiasm of the emacs being such a fascinating machine which lets you do anything you want and also to get the feedback from the community on the package.

The sample org file provided in the repo provides a gist of how to use the module.

ob-ledger-convert: jayrajput/ob-ledger-convert: Convert anything to ledger in emacs org babel (github.com)

&#x200B;

https://redd.it/14fy1xc
@r_emacs

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

/r/emacs

interested in emacs as a whole, but have no idea what it can really do

hey! I'm a newly-converted Linux user (dabbled with it a bunch but it finally feels to have really stuck), and I've always used vim as a default console editor, which has been good, feels pretty fast, though all i really do is edit config files with it.

i hear a ton about emacs, and the lengths to which people take it, but i don't actually know what it can do

basically all i know is that it's a very configurable text editor, but from what I've heard, that description doesn't really do it justice.

so basically, tldr, what makes emacs so good? why do people like it so much?

https://redd.it/14fp22r
@r_emacs

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

/r/emacs

Displayed cursor jumps editing elisp files
https://redd.it/14fjow0
@r_emacs

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

/r/emacs

Treemacs all the icons

Hi everybody ! I'd like to use all the icons with treemacs but I can't figure how to do it. I tried (straight-use-package 'treemacs-all-the-icons) I use straight package manager, but it doesn't work. I tried (treemacs-load-theme "all-the-icons") but didn't work either.
Any ideas ?

https://redd.it/14fatmz
@r_emacs

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

/r/emacs

Automate Your Blog Workflow with Org-mode TODOs and Ox-Hugo

https://www.armindarvish.com/en/post/building\_an\_efficient\_blogging\_workflow\_in\_emacs/

https://redd.it/14f2xdz
@r_emacs

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

/r/emacs

Creating regions within a buffer

To preface - I started using emacs about 2 years ago, and this is my first real foray into trying to make something of my own.

I've been trying for a while to find an emacs startpage that I find useful. I work mostly out of org files, so I have no use for the scratch buffer, the default is fine but a little lacking in functionality (for me at least) and I tried the dashboard.el package (which is what inspired me to try to make my own).

My goal is to take a single buffer and divide it into multiple regions, so that, for example, the top half could display a calendar (I use calfw, so I had intended to show the one week view here) and the bottom half could be divided into left and right. (I had wanted to show magit-list-repos and org-agenda here). I didn't see any existing packages that seem to allow for this, though I absolutely could have missed something.

This could obviously be changed, my thought was that it could function similarly to how you define elements in html, and if I get it working could be pretty dynamic and flexible. I'll settle for some hardcoded regions though, if it means I could get something to work.

This presents some challenges. I toyed with simply copying the output of the respective commands, and I got close to making that work before I realized that, while that would solve my problem, it sort of defeated the point of what I had undertaken in the first place. Next, I tried overlays but to be honest I couldn't make that work at all. I started looking into it based on the name ("overlay" just sounded like it would do what I wanted, but once I read more into what it did I wasn't entirely sure).

That lead me to make this post - I don't really know what else to try, or even if an idea like this is feasible within emacs. I'm attaching a sketch that hopefully illustrates what I would like this to do...

I'd appreciate any input!

Also - yes, I realize that I can split windows to accomplish the layout that I'm looking for. The reason I didn't use that is because I want to use this as my screen that shows when I open emacs. If I have three windows automatically open with their own buffers, I would have to close 2 of them just to focus on one window - which is a little annoying.

https://preview.redd.it/e7w21lhklb7b1.png?width=2843&amp;format=png&amp;auto=webp&amp;v=enabled&amp;s=398b257c08ad25951af6735a8d11a1b42a2ae426

https://redd.it/14f0e83
@r_emacs

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

/r/emacs

Ran Into A Error When Installing Doom Emacs

Im trying to install doom emails on my 2015 MacBook Pro using the GitHub repo.

https://github.com/doomemacs/

git clone --depth 1 --single-branch https://github.com/doomemacs/doomemacs ~/.config/emacs
~/.config/emacs/bin/doom install

However I ran into this error after installing it?


> Building git-gutter-fringe > Building git-gutter...
Cannot open load file: No such file or directory, backtrace
✓ Finished in 2m 33s
Error in kill-emacs-hook (#128 "\302\300\303\301\"\"\207" [doom-cli--output-write-logs-h (#s(doom-cli-context (25746 27146 809877 0) 2623 0 (80 . 24) nil nil "doom" nil nil ...)) apply append 6 "
(fn &rest ARGS2)"]): (file-missing "Loading charset map" "No such file or directory" "GB180304")

&#x200B;

https://redd.it/14evzln
@r_emacs

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

/r/emacs

read a variable from parent scope in `cl-function`

hi, how can I use a variable from outer scope in \`cl-function\` for ex:

(cl-function
(lambda (&key data &allow-other-keys)
(append (list (json-parse-string data)) callback-args)))

&#x200B;

the `callback-args` are defined in the outer scope of this function, how to include it in the current function, already tried

`(append (list (json-parse-string data)) ,callback-args)

&#x200B;

https://redd.it/14ei6en
@r_emacs

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

/r/emacs

How do I improve my development experience in Emacs?

I've been using Emacs for 4 months now, and seriously, and I don't want to go back to VSCode because of the fact that I can do everything in it (notes, task management, and programming; I also love org-mode). Unfortunately, my development experience has been okay-ish with Emacs. I have installed lsp along with corfu for completions (and web-mode for ReactJS) but the completions are not as good as VSCode. They are quite slow too. Here's the link to my config file. How can I improve the completions? I would also like it to highlight unused imports (flycheck isn't doing it, idk why). Just this much would suffice :) I don't need anything else from a code-editor (although Emacs is so much more than that).

https://redd.it/16wejym
@r_emacs

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

/r/emacs

Using Emacs as $EDITOR
https://magnus.therning.org/2023-09-30-using-emacs-as-$editor.html

https://redd.it/16w9bvh
@r_emacs

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

/r/emacs

Invoke org-export-dispatch from CLI?

I can't find any documentation on running org-export-dispatch commands from CLI? Is it as simple as evaluating the command from with the shorthand letters as arguments (e.g. emacs -e '(org-export-dispatch H A)')?

https://redd.it/16w923r
@r_emacs

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

/r/emacs

How do you load a package without ;;;autoloads header? (doom emacs)

There is a really niche, but simple package for elfeed that adds system notifications: https://github.com/flocks/elfeed-notifier/blob/master/elfeed-notifier.el

However loading it by default with straight package manager doesn't work:

(package! elfeed-notifier
:recipe (:host github :repo "flocks/elfeed-notifier"))

Nothing happens, no function or variables are available.

Does anyone know what's the standard procedure for loading such packages? I assume that it has something to do with use-package?

https://redd.it/16vjyy5
@r_emacs

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

/r/emacs

Is anyone using elfeed? I'm trying to add a hook to send desktop notification when articles become available.

I was wondering if anyone is familiar enough with elfeed's codebase to advise where would be any good place to hook when new articles become available to send a desktop notification with a truncated title of the articles?

Also I've noticed that emacs users... kind of don't use notifications (org-agenda, elfeed)? Do you all guys just have photographic memory, see the future, read minds to not need to keep up with any schedule?

https://preview.redd.it/fh8h3p7xd9rb1.png?width=996&amp;format=png&amp;auto=webp&amp;s=95bb6544a926a7e4bba2c205db2b241be3706133

https://redd.it/16vn6aa
@r_emacs

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

/r/emacs

flymake mode to codespell
https://github.com/chmouel/flymake-codespell

https://redd.it/16vlkbq
@r_emacs

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

/r/emacs

Linking Latex installation to emacs

I'm using emacs to edit my latex documents. I have the auctex emacs package installed, as well as latex-preview-pane.

I would like to use the siunitx latex package.

I installed the package doing:
sudo apt -y install texlive-science

When I compile my document using directly latex:
pdflatex mydoc.tex
it works, but when I'm within emacs, the latex-preview-pane package cannot compile my document.

I guess I have to tell emacs and auctex where to find the packages I installed when I installed texlive-science.


How can I solve this ?

PS : I know that the error in latex-preview-pane comes from the \usepackage[siunitx], because if I comment this line, it works perfectly.

https://redd.it/14g5urb
@r_emacs

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

/r/emacs

Difficulties with hooks: how to use 2 modes with certain files extensions

I am reading about hooks, about modes and how to assign a mode to a file according to its extension.

My question: is it possible to assign 2 modes to a file depending on it extention?
I want for all log files (.log or .err) to apply the log4j mode for the better display and also the mode that reproduces the behaviour of

 -f

To apply each mode (log4j-mode or uses a hook...

I am pretty certain that it is not possible as is... how to make it possible?

Thanks for your advises

https://redd.it/14fl0fp
@r_emacs

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

/r/emacs

A diff based approach to saving files

I was saving files by C-x C-s save-buffer command. I do some changes to files and some time after I have done a complete change, I spam a C-x C-s.

But sometimes I can change unrelated parts of a buffer unconciously. Sometimes I delete some part of a buffer, sometimes I copy a huge part of another buffer into this buffer and have a very long extra parts that are hidden under an org heading.

So the problem is I sometimes change the file in some unwanted way. Most of the time those goes unnoticed and long time I see some inconsistencies with the file itself and how the it should be. I see that the file does not have integrity. This is a bad experience mostly. So I wanted to be able track contents of every save operation I make to the files.

I also don't use auto-save-visited-mode which saves buffers automatically. That may result in also me making unconcious changes to a file and then it goes unnoticed.

So I began to look into diff modes. I saw the diff-buffer-with-file command, which indeed turned out to be useful.

&#x200B;

&#x200B;

&#x200B;

&#x200B;

I think that it is a good practice to diff buffers before saving. So I don't use C-x C-s but now I do this:

&#x200B;

C-x C-SPC first to view the diff then use

`SPC' and `S-SPC' keys in diff buffer to

scroll through the diff buffer.

&#x200B;

After viewing the diff I use `C-SPC' key in diff buffer to save

the main buffer and quit diff window or use `c' or `x' keys

to just quit diff window without saving the main file.

&#x200B;

This way I have a more secure and concious way to save files

knowing what am i writing into the file.

&#x200B;

;; we use diff-mode-map and diff-buffer-with-file below, so this is needed
(require 'diff-mode)

;; use this key to diff current buffer with its file
;; beware that going to the diff window by using
;; other-window command is a bit of a hack, replace it
;; if you have a more resilient and certain way.
(define-key global-map
(kbd "C-x C-SPC")
(lambda nil "Diff current buffer with its file and go to its diff window"
(interactive) (diff-buffer-with-file) (other-window 1)))


(define-key diff-mode-map
(kbd "C-SPC")
(lambda ()
"Quit the diff window and save the main buffer."
(interactive)
(quit-window)
(save-buffer)
))

;; q already quits the diff window, but because x and c are
;; near the SPC key, we prefer those keys to quit the diff window
(define-key diff-mode-map (kbd "x") 'quit-window)
(define-key diff-mode-map (kbd "c") 'quit-window)



I hope this helps

https://redd.it/14fnufv
@r_emacs

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

/r/emacs

maccalfw: A calfw interface for MacOS's Calendar app

&#x200B;

maccalfw

This is a project born by personal need and mostly for personal use and very much still work in progress, so use at your own discretion. I am still testing it as I had to customize large parts of calfw and calfw-blocks to my liking (working on the interface for modifying and adding events now).

Bug reports and possible improvements are welcome.

&#x200B;

A bit of background: I was trying to find ways to view and modify my calendars from within Emacs which lead me down the rabbit hole of figuring out calendar clients for my Google Calendar, my Apple calendar and my work Office365 calendar. Clients for Office365 are particularly annoying with the new Oauth2 system; an app has to be trusted by Microsoft which pretty much means that all open source clients are unusable unless one has admin control over the Azure environment.

After some pointless struggle, I decided to just rely on my local MacOS calendar app to handle all the authentication and to sync my calendars. I wrote a simple interface in Swift which can be imported in Emacs and then used to feed events into calfw.

https://redd.it/14fh2tc
@r_emacs

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

/r/emacs

use-package support :vc to install package from version control

I am pretty sure i read about use-package now supporting :vc for installing packages from version control. However I cant find anything about it now. Does anybody know about this feature? I checked the github page and my local package is labeled "20230426.2324". Its installed from melpa (i guess).

https://redd.it/14f4jv1
@r_emacs

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

/r/emacs

Weekly Tips, Tricks, &c. Thread

This is a thread for smaller, miscellaneous items that might not warrant a full post on their own.

See this search for previous "Weekly Tips, Tricks, &c." Threads.

Don't feel constrained in regards to what you post, just keep your post vaguely, generally on the topic of emacs.

https://redd.it/14f1klb
@r_emacs

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

/r/emacs

Should I start with vanilla Emacs?

I want to get into Emacs in order for it to be my PKMS, and a environment for writing blogs, articles, and books. Should I start with vanilla GNU Emacs, or should I go with some distribution?

https://redd.it/14ezcvy
@r_emacs

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

/r/emacs

Emacs on windows

I was wanting to use Emacs on windows but even installing through .msi it is not available in the cli of cmd, does anyone know how to solve this?

https://redd.it/14e9ph7
@r_emacs

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

/r/emacs

Can org-mode not autoload with in use-package?

I just noticed that my org-mode, which is configurated with use-package, has to be loaded every time. I want org mode start load (and the modes hooked with it) when I open .org file.

How can I make it happen? Here is my configuration, do I miss something?

(use-package org 

:bind
(:map org-mode-map
("C-c l" . org-store-link)
("C-c a" . org-agenda)
("C-c c" . org-capture)
)

:config
(message "hello org") ;; this for checking if the org mode loaded.
)


Thanks.

PS:

emacs version:
GNU Emacs 30.0.50 (build 1, aarch64-apple-darwin22.5.0, NS appkit-2299.60 Version 13.4 (Build 22F66))

org-mode version:
Org mode version 9.7-pre (release_9.6.6-418-g294a4d @ ~/.emacs.d/straight/build/org/)

https://redd.it/14eou7i
@r_emacs

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