lainchan / λ

(untitled)

The Phantom Phreak · 2018-03-13 08:46
Hi, lainons. Emacs Lisp thread. I recently started a journey into the obscure world of Emacs. I tried to switch from Vim to Emacs twice in the last years, but I gave up twice. I tried again a month ago and I'm still using Emacs daily. The reason is Emacs Lisp. Last year (motivated by lainchan) I started learning Common Lisp and liked it a lot. Then I found I can do whatever I want to do in Emacs Lisp. I've already written lots of functions. Maybe I can develop a new killer major mode, who knows. Please share your experiences and thoughts about Elisp in this thread. Can/should I use it as an application framework for something not related to text editing?
Lukasiewicz · 2018-03-13 14:27
>>7270 I did the same, from vim to Emacs and tried to learn elisp. At the end of my journey I concluded that vim is far better and Common Lisp too. Emacs is just unnecessary.
Tyrell Wellick · 2018-03-13 15:02
If you're looking for something to write, how about an interface to post on Lainchan from Emacs? You currently can't do that with EWW or w3m. You can most definitely use Emacs as an "application framework", look at magit. My experience with Elisp is that it's a fun language to use with Emacs. Everything being Lisp helps in that it's never too difficult to learn how something works and to change it.
Hououin Kyouma · 2018-03-13 15:12
>>7273 Vanilla vim is better than vanilla emacs, but if you need something Vim doesn't give you by default, it'll be a pain in the ass to do it in Vim script.
queue · 2018-03-13 15:17
>>7273 Also, coding in Common Lisp without slime isn't a good idea.
Tomohisa "Tom" Kanezaki · 2018-03-13 18:35
>>7273 I have a problem that I don't know should I use vim or emacs. Now I'm constantly switching between them. I like vim because it's just an editor and feels very fast but I also like configuring emacs with elisp and emacs feels very good for programming.
Tyrell Wellick · 2018-03-13 18:46
>>7270 In my opinion the reason to use emacs is precisely because you can use it as an application framework with everything written in the same language and tightly integrated. There's no point in using it as a simple text editor, (neo)vim is way better at that. I wish I had learned Emacs instead of Vim when I started programming. I'm pretty jealous of all the features it has and have increasingly been dreaming of switching to it because of this https://technomancy.us/184 .
progn · 2018-03-13 20:56
>>7275 I agree with you, but the vim package manager is cool enough >>7278 I love the modal mode for programming Emacs feels bloat to me
Rick Deckard · 2018-03-13 21:11
>>7278 >I like vim because it's just an editor and feels very fast What about vim makes it feel fast compared to emacs? Are you talking about it's modal editing? There's Evil mode for that https://www.youtube.com/watch?v=Uz_0i27wYbg >>7281 >Emacs feels bloat to me In what way? Emacs provides many useful functions for you when you're writing Elisp. If you're not writing Elisp, then it'll seem like bloat to you since you're not taking full advantage of a lisp environment.
nibble · 2018-03-13 21:54
>>7282 Maybe it's because I don't need/like having everything packed together. I prefer a tmux session with vim than an Emacs one. Maybe it's my resilience to prefer using vanilla software that block my ascension to Emacs: I just don't like the mentality of having to extend something heavily to make it usable. NB. Elisp is cool, but is an inferior lisp dialect...
Just another Random Lainon · 2018-03-13 22:24
>>7282 >>Emacs feels bloat to me >In what way? $ du -hs * 217M emacs-25.3 52M vim-8.0.1298 $ find emacs-25.3/ -regex ".+\.[ch]" | xargs wc -l | tail -1 429937 total $ find vim-8.0.1298/ -regex ".+\.[ch]" | xargs wc -l | tail -1 447298 total $ find emacs-25.3/ -regex ".+\.el" | xargs wc -l | tail -1 1657763 total $ find vim-8.0.1298/ -regex ".+\.vim" | xargs wc -l | tail -1 255501 total On the other hand, "bloat" implies wasteful and Emacs does seem to do an awful lot more than Vim. From what I understand the power of Emacs comes from those 1.6m lines of Lisp code. Would it take more than 1.5m lines of C and vimscript to bridge the functionality gap? Probably. I'm like >>7283 though, Vim + tmux is simple and good enough for me.
mod · 2018-03-13 23:06
>>7282 a copy/paste from another lainchan thread >Among other things, Emacs contains: >- An original dialect of Lisp >- A HTML renderer >- An ANSI-conforming terminal emulator >- Two parser generators >- An implementation of Unix man for when Unix's man is unavailable, called "woman" for "without man" >- A Plan 9-like shell, including a few basic unix utilities and a portable implementation of piping >- A sort of document markup language for note keeping and time management, which has been used to write books >- An input mode that converts TeX symbol identifiers to the corresponding Unicode as you type, with real-time preview and suggestions >- Multiple(!) IRC clients >- A somewhat clever text adventure game >- A psychotherapist >- Tetris >At least one person reading this is going to think I'm making some of these up, or exaggerating them by not mentioning that they're third-party extensions or that they let external processes do the heavy lifting. I'm not.
typedef · 2018-03-13 23:23
>>7285 Besides the jokes (tetris, therapist, adventure game), all of that is incredibly useful to have. I suppose this is a difference between those who choose vim, and those who choose emacs: I see functionality and tools, a system, you see bloat.
Yamaoto Toshi · 2018-03-14 02:08
>>7285 Don't forget about the image and PDF viewers!
Colmerauer · 2018-03-14 10:27
>>7281 > vim package manager is cool enough It's cool, but you will be dependent on other programmers who can endure learning and programming such painful language as Vimscript. Elisp, in the other hand, is a pleasant language, and Emacs is extensible and well documented as hell. I can do anything I fuarrrk want without having to wait for another programmer do it for me and put in a package manager. And if you like Vim's composability and dual/mode or something else, you can always use evil, viper or Spacemacs.
Linda Lee · 2018-03-14 10:38
>>7293 I understand, and like OP I hopped between the two a lot of time, but never had the feeling that Emacs was worth it: it has too many command, to many things to learn that I prefer vanilla vim + tmux, with packages I choose and bash scripts if needed. This way feels like a DIY approach, I can build my workflow starting from a minimal setup, Emacs is so vast that intimidate me.
⍕ · 2018-03-17 22:00
I was a heavy vim user and dabbled with emacs now and then, but when I finished education and I started working, they gave me a computer with a really bad operating system, and emacs provided me with a better way to interact with my computer. I have been using it for a while now, I feel proficient with it, but I need more from it. The problem I have is, I would like to automate some thingies, but, while I know lots of keybindings, I dont know the actual name of the commands. What are your favourite resources for learning emacs lisp? How did you guys moved form basic users to extending your own editors?
Batou · 2018-03-17 22:38
>>7360 Sounds like you need some "C-h k" in your life. This along with C-h v and C-h f are how I discover emacs. As slow as it is, https://www.gnu.org/software/emacs/manual/eintr.html is a great resource for learning how to program with buffers in mind. You can easily read it one or two days.
Church · 2018-03-18 09:40
I wish emacs ran better on Windows
Hailvim · 2018-03-18 12:03
>>7367 Maybe this may help you? You probably already knew of it existence, but just in case someone else has the same issues. https://github.com/zklhp/emacs-w64
Ishikura "Tatsu" Tatsuhiko · 2018-03-18 12:12
>>7361 These works on terminal?
bit · 2018-03-18 12:26
>>7367 its still a better OS than windows tho.
Ishikura "Tatsu" Tatsuhiko · 2018-03-18 14:55
>>7285 what about the window manager? Emacs has those too. You can in fact boot up the naked Linux kernel + X-server and use emacs for everything else.
Mentat · 2018-03-18 17:06
>>7370 I don't see why these commands wouldn't work in a terminal, at least gnome-terminal functioned as expected.
BloodCat · 2018-03-22 00:59
How can I find the longest line in a buffer?
Terzibashjian · 2018-03-22 07:53
>>7410 (defun greatest-str (x y) (if (> (length x) (length y)) x y)) (defun greatest-line-buffer (buffer) (with-current-buffer buffer (reduce #'greatest-str (split-string (buffer-string) "\n"))))
Hagbard Celine · 2018-03-23 00:22
>see mention of Emacs on IRC >have a look >install >change face colors to greatest theme in existence (lainchan.org, poison) >change font to Terminal >mfw I casually realized I'm a hacker now XD I've been leaning C++ in my spare time using Sublime Text, MinGW, and Windows PowerShell. Running these same processes in a single environment is pretty nice, especially one as visually simplified as Emacs -- I'd rather stay away from a modern IDE for as long as I can. The whole application seems so robust and rewarding to use that I almost want to dive into this Elisp in order further customize and gain familiarity with Emacs. But I think it's best I stick to one language for now, unfortunately. Just the Emacs' Tutorial and Help files have already stolen hours of C++ study time. I'm not complaining, perusing these documents is terribly relaxing. Once I learn how to run IRC, and have it, my system shell and a source file all open in separate frames and press F11, then I imagine my comfort levels will be through the roof. Thank you, Lainons, I'm very happy with this program.
Nguoi La · 2018-04-03 17:30
Is there a function like replace-string, but which exchange strings? For instance (command "foo" "bar") applied on the buffer "foo bar foo" would give "bar foo bar".
stack · 2018-04-04 06:32
>>7681 In python since I had my terminal opened: >>>str="foo bar foo" >>>str.replace("foo", "temp").replace("bar", "foo").replace("temp", "bar") 'bar foo bar'
x<->y · 2018-04-04 08:14
>>7683 Of course temp shouldn't appear on the original string. A fail proof algorithm would generate a random string with 0 occurrences inside the original string before applying the replaces.
Hacker · 2018-04-08 16:08
http://irreal.org/blog/?p=1661
hash table · 2018-04-09 09:12
>>7766 So I copypasted this in *scratch*: Jill and Jack went up the hill to fetch a pail of water. Jill fell down and broke his crown and Jack came tumbling after. Then I did M-x replace-regexp \|Jack \,(if \1 "Jack" "Jill") And I got JillJJilliJilllJilllJill JillaJillnJilldJill JillJJillaJillcJillkJill JillwJilleJillnJilltJill JilluJillpJill JilltJillhJilleJill JillhJilliJilllJilllJill JilltJilloJill JillfJilleJilltJillcJillhJill JillaJill JillpJillaJilliJilllJill JilloJillfJill JillwJillaJilltJilleJillrJill.Jill JillJJilliJilllJilllJill JillfJilleJilllJilllJill JilldJilloJillwJillnJill JillaJillnJilldJill JillbJillrJilloJillkJilleJill JillhJilliJillsJill JillcJillrJilloJillwJillnJill JillaJillnJilldJill JillJJillaJillcJillkJill JillcJillaJillmJilleJill JilltJilluJillmJillbJilllJilliJillnJillgJill JillaJillfJilltJilleJillrJill.
Neo · 2018-04-09 18:02
>>7770 So this is the true power of elisp
byte · 2018-04-10 08:19
This is a bit more emacs than emacs lisp, but I will shamelessly ask anyways. Much to my displeasure, I have to use a windblows computer at work, and I have figured that I cal alleviate much of the pain using emacs. My problem is: emacs comes by default with gnutls28, rather than the required gnutls30 and I do not have admin access to this computer- Thus I cannot implement this workarround: https://emacs.stackexchange.com/questions/27202/how-do-i-install-gnutls-for-emacs-25-1-on-windows Is there a way so I can point emacs to the gnutls .dll's outside of emacs' installation /bin folder? I went arround looking at the gnutls.el sourcecode, but I could not find anything "path-like" to the dll's nor the gnutls-cli program (which I see my emacs packages unsuccessfully call), but much of it is written in common lisp, which is beyond my comprehension.
Trinity · 2018-04-10 08:58
>>7438 Just have in mind that Emacs comes with the intro to emacs lisp out of the box (M-x info, and navigate to emacs lisp intro). You can manage to get tidbits of emacs lisp from reading the source code of the packages you are using, reading snippets of that book, and copying customizations for your init.el. Its not like learning C for school or work, where you need a thorough understanding of the language. You can get away with knowing a bit, customizing some functions and hacking your config files little by litte as you learn and looking up just the necessary stuff you need to acomplish your task. At least that is what I am doing, and I am learning a lot, and making my workflow more efficient.
over · 2018-04-10 15:39
>>7770 It's M-x replace-regex \(Jill\)\|Jack \,(if \1 "Jack" "Jill")
Pulse · 2018-06-23 10:38
How do I do a macro that remove the first n characters of each line of some selected text?
Dox · 2018-06-24 14:12
>>9115 You should think how would you mechanically do this with your keyboard, then use the equivalent commands in a script. You know, even pressing a key have an equivalent function. I can do it for you, not now, but it's worth giving it a try.
Y.T · 2018-06-30 03:24
I made a pretty cool org-mode file generator that takes my firefox tabs and saves them in a categorized file: https://github.com/kennymalac/wikify I'll be livestreaming me working on an extension to this project in Common lisp at 10am PST June 30th. https://www.twitch.tv/events/Yh7I84GuTSKRNZ6oKg1g3Q or https://www.youtube.com/watch?v=CbfHpLUPL7E
stack · 2018-07-01 12:16
>>9124 you should not do it for him. that is not helpful. >>9115 we are here to help you, not write your code, because writing your code will not help you. on the top of my head: can you write a function that deletes a the first n characters of a line? can you write a function that uses the above to iteratively (/ recursively) walks selected lines and applies the above? I believe that chapter 8 of "an introduction to programming in emacs lisp" will be most helpful for your task. if you do not want to do any programming, then just press f3, that will start recording a macro. delete n chars from the line, and move to the next line. press f4, that will stop macro recording. now you just need to press f4 as many times as you want.
Backus · 2018-07-21 20:56
>>9244 Eh, nothing personal streamer kid. strings ~/'.config/chromium/Default/Current Session' | 'grep' -E '^https?://' | awk '{print("*"$0); }'
HELIOS · 2018-07-21 23:05
>>9548 Not him, but is awk still being used? I have a few books about it and wanted to learn, but I wasn't sure if it was worth the effort.
Boole · 2018-07-21 23:29
>>9550 awk, like all good unix utilities, will be around longer than you.
string · 2018-07-22 18:39
>>9550 Awk does one job and do it well. I spent a few hours learning it and used it countless times.
Aristóteles Amadópulus · 2018-07-22 19:37
>>9551 >>9568 Cool, I think I'll take a look at it then.
Anonymous · 2018-08-01 03:03
>>7274 since lainchan doesn't have a captcha it would be a lot easier than other comparable boards I'll look into making one
Kay · 2018-08-01 03:11
>>7372 I use this (exwm). The only issue that ever comes up is that if emacs is stalled because of some computation or something, it stalls all input. In practice this doesn't happen that often. And being able to use simulation keys makes text editing in firefox a lot less painless.
Chani · 2018-08-03 18:28
>>9550 awk is an amazing tool if you learn how to use it and as long as we're having text files it is irreplaceable
bit · 2018-08-12 22:42
I love the concept of writing editor plugins in lisp but Emacs' default keybinding is so confusing for me. Vim's keywords and keybinds are mostly abbreviations so I could pick them up with relative easiness but emacs' seemingly random control combinations are not sticking with me. I know there exist evil-mode or even space emacs but I would rather learn the way of emacs and not patch dozens of major modes by myself just to make them work. Could any lainon teach me how should I start learning emacs as 'mouse free' daily editor?
Anamika · 2018-08-13 05:40
>>10049 > but Emacs' default keybinding is so confusing for me Muscle memory, dude. It's confusing because you are not used to it. Vim is confuse as hell when someone is learning it.
Pris · 2018-08-13 06:23
>>10050 >Muscle memory, dude. Indeed. I realized I was learning the keybindings when I started to look for them outside of emacs. It actually becomes kind of annoying to edit text outside emacs.
Arisu Mizuki · 2018-08-27 00:06
>>7278 I just use both Vím for quick/remote edits, emacs for actually working on something
Armitage · 2018-08-27 23:40
>>7276 no slime == better function name retention
Donna Hawthorne · 2018-08-29 00:59
>>10049 >and not patch dozens of major modes by myself just to make them work You can use the evil-collection package to get evil keybinds for most modes.
DEBUG-CONTENTS · 2018-08-30 07:26
Any interesting workflows you guys have ? I use interleave mode which let's me take notes in org mode for PDFs I am reading. I also have a halfway gtd going with org mode. I intend to work towards managing my references better as the organization of thr stuff I am supposed to be reading is currently a mess, maybe with bibtex, I am not sure yet.
lain · 2018-09-25 20:57
what's the word on using starter kits and which ones do you lains recommend?
Just another Random Lainon · 2018-09-27 19:14
>>10236 That's a cool idea. I tried some programming with org-babel but it got slow after a bit, it's probably better suited for scripting languages than the c++ I was using it for but it did work
Terzibashjian · 2018-10-01 18:44
>>10542 Don't use starter kits. First, for a ton of features you will never use they have insane load times, you won't learn ELISP from them due to the lack of any meaningful configuration, they often contain very deep-set self-coded modules which could be replaced by much better, far more modular, replacements widely available, etc. Start with vanilla Emacs and just port around your init.el, it's way better than screwing with random Emacs kits
Zero Cool · 2018-10-01 21:32
>>10542 The most common packages that all starter kits will have is ido, smex, projectile and magit. Ignore this FUD spewer: >>10641 who will always post in every emacs saying add-ons to emacs is bloat. Emacs is a slow editor, it always has been. Nothing wrong with getting familiar with vanilla emacs but dont deprive yourself of all the modern search features that most modern editors have now.
Dujour · 2018-10-02 01:20
>>10648 Brah, Emacs isn't slow unless it's packed to the brim with crap like all starter packs are Just configure Emacs as you go along and it'll be perfectly suited to your needs I use MELPA a ton, extending Emacs with packages is fantastic and eliminates any need for the starter packs
x<->y · 2018-10-02 04:23
>>10542 If you google "emacs starter kits" there is a short list that everyone agrees is the best, Spacemacs always being at the top of the list.
Agent Smith · 2018-10-03 14:49
I use nano for standard text editing/quickly going through a file. Emacs for programming because the syntax highlighting is pretty good and the macros are delicious. sometimes vim seems to me like an overcomplicated nano and I can't really bring myself to use it.
Tequila · 2018-10-03 14:51
>>10698 oh and I use gas as my assembler. sue me
H.R. Giger · 2018-11-07 16:17
Right now I'm working through SICP and use scheme code blocks inside an org file. I'd love to be able to use C-c C-c with the cursor inside a code block to compile/interpret it and print out the result below. But I don't know how. When I tried it my minibuffer screams at me "No org-babel-execute function for scheme!"
Batou · 2018-11-07 20:41
>>10542 >>10641 >>10648 >>10654 I've been configuring Emacs from scratch using MELPA for the better part of a year and really like it so far. You learn a lot reading each package's documentation and fiddling around with its ELisp. My only (minor) regret about taking this route is that I learned Emacs keys instead of Vim ones with Evil because there's a Vim-keys version of everything. Luckily, Stumpwm allowed me to set Emacs keys for Firefox using the "define-remapped-keys" function. The only package I need is Counsel (which comes with Ivy and Swiper - is that cheating?). Other stuff is nice, but Counsel/Ivy makes a world of difference. It even makes learning Emacs easier because you see the names of functions in the lookup menu and start reading the docstrings. >>11261 Have you tried Geiser? It's a Scheme REPL a la SLIME.
Miho Iwakura · 2018-11-07 23:29
>>11261 >I'd love to be able to use C-c C-c with the cursor inside a code block to compile/interpret it and print out the result below. But I don't know how. put the cursor after the closing paren of the expression you want to evaluate and then C-x C-e
Moore · 2018-11-13 18:45
>>11261 Well you can, but you need to get geiser, set a default scheme for geiser and then add scheme to org-babel-languages. >>11265 This way you evaluate scheme code through an elisp repl which may or may not work, or may work with unexpected results.
Nobody special · 2018-11-14 03:00
>>10542 I'm a big fan of castlemacs. It's mostly vanilla emacs with a few convenience plugins and some saner keybindings.
Ender · 2018-11-28 14:10
>>9550 If you were standing before me I'd beat your little ass for insulting awk in such horrible way.
Pris · 2018-11-29 03:42
>>11352 Let's talk about geiser for a little Does it feel lacking to you, compared to something like Cider? I'm referring mainly to the debugging department. Cider's debugger is excellent. You think it can be related to the implementation I'm working with? I'm using Chez on my machine. Was all debugging born equal in Geiser?
Hagbard Celine · 2018-11-29 20:46
>>11579 I've felt this as well, Geiser is a bit less polished than say Slime or Cider. Personaly I use mainly racket so I debug using DrRacket.
William Holtzer · 2018-11-30 11:38
>>11590 Well, the whole fun in using emacs is that I can use it for everything and that I don't have to get used to other programs. I'm wondering how much effort it would be to port the cider debugger to geiser
Lain Iwakura · 2018-12-12 07:36
Am I crippling myself by using spacemacs with vim-mode? I'm far too used to using vim as an editor yet don't want to be missing out on what emacs has to offer.
sizeof · 2018-12-12 11:16
>>11760 I am going to say no, but take my opinion with a pinch of salt, as I have never used spacemacs nor vim mode. The power of emacs resides in that you can customize it to your liking and extend it to your needs using emacs lisp. If you are more confortable using vim bindings, all power to you.
Sabo Engle · 2018-12-15 20:52
>>11760 Only in terms of startup time and latency, maybe some good vim plugins like syntastic. Other than that, I would agree with >>11765
nibble · 2018-12-19 07:02
>>11760 Starting to use emacs, made me realize that the only commands that I really miss in non vim editors are: "o", "O" and "dd". So, I made three keybindings in my .emacs and now I use vanilla. Find your way, or carve out one yourself, that's the emacs way to me, use what's best for you.
Cypher · 2018-12-22 21:20
I'm thinking of a new mode line, but I'm not sold on the Spacemacs ones. What are some of the less-seen customizations? Material on this seems hard to find. I'm looking for something a bit retro, not flat. >>11760 You can use the default Emacs with Evil (the Vim emulation layer) and install the other packages you want. There's also Doom-Emacs, a lighter Vim emulation starter pack. The author has put a lot of work into speeding up the startup. https://github.com/hlissner/doom-emacs
The Fin · 2019-01-06 11:59
>>11867 as someone that made their own mode-line i highly recommend you start by trying to make your own mode-line that just displays the buffer name. once you learn how to do that, start looking at packages of existing mode-lines
Turing · 2019-01-20 04:12
>>7275 >>7293 >vim script Doesn't neovim's remote plugins fix this problem?
McCarthy · 2019-01-21 11:47
>>7279 Yes, but really? I dont think OP is talking about emacs, but emacs lisp, which is one of the main misconceptions of this thread IMHO, not that I really care. Is any of you using ELisp for anything else other than text editing? Text editing broadly speaking. I mean, I think it is a great tool for text editing, but I have my doubts it is good for anything else. I know its capable, cause there is snake and whatnot inside emacs, but is is good? What have you guys done in ELisp outside text editing? Where you happy you used ELisp, or would you have been happier with another lisp? ELisp is my least favorite Lisp, given that I am only proficiente with Clojure and ELisp. I have written some small scripts in ELisp to automate my workflow, I think its great for that and I have found quite a bit of joy using it. But I still have the hunch that it might be one of the worst lisp out there (and just so fanboys dont kill me, I like ELisp better than Python).
Hitomi · 2019-01-21 13:14
>>12209 Yeah it does. You can even write your plugins in ELisp now ;)
Hacker · 2019-02-04 15:55
I am working on a terminal emacs via putty. I have installed paredit. but the key bindings are not working. I have checked with my init e-lisp scripts in my local gui version of emacs, and there seems to be nothing different. I have noticed that there is an emacs-mode-keybindings variable of some sort. can i set all those keybindings somehow? i can call the paredit functions via M-x with no problem i have gone to the paredit.el and executed the paredit-define-keys function, but keybindings are still not available
Kay · 2019-02-04 16:15
>>7438 >change face colors to greatest theme in existence (lainchan.org, poison) source?
Crash Override · 2019-02-04 17:53
>>12231 On one hand Emacs Lisp is not that great by any means. It's an almost historical Lisp, without many of the features of more recent times. For example the lack of packages of any sort, dynamic binding and stuff like that. Every time I try to write something for emacs, I'm like thanks god for cl.el and s.el and stuff like that. Which brings us to the main advantage of Emacs Lisp. Through the times, both in core and in several external libraries, there has been amassed a great plethora of libraries and utilities so that developing for emacs has become really easy. The whole ecosystem is quite easy to grasp and naturally extends from editing to extending and programming emacs. That is the real power of Emacs Lisp. Outside of emacs there is no reason to choose it in favor of Clojure or even Common Lisp. Does this make it the worse lisp? It's use is narrow but I wouldn't say this, given that it's probably the most used lisp out there.
Davis · 2019-02-05 12:19
>>12423 Thanks for the reply, it was very insightfull, and I have never thought that Emacs Lisp was probably the most used lisp. While I have written a fair share of Emacs Lisp, I still consider me a novice. I read through the Emacs Lisp Intro in the info. So it does not cover a lot of libraries and the like. What other libraries are you using other than s and cl? Also, I am familiar with Clojure and not CL. I have been digging arround, and saw that the dash.el was a nice interface closer to Clojure Now, do you prefer cl.el over dash.el for list manipulation for some reason? I am assuming that cl.el has more functionality than list manipulation, but dash.el seems to only cover that region.
Tequila · 2019-02-05 16:53
>>12427 Well cl.el is not that useful if you're not familiar with Common Lisp. It offers things like loop and aliases many Emacs Lisp functions and macros to ones more similar to Common Lisp. I haven't really used dash so I don't really know what it offers, but from a quick look it offers clojure-y things so they might work well if you got experience in clojure. I don't think though that I've ever needed more complex list manipulation than that offered in Emacs Lisp. In general the thing with Emacs Lisp is that, imho, you don't need to treat it like a traditional language. You don't need to study some book. Just do your everyday things and if something is interesting study it with C-h f , C-h k or C-h v and then find its source with M-. and stuff and since you've already got most popular libraries loaded from other packages you can see if they seem useful to you. I'm no expert in Emacs Lisp either, but on the other hand it is my most successful language, meaning that almost whatever I put my mind to do I can easily do it. The barrier for seeing results and being useful is pretty low.
Zhora · 2019-02-06 11:21
>>12428 Well, yesterday, before I read you post, I had to add decorators to all functions in a medium size python project. Maybe there is a better way to do it, but i read all the files in the buffer, and used seq to split the results into files and folders, decorated files, recursed over folders. seq felt fairly rudimentary, and knowing of dash before doing that, would have made my life a lot easier. I think the book is great, it gives you a flavor of the standard library and idioms in elisp. but I agree with you, there is nothing i have not been able to do in elisp. but i also produce the hackiest, ugliest code i have ever written. I think if i were to have better knowledge of the libraries out there, it would be much improved. not that it matters a lot, since i am the sole consumer of my elisp code.
Joe Bloggs · 2019-02-08 01:07
>>7270 used vim for a while. loved it. Switched to spacemacs. Love it even more. Will write a more personal config with experience. On a related note, anyone recommend DOOMemacs over spacemacs?
Colmerauer · 2019-04-03 01:49
Hello, I'm having a bit of a issue writing a w3m-emacs filter for duckduckgo. Basically what I have is a bunch of links this: href="/l/?kh=-1&amp;uddg=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FTest" Which I'd like to change these to be directly usable by my browser like this: href="https://en.wikipedia.org/wiki/Test" Each individual part of the function I wrote to solve this problem seem to work on their own but when combined together they break, clobbering the DOCTYPE header instead of doing anything useful. Specifically everything seems to work perfectly until either url-unhex-string or w3m-decode-url-string are added, both of which result in the error. Making a function using regex to decode the URLs has the same effect. Any help would be greatly appreciated. lisp (defun w3m-filter-duckduckgo () "Removes the link indirection from duckduckgo results." (interactive) (when (re-search-forward "/l/\\?kh=-1&uddg=\\([^\"]*\\)" nil t) (replace-match (url-unhex-string (match-string 1)))))
Nameless · 2019-04-03 17:17
>>13090 (you) The issue seemed to be that the various functions to decode the url use regex, and because of this made replace-match do unexpected things. Here is a functioning version of the filter in the proper format for w3m-emacs: lisp (defun w3m-filter-ddg (url) "Remove the link indirection from ddg results." (while (re-search-forward "/l/\\?kh=-1&uddg=\\([^\"]+\\)" nil t) (let ((start (match-beginning 0)) (end (match-end 1)) (new (url-unhex-string (match-string 1)))) (delete-region start end) (insert new))))
The Oracle · 2019-04-03 17:43
>>13099 Sorry for the spam but one last thing is needed to make it run as a w3m filter. I was testing in a text buffer and so I didn't realize this. (goto-char (point-min)) needs to be added before the loop so that the cursor is at the top of the buffer before running.
Agent Richard Gill · 2019-04-07 13:42
Here's a filter to make the images work on this site, for whatever reason w3m.el dislikes unicode image names, and luckily there is a alternative. lisp (defun w3m-filter-lain (url) "Make images renderable on lainchan" (goto-char (point-min)) (if (string-match "\\(%CE%BB\\|lambda\\|%CE%A9\\|tech\\|%CE%94\\|diy\\)" url) (pcase (match-string 0 url) ((or "%CE%BB" "lambda") (while (search-forward "\u03BB/thumb/" nil t) (replace-match "lambda/thumb/"))) ((or "%CE%A9" "tech") (while (search-forward "\u03A9/thumb/" nil t) (replace-match "tech/thumb/"))) ((or "%CE%94" "diy") (while (search-forward "\u0394/thumb/" nil t) (replace-match "diy/thumb/"))))))
Hong, Guil Dong · 2019-04-07 13:54
>>13162 ugh, the if is unnecessary but you get the idea.
Joe Bloggs · 2019-04-17 09:13
>>7361 Those commands is super useful now that I mimic Spacemacs leader feature with evil-leader and which-key-mode. Those like me who find the default keybindings terrible should give that a try
Liet Kynes · 2019-04-17 09:24
>>13254 are*
() · 2019-04-17 14:22
>>13162 Here's a improved version of my lainchan filter. It removes the unnecessary if and string compares, it also uses cond instead of pcase which is a C function with a dedicated opcode. lisp (defun w3m-filter-lain (url) "Make images renderable on lainchan." (goto-char (point-min)) (cond ((not (string-match "\\(%CE%BB\\|lambda\\)\\|\\(%CE%A9\\|tech\\)\\|\\(%CE%94\\|diy\\)" url))) ((match-string 1 url) (while (search-forward "\u03BB/thumb/" nil t) (replace-match "lambda/thumb/"))) ((match-string 2 url) (while (search-forward "\u03A9/thumb/" nil t) (replace-match "tech/thumb/"))) ((match-string 3 url) (while (search-forward "\u0394/thumb/" nil t) (replace-match "diy/thumb/")))))
sizeof · 2019-04-18 04:02
>>7284 >>7285 >>7281 >Emacs feels bloat to me I agree completely, I've used emacs for 4ish years after coming from about 2ish years of vim. I don't think I could go back because I'd miss magit, org, org-ref, and helm. Ideally I'd like a minimal version of emacs that is basically just a elisp interpreter then you pick and choose what other stuff you want. I don't need several irc clients, email clients, man page viewers, and 4 shells. Just let me pick the one I like and not have to carry around the bloat of the rest. Packages and elisp make it worth the bloat for me tho, maybe someday if I have time I'll see how hard it would be to decouple some of the pieces then I'll have my perfect editor.
Hououin Kyouma · 2019-04-18 04:20
>>10236 If you want to use bibtex with org mode I highly recommend org-ref it is fuarrrking amazing https://www.youtube.com/watch?v=2t925KRBbFc
Morpheus · 2019-04-18 15:01
>>13263 >Ideally I'd like a minimal version of emacs that is basically just a elisp >interpreter then you pick and choose what other stuff you want. I seem to remember a way to do this by editing a configuration file before compiling emacs. You might also be interested in modalka which is a packages which takes this philosophy in making emacs a modal editor, although I'm not sure how possible it is to implement a language as powerful as ex's in it.
bit · 2019-04-18 20:34
>>13270 You could probably go through the ./configure options and disable everything but I don't know the the configure help actually shows all the options you can disable. Like I disable a lot of things for my emacs install on a remote terminal because I don't need GUI, mail, etc. But yeah I don't actually use 99% of the extra stuff that emacs has; I just install the lang-mode packages, sometimes the language server packages, magit, and I'm done.
Tequila · 2019-04-19 03:49
To me it looked a little too unnecessarily complicated for my needs and I side with the vi camp (which seems to have won by the numbers) but I could see myself eventually getting accustomed to emacs down the road, I definitely find it to be an interesting topic
Ishikura "Tatsu" Tatsuhiko · 2019-04-19 13:16
>>13263 >Ideally I'd like a minimal version of emacs that is basically just a elisp interpreter then you pick and choose what other stuff you want. Many people have had this same thought over the years and ultimately concluded that's it's not worth it. Emacs ultimately is just an environment built around elisp interpreter. Users don't pay any price for the 2 IRC clients besides a slighter bigger install size If it's any consolation, Stallman has recently been opposed to including more functionality in Emacs as it bloats the already difficult to maintain manual.
swap · 2019-04-21 01:21
What is standard idiom for making multidimensional array in elisp? elisp info page mentioned I should make nested one dimensional array but what is the difference between (setq 2d-vec (make-vector 6 (make-vector 6))) and (setq 2d-vec (make-vector nil)) (dotimes (i 6) (setf (aref 2d-vec i) (make-vector 6))) ? Stackoverflow page mentioned I'm aliasing in the first case but what does that mean exactly?
Aristóteles Amadópulus · 2019-04-21 13:54
>>13304 (me) I am yet to understand how aliasing works in emacs lisp but I guess in first expression inner make-vector is evaluated once before outer make-vector is evaluated, resulting in all the elements outer vector to be one same vector not six unique vectors. This honestly feels dumb. Is there specific reason why emacs lisp does not provide multidimensional array natively?
Judge Fang · 2019-04-22 20:42
>>13307 >I am yet to understand how aliasing works in emacs lisp but I guess in first >expression inner make-vector is evaluated once before outer make-vector is >evaluated, resulting in all the elements outer vector to be one same vector >not six unique vectors. Playing around in ielm this seems correct. >This honestly feels dumb. Is there specific reason why emacs lisp does not >provide multidimensional array natively. There are many questionable design decisions that went into Elisp. The best you can do is to extend the language to your liking. The following is a efficient implementation of multi-dimensional arrays. With these basic operations you could if you wanted define a library of linear algebra functions, iterators, etc. lisp (defstruct flat-array data factors) ;; No bounds checking is provided other than that at the ends of the ;; flat-array, watch out! (defun compute-flat-index (indices factors) (defun iter (i acc) (if (< i (length indices)) (iter (+ i 1) (+ acc (* (elt indices i) (elt factors i)))) acc)) (iter 0 0)) (defun build-flat-array (dimensions init) (let ((flat-array (make-vector (seq-reduce #'* dimensions 1) init)) (index-factors (let* ((dimensions-length (length dimensions)) (factors-length (max 1 dimensions-length)) (factors (make-vector factors-length (if (zerop dimensions-length) 0 1)))) (unless (< factors-length 2) (dotimes (i (- factors-length 1)) (let ((pos (- factors-length 2 i))) (aset factors pos (* (elt dimensions pos) (aref factors (+ pos 1))))))) factors))) (make-flat-array :data flat-array :factors index-factors))) (defun flat-array-ref (flat-array indices) (aref (flat-array-data flat-array) (compute-flat-index indices (flat-array-factors flat-array)))) (defun flat-array-set (flat-array indices val) (aset (flat-array-data flaty-array) (compute-flat-index indices (flat-array-factors flat-array)) val))
Six · 2019-04-22 20:57
>>13325 A even better place to start would be by improving these functions, by adding bounds checking to compute-flat-index, or by removing the excessive let* in build-flat-array.
Stallman · 2019-04-22 21:03
>>13326 or the type in flat-array-set...
Leto Atreides I · 2019-04-22 22:42
god this is so poorly done, in so many ways, sorry about that, I'll fix it, do a sage and re-post when I'm done.
JARGON · 2019-04-23 02:14
This seems acceptable: lisp ;;;-*- lexical-binding: t; coding: utf-8 -*- (defstruct flat-array data factors bounds) (defun build-flat-array (bounds init) ;; Bounds are mandatory rather than (build-flat-array [] []) the caller must ;; instead do (build-flat-array [0] []) this should perhaps be reconsidered. (when (= (length bounds) 0) (error "No bounds specified")) (let* ((bounds-length (length bounds)) (factors (make-vector (max 1 bounds-length) (if (= bounds-length 0) 0 1)))) ;; This function is multi-purpose, it mutates the factors array to the ;; proper values, calculates the total size needed for the flat-array, and ;; checks to make sure the bounds data isn't pathological. This is all done ;; in one function to avoid having to traverse the data more than once. (defun iter (i size) (let* ((pos (- bounds-length 2 i)) (init (aref bounds pos))) (cond ((<= init 0) (error "Invalid bounds %d" init)) ((= i (- bounds-length 2)) (aset factors pos (* (aref factors (+ pos 1)) init)) (* size init)) (t (aset factors pos (* (aref factors (+ pos 1)) init)) (iter (+ i 1) (* size init)))))) (defun iter-init () (let ((bound (aref bounds (- bounds-length 1)))) (cond ((< bound 0) (error "Invalid bounds %d" bound)) ((< bounds-length 2) 1) ((= bound 0) (error "Invalid bounds %d" bound)) (t (iter 0 bound))))) (make-flat-array :data (make-vector (iter-init) init) :factors factors :bounds bounds))) (defun compute-flat-index (factors bounds indices) (defun iter (i acc) (let ((index (aref indices i))) (cond ((<= (aref bounds i) index 0) (error "Index %d out of bounds %d" i (aref bounds i))) ((= (- (length indices) 1) i) (+ acc (* index (aref factors i)))) (t (iter (+ i 1) (+ acc (* index (aref factors i)))))))) (if (= (length indices) (length bounds)) (iter 0 0) (error "Wrong number of indices %S" indices))) (defun flat-array-ref (flat-array indices) (aref (flat-array-data flat-array) (compute-flat-index (flat-array-factors flat-array) (flat-array-bounds flat-array) indices))) (defun flat-array-set (flat-array indices val) (aset (flat-array-data flat-array) (compute-flat-index (flat-array-factors flat-array) (flat-array-bounds flat-array) indices) val))
synchronized · 2019-05-28 17:11
I've been diving into emacs since a few days and i'm loving it! Who knew a text editor could be so fun.
list · 2019-05-29 21:31
>>7270 My main use of emacs nowadays is creating latex files/pdfs. It used to be kinda clunky, but its extensibility really allows you to automate a lot of the error-prone things. Here's an example of how I've enhanced m latex configuration to set up homework projects. https://pastebin.com/72NMvhKz
Faye Valentine · 2019-06-02 15:54
This an uploading utility for https://0x0.st - Hopefully you find it useful. (defun z/0x0-get-buffer () (list (point-min) (point-max))) (defun z/0x0-get-region () (list (region-beginning) (region-end))) (defun z/0x0-make-temp-file () (make-temp-file "0x0" nil (file-name-extension (concat (buffer-name) ".txt") t))) (defun z/0x0-write-to-file (file) (apply 'write-region (append (if (region-active-p) (z/0x0-get-region) (z/0x0-get-buffer)) (list file)))) (defun z/0x0 (&optional arg) (interactive "P") (let ((temp-file (if arg (read-file-name "File to upload: ") (z/0x0-make-temp-file)))) (unless arg (z/0x0-write-to-file temp-file)) (set-process-filter (start-process "0x0" nil "curl" "-F" (format "file=@%s" temp-file) "https://0x0.st") (lambda (process output) (message (kill-new (replace-regexp-in-string "\n$" "" output))))))) ;; Set up a keybinding for it, for example: (global-set-key (kbd "C-c 0") 'z/0x0) ;; C-c 0 anywhere to upload the entire buffer, or region if region is selected. ;; C-u C-c 0 to upload a file from the prompt.
Zuse · 2019-06-03 21:11
>>13813 Hey zdm, I saw you mention this in irc the other day and it made me wonder if I could make it work with url.el instead of curl. Alas I can't figure out how to POST a multipart/form-data using url.el. Bellow are the modifications I was capable of making soundly. Also I don't understand what the "P" option in interactive does, would you mind explaining? lisp (defun z/0x0 (&optional arg) (interactive "P") (let ((temp-file (if arg (read-file-name "File to upload: ") (make-temp-file "0x0" nil ".txt" (if (region-active-p) (buffer-substring-no-properties (region-beginning) (region-end)) (buffer-string)))))) (set-process-filter (start-process "0x0" nil "curl" "-F" (concat "file=@" temp-file) "https://0x0.st") (lambda (process output) (message (kill-new (replace-regexp-in-string "\n$" "" output))))))) ;; Set up a keybinding for it, for example: (global-set-key (kbd "C-c 0") 'z/0x0) ;; C-c 0 anywhere to upload the entire buffer, or region if region is selected. ;; C-u C-c 0 to upload a file from the prompt.
Jens Hansen · 2019-06-05 01:05
>>13822 Sorry for the late response but thanks for the contribution. If you didn't figure it out, "P" just lets you pass the prefix argument C-u: https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Interactive.html I'm not sure how to use url.el but it would be nice to use pure elisp instead of the curl backend process. Maybe I'll look into it.
Lady 3Jane.. · 2019-06-05 14:08
>>13837 >If you didn't figure it out, "P" just lets you pass the prefix argument C-u ah, okay, I read that in the help page but I just didn't understand what a prefix argument was for whatever reason. Thanks. >I'm not sure how to use url.el but it would be nice to use pure elisp instead of the curl backend process. I looked into it some more, and this is just something url.el can't do apparently, there are libraries but I think they're all just wrappers around curl, so you're stuck I think.
dictionary · 2019-06-06 09:19
Hi lainons, I have a bit of a niche question about js-mode. I am doing a proyect in node: a chatbot, which is a webapp using some framework built by a highly unreputable corporation (none of this was my call). I do not know node, javascript or anything at all about webapps. So if my whole reasoning about the issue is wrong, I am more than happy to get it pointed out. Ok, on to the issue. this is my workflow running a bot. I start the, a js console and a restify server (no idea what this is or what it does), and connect the bot to it. Obviously things do not work as expected, so I need to restart the server and console for my changes to take effect, cause I copied shitton of code from the docs, and everything is a cons, so things cannot be redefined, and i am not going to go arround sending only the necessary bits of code via js-send-region. Also if there is a better way, i do not know. For some reason js-comint-restart-repl tends to hang my emacs, so i am killing the console buffer. Cause doing this is a pain, I wrote a little function: First of all I have my server.close() commented out in some file, so i can js-send-buffer safely. and i have a function that uncoments, closes and comments again. I know the let could be simpler/removed cause there are functions than do that, but i figured that out afterwards. (defun js-close-server () (interactive) (let ((beg (progn (move-beginning-of-line 1) (point))) (end (progn (move-end-of-line 1) (point)))) (progn (uncomment-region beg end) (js-send-last-sexp) (comment-region beg end)))) Now comes the question. I have a little function that goes to the file where the previous is supposed to be executed, runs it and kills the js console. Problem is: I want to start a new console, and send that buffer. but when run-js gets run from the script, the index.js buffer does not get associated to the console, so js-send-buffer does not work. I have tried using both set-current and switch-buffer, but none seems to work, and js-send-buffer takes no arguments. js-send-buffer calls a lower lever function and that might do the trick, but i would like to know if there is a high level alternative. (defun js-restart-bot () (interactive) (save-current-buffer (set-buffer "index.js") (beginning-of-buffer) (search-forward "server.close()") (js-close-server) (kill-buffer "*Javascript REPL*") (switch-to-buffer "index.js") (run-js) (switch-to-buffer "index.js") (js-send-buffer))) As I said, I know this is fairly niche.
Turner · 2019-06-07 18:16
Lains, I need your help. Why is package.el unable to install this package? https://github.com/rosbo018/q4 I tried branching it and adding a (provide 'q4) but that didn't help either. Please advise?
Project 2501 · 2019-06-08 20:40
>>7270 Why do people say elisp is inferior?
() · 2019-09-17 17:38
I'd like to point you all to a lovely little package I found today: https://github.com/raxod502/el-patch It simply allows for you to customize pieces of existing code from packages and the like and have it so that you're notified of any future modifications from upstream so that you can keep upgrading your emacs without fear of breakage (you'll get an ediff of the changes). It also integrates with use-package. I came across this package from a user on the #emacs channel on freenode as I was having a problem: I needed to change a very specific portion of code in the asm-comment function, specifically this line: (insert asm-comment-char asm-comment-char ?\ ) My change is stupidly simple, I just want to remove one instance of asm-comment-char. The solution is copying the whole function, which el-patch helps with a bit but it's still a stupid solution. What would be nice would be some way of targeting that specific line and being able to modify it wholesale. Emacs Lisp comes with Advice functionality but these only act as wrappers and you can't really target something specific. Do any of you know a way of, or perhaps can think of way to implement, such functionality?
Ishikura "Tatsu" Tatsuhiko · 2019-09-17 19:19
>>13837 >>13822 See https://melpa.org/#/0x0, supoorts both url.el and curl.
Six · 2019-09-26 04:46
Here is an excerpt from my init pertaining to ERC: (use-package erc :init (setq erc-modules '(pcomplete netsplit fill button match track completion readonly networks ring autojoin noncommands irccontrols move-to-prompt stamp menu list notifications)) :config (erc-update-modules) (erc-notifications-disable) (add-hook 'focus-in-hook 'erc-notifications-disable) (add-hook 'focus-out-hook 'erc-notifications-enable)) This allows for notifications to be sent via dbus (so, libnotify) when not focused on the frame, but when focused notifications are sent through their usual means (your modeline) so you don't have double notifications like you would if you simply left the notifications library enabled. It would be wonderful if anyone reading this would share their own useful snippets of Emacs utility/functionality. For anyone interested here is my full ERC configuration which I've commented for you: https://0x0.st/zvPt.txt
BloodCat · 2019-09-29 20:48
if one wanted to embed some xembed aware programs into emacs, should they start by looking at xelb?
Hopper · 2019-10-02 05:57
>>15392 I suppose extending and customizing ERC is a frequent past-time of mine now. I made a little change: (defun user/erc-server-name (server) "Generate the main name for the server" (replace-regexp-in-string (rx "." (eval `(or ,@user/erc-tld-list))) "" (replace-regexp-in-string (rx bol (+? char) ".") "" server))) (defun user/erc-nickserv-auth (server nick) "Identify with NickServ, but only for SERVER and not future servers (via M-x erc-tls)" (erc-with-server-buffer (erc-server-send (format "NickServ IDENTIFY %s" (with-temp-buffer ;; Passwords are stored in file named after the main server name. ;; e.g irc.freenode.net -> freenode ;; lainchan.org -> lainchan (insert-file-contents (concat user-emacs-directory (user/erc-server-name server))) (buffer-string))))) (setq erc-after-connect (remove 'user/erc-nickserv-auth erc-after-connect))) user/erc-tld-list is a variable bound to a list of strings, each string being a tld. This list contains every tld: https://0x0.st/zvnV.txt - Combined together these two functions allow nicely defined functions for connecting and identifying with a server, like so: (defun user/erc-lainchan () "Connect to lainchan.org, identifying with NickServ after a successful connection" (interactive) (add-to-list 'erc-after-connect 'user/erc-nickserv-auth) (erc-tls :server "lainchan.org" :port 6697)) (defun user/erc-freenode () "Connect to irc.freenode.net, identifying with NickServ after a successful connection" (interactive) (add-to-list 'erc-after-connect 'user/erc-nickserv-auth) (erc-tls :server "irc.freenode.net" :port 6697)) This allows you to still connect to servers via M-x erc-tls without identifying. I did this because 1.) I don't want to store my password in my init as I sometimes share my config and rather have it all public-friendly. And 2.) ERC's built-in NickServ identification flat out doesn't work for some servers.
Apoc · 2020-02-06 01:14
>>13813 Been a while, modified this little program, still uses cURL because I'm lazy. Supports several pastebin services, and I'll probably extend support to pomf services some time, maybe add in gist support at some point as well. Attached file should have the .txt extension removed when put in `load-path'.
nibble · 2020-02-06 09:40
>>16786 Most up to date version here: https://gist.github.com/zdm0/07b28c14b4d8b03139efb5a1a3b7e628
Donna Hawthorne · 2020-02-06 22:09
I've tried Emacs a few times, but I haven't stuck to it, but I still have the intention. I hope you can point out the fault in my reasoning and how should I approach Emacs so I can actually proceed. Problem is the size of it. I want to do stuff but the manuals are huge and just getting the basic elements it, and how they interact with each other, and what is the most relevant information, and how they might be manipulated by code I write, all of it is buried in huge manuals with many many details too big for me to read without getting annoyed. For example, I want to tweak the paredit and vile packages to make my own modal workflow for paredit, but I don't even know where to start, I take I would need to know how the event handler dispatches keyboard input, and how it can be modified to do something else, but I wouldn't know where to look for this info as it may pertain to one or more of several aspects of the editor. tl;dr editor is huge and documentation too so I don't even know where to start looking up info to edit the editor
Faye Valentine · 2020-02-07 07:32
>>16786 >>16788 Add types to your defcustoms, and consider using the \[...] syntax for keybindings in your docstrings.
Special Agent Bob · 2020-02-08 00:03
>>16786 https://melpa.org/#/0x0 now implements most of what you do too.
John Doe · 2020-02-08 13:06
>>16801 Ok Philip, I see you ;)
nibble · 2020-02-15 20:01
>>16788 Moved to https://git.lain.church/zdm/emacs-upload - Changed how some things work, moved away from eval as that's just dumb, considered using a macro but figured out I didn't need one at all. It would be really nice to get away from curl completely but that still alludes me. Maybe I'll have to write a specialized http client just for sending forms. I might genuinely do that, in Emacs Lisp of course. I also need to handle errors and "parsing" json better. How would I detect if some data is json? Or should I perhaps change emacs-upload/hosts to have something like "pomf-p" in the list if a host is a pomf service? Unsure.
Lukasiewicz · 2020-05-29 19:36
Hello! I recently got into writing elisp to help me write latex more efficiently. I found that I was wasting a lot of time going between pairs of "{}" and "()" so I wrote some Elisp to help me. Basically, you press "C-Tab" to go to right-before the next "}" and "C-S-Tab" to go to the previous "{". I found this to be actually pretty useful. I was curious to see what better ways of writing this would be, since I'm not sure what "good style" elisp is. (defun on-same-line-p (start end) (cond ((and start end) (<= (count-lines start end) 1)) (t nil))) ;; Kinda jank, but just do a search for the next "}" or ")". ;; If it 's on a different line, just ignore it. (defun latex-goto-next-brace () (interactive) (let* ((curr-pos (point)) (curly-pos (progn ;; "+ 1" is done to ensure we don't get stuck ;; at a particular brace. (goto-char (+ curr-pos 1)) (search-forward "}" (buffer-end 1) t))) (paren-pos (progn (goto-char ( + curr-pos 1)) (search-forward ")" (buffer-end 1) t)))) (cond ((on-same-line-p curr-pos curly-pos) (goto-char (- curly-pos 1))) ((on-same-line-p curr-pos paren-pos) (goto-char (- paren-pos 1))) (t (progn (goto-char curr-pos) (message "No Change!"))) ))) (defun latex-goto-prev-brace () (interactive) (let* ((curr-pos (point)) (curly-pos (progn (goto-char (- curr-pos 1)) (search-backward "{" nil t))) (paren-pos (progn (goto-char (- curr-pos 1)) (search-forward "(" nil t)))) (cond ((on-same-line-p curr-pos curly-pos) (goto-char (+ curly-pos 1))) ((on-same-line-p curr-pos paren-pos) (goto-char (+ paren-pos 1))) (t (progn (goto-char curr-pos) (message "No Change!"))) )))
Emmanuel · 2020-05-29 20:53
>>18891 Notes: - cond bodies have an implicit progn, so you don't need to add - try using the save-excursion macro - usually functions like these are written so that the "previous" variant calls the "next" variant with a negative argument. - cond doesn't have to be exhaustive, (cond) evaluates to nil, just like (cond (t nil)). Therefore on-same-line-p can just be ((and start end) ...).
null · 2020-05-30 04:11
>>18893 Thank you! Didn't know about the macro, and I forgot how cond works. Appreciate it!
DEBUG-CONTENTS · 2020-05-30 12:32
>>18891 >>18896 Actually reading the code, I think (defun latex-goto-next-brace () (interactive) (forward-char) (or (search-forward "}" (line-end-position) t) (search-forward ")" (line-end-position) t) (message "No Change!")) (backward-char)) should do the same. The difference is that instead of using on-same-line-p, I bound seach-forward to no look beyond the end of the buffer. I don't think the message is necessary (you've either moved or you didn't), but I kept it in to show how or can implement a "default-case". latex-goto-prev-brace should be quite similar, just with the operations reversed. My original idea was to use narrowing + save-restriction to prevent search-forward from searching beyond the current line, but since search-forward already has a BOUND argument, it turns out to not be necessary. You used (buffer-end 1), which is just a fancy (point-max), but that's not necessary in general, since a nil is interpreted as: "A value of nil means search to the end of the accessible portion of the buffer." (see the function docstring).
Rick Deckard · 2020-06-05 05:09
>>7270 As part of my org-roam workflow, I've been linking a bunch of youtube videos and have been kinda bored by needing to manually insert the title and duration each time, so I decided to automate it. I know there's a json library, but doing it with jq just seemed easier. (defun youtube-command (url) (shell-command-to-string (format "youtube-dl -j %s" url))) (defun jq-get-field (json field) (shell-command-to-string (format "echo '%s' | jq %s " json field))) (defun youtube-get-title-duration (url) (let* ((yt-json (youtube-command url)) (duration (string-to-number (jq-get-field yt-json ".duration"))) (title (replace-regexp-in-string "\"" "" (string-trim (jq-get-field yt-json ".fulltitle"))))) (list duration title))) (defun duration-to-string (duration-sec) (let ((hours (/ duration-sec 3600)) (minutes (/ duration-sec 60 )) (seconds (mod duration-sec 60))) (if (> hours 0) (format "%dh:%02d" hours (/ (- duration-sec (* hours 3600)) 60)) (format "%s:%02d" minutes seconds)) )) (defun org-format-youtube (url) (interactive "sURL: ") (let* ((yt-info (youtube-get-title-duration url)) (duration (nth 0 yt-info)) (title (nth 1 yt-info))) (insert (format "[[%s][%s (%s)]]" url title (duration-to-string duration))))
Nameless · 2020-06-05 05:16
>>18910 I think I had misread the docstring. However, now I'm confused. How do you ensure that you return the minimum of the two searches (closed curly-bracket and closed parenthesis)?
Cutter · 2020-06-05 07:02
>>19022 Just realized a small error in my jq-get-field function: I had seen that the elisp interpreter had correctly escaped double-quotes in the json-string, but didn't see that it didn't do so in the single-quote case. Because I'm passing this string to the shell, any single/double quotes must be escaped. Luckily, there's a command for that. The new function is: (defun jq-get-field (json-str field) (shell-command-to-string (format "echo %s | jq %s" (shell-quote-argument json-str) field)))
Yu-ichi · 2020-06-05 08:58
>>19023 The function doesn't, just like the previous one. It verifies if a closing curly parenthesis is between the point and the end of line, and jump to it if found. The same is repeated if the previous attempt failed, for regular parentheses. At least that's why my mental evaluation of the initial code gives me. If you want to find the first, you could to do something like (search-forward-regexp (regexp-opt '("}" ")")) (line-end-position) t)
Unspecified · 2020-06-05 16:59
>>19034 Huh. I can't believe I'm saying this but I think I don't understand my code. I completely just thought I would get the first occurrence of the next "closing delimiter". My bad. And I had no idea regexp-opt existed. Thanks for introducing me to it. I feel like I'm at a point in elisp-ing where I can mostly figure out what I need to do, but am missing a bit of experience. Thank you!
Dozer · 2020-07-08 22:51
I love lisp, any lisp
aliased · 2020-08-20 02:11
I'm having an awful time with gnus. I want to import a few hundred RSS feeds, but can't automate this. Pressing G R in the *Group* buffer runs gnus-group-make-rss-group. Just adding the feeds to nnrss-group-alist didn't work, and I thought taking apart gnus-group-make-rss-group to run its body on a list of the relevant data would work, but it doesn't quite succeed. This may have something to do with some of these RSS feeds having URLs that end in HTTP parameters rather than rss.xml or variants. I tried converting the data to OPML and using nnrss-opml-import, but this uses the interactive procedures, so it's useless for my purposes. The reason I think it's got to do with these different endings is because it only fails for those which have this, not others. Anyway, I've spent at least eight hours working on this and reading the manual, so I'd appreciate some help before I just give up and use something else. This is the worst Emacs experience I've ever had.
dup · 2020-08-20 03:43
>>20378 gnus is ancient and soykaf. if you want rss, go with elfeed.
Haruyoshi · 2020-09-23 17:40
>>20378 >>20379 I second the elfeed recommendation. You can simply set a list of feed URLs and that's it.
Shogun · 2020-10-16 21:35
Something which seems to not have been mentioned in the thread so far but which I think should be: emacs --daemon. It means that the delays in opening Emacs are only ever noticed on first starting it, so long as you use emacsclient to invoke it from other programs (if need be). One should also get in the habit of using the "C-x 5 <char>" keybindings as necessary.
The Fin · 2020-10-19 09:15
Some guy has started a survey that was announced on emacs-devel a few weeks ago, to find out how people use Emacs: https://emacssurvey.org/. It's mainly being organized on Reddit, so it's to be expected that a lot of Doom/Evil users will be overrepresented. If you don't want to give these people the excuse to push for a more VSCode like dumbing down of Emacs, consider participating.
HELIOS · 2020-10-19 11:05
>>21493 I just hope that if they make significant changes to emacs defaults, I won't have to revert them.
t · 2020-11-06 20:35
>>7273 based
cdr · 2020-11-07 04:01
>>21498 Maybe the best way around that would be to load all the "modern customisations" into a theme, that can either be disabled easily or enabled on the spash screen for beginners.
Nell · 2020-11-21 10:12
I've recently been reconfiguring to use visual lines rather than hard breaks in modes not derived from prog-mode. I'm wondering if there exists something similar for source code, and specifically Common Lisp? This would mean keeping a Common Lisp program on one line or maybe a few lines (line breaks for comments) and having the editor softwrap and indent to the user's preferences. I know this is in opposition to the established norms, and to a lesser extent GNU Emacs due to its buffer representation, but this seems to be the only rational way to deal with formating issues while respecting the preferences of every developer (that's not to say that the selection of equivalent alternatives is in any way significant).
Motoko Kusanagi · 2020-11-25 06:47
>>7270 OP, you can use vim binding in emacs, you only need 1hour-30min to do the configuration and you have the same thing :/
Yuki Nagato · 2020-11-25 06:48
>>7270 OP, you can use vim binding in emacs, you only need 1hour-30min to do the configuration and you have the same thing :/ Why people think emacs is hard to learn, i you used to use gnu/linux on daily basis emacs is just CONFIGURATION and the rest is fun :D
caddar · 2020-12-09 08:54
I finally wrote a minor mode for myself. A modal editing mode which is not evil. I borrowed significat amount of code from xah-fly-keys and kakoune.el, but made a handful of my own text-editing functions. I'm finally free from paredit and smartparens, but unlike xah-fly-keys, my mode doesn't delete the whole sexp when it deletes an opening or closing delimiter. Instead it unwraps this sexp by deleting surrounding delimiters when you try to delete a single paren. At this moment it's less than 1k lines of code. It was a pleasant experience, I'm planning to exend it in the future, but at this moment it has everything I need :D
Hopper · 2021-01-02 10:21
>>7270 Hello lains. Recently made a set of functions to help me organize my notes. It's loosely based off of org-roam in that both projects use tags to keep track of things, but my project focuses a lot more on being able to search on a set of tags more easily. Here's a screenshot of a query over my notes (It looks like a normal org-mode buffer, but it's generated by querying with the arguments you see in the first line in grey). The repo is here: https://github.com/ricardoaiglesias/prog-snippet Currently looking for suggestions and / or criticisms.
Switch · 2021-01-17 17:01
>>7782 Try installing MSYS and emacs in the MSYS environment, then try updating gnutls on the shell Note that the GNU project doesn't support the Windows port or any port of Emacs to non-free operating systems, and administrator is just a placebo pseudo-root account
Y.T · 2021-01-17 20:15
>>21493 You are implying that no one here is using either of DOOM or Evil.
Mitnick · 2021-02-09 16:09
>>23692 I keep most of my notes (programming or otherwise) in org documents. So far, the existing search features provided by Spacemacs have been sufficient, though. With that said, the tag-oriented view you came up with looks useful. Perhaps I'll try it out.
Neo · 2021-02-10 05:52
>>7274 >>9671 Hah, I take it you're not doing it anymore, I just posted into another thread that I'm working on something like that right now.
strikechad · 2021-02-13 10:28
Hey lainons, are there any benefits of using org-roam over normal org mode?
renames · 2021-02-17 11:06
>>24453 >org-roam https://www.orgroam.com/ https://www.orgroam.com/manual.html#Introduction > Org-roam is a tool for network thought. It reproduces some of Roam Research’s 1 features within the all-powerful Org-mode. > Org-roam is a solution for effortless non-hierarchical note-taking with Org-mode. With Org-roam, notes flow naturally, making note-taking fun and easy. Org-roam keeps closely to Org syntax, and will work for anyone already using Org-mode for their personal wiki. At first glance, it looks really interesting. Without knowing much about it, I'm concerned to what degree it's compatible (or not) with my existing body of org documents. I definitely want to explore this system later.
Ivan Petrov · 2021-02-18 16:05
>>24453 >>24506 I've dipped my toes in the waters of org-roam, and it's stylistically very different from how I currently use org-mode. Instead of making long org documents, org-roam encourages the creation of many small notes that can be linked together. It's supposed to free you from worrying about where in a documents hierarchy an idea should go. That can be done later (or not at all) after the data has been collected. I've set aside a little directory in my filesystem for org-roam documents (which you HAVE to do), and I'm going to give it a chance. I'm not used to this style, and it'll take me some time to acclimate, but I'm willing to try. My existing org documents will remain where they are, and I'll keep writing in those, too. https://www.youtube.com/watch?v=bTbiC6SamT4 I watched the above video to help me get the gist of the system, and I think he did a decent job of introducing org-roam.
Mario Rossi · 2021-02-18 16:51
>>24453 This might help with why you'd want to use such a system. https://writingcooperative.com/zettelkasten-how-one-german-scholar-was-so-freakishly-productive-997e4e0ca125 https://archive.vn/uO8E7 <Why other notetaking systems fall short >If you’re anything like me, you’ve tried taking notes in all sorts of ways. >- You’ve written in paper notebooks, >- you’ve written on the margins of books and printouts, >- you’ve used smartphone and web apps, >- you’ve taken notes using a word processor or text editor and tried to organize the resulting files in a sensible folder structure on your computer, >- you’ve drawn both analog and digital mind maps and concept maps, >- you’ve used outliners, and >- you’ve buried your desk under a chaos of post-it notes and random slips of paper. >The problem with all these approaches is that they don’t really help you find connections among ideas. Instead, they lock ideas away to be forgotten in a box under your bed, in the cloud, or in a folder somewhere on your computer.
Lady 3Jane.. · 2021-02-21 22:06
>>24453 Now that I've used it for a few days, I'm starting to see the benefits. I have a lot of text in org documents prior to using org-roam, but I have to admit that I don't go back to read a lot of what I wrote. I do text searches and tag searches to find old content, but with org-roam, you're building a secondary associative memory. In the beginning, it feels contrived and awkward, because you're like a baby who has a blank slate for memories. However, as you fill your roam directory with org documents that are linked together, you start noticing connections that you might not have noticed before. I think as I write more, I might discover more surprising connections. It's up to you to aggressively link docs. That's what gives org-roam its power. When I first looked into org-roam, I saw people writing about the Collector's Fallacy. https://zettelkasten.de/posts/collectors-fallacy/ Collecting information by itself doesn't lead to progress. More often than not, it's just collected to never be looked at again. However, when you add CONNECTION to the mix, what was once forgotten has a chance of being remembered. This is one of my biggest takeaways from org-roam so far.
Zuse · 2021-06-15 15:07
Hello, I'm wondering if anyone here knows a better way to write the following type declaration such that YEAR can be a variable which is evaluated. I find the satisfies clause really unfortunate and would much rather have everything in the integer, but can't seem to find a way to make YEAR evaluate correctly in this case. Otherwise if someone can explain why it must be this way that would also be useful. (cl-deftype timestamp-day (year) `(and (integer 1 *) (satisfies (lambda (d) (<= d (if (timestamp-leap-year-p ,year) 366 365))))))
limited · 2021-06-17 16:38
All my life I have been a filthy end user, I always got the binary emacs from the package system of whatever os I ran at the time. Just today I bothered to look at the source and realized that I can build without gtk support! I never really liked using emacs in a console, and didn't like the absurdity of needing gtk for a graphical interface. Today I built emacs with minimal dependencies, perhaps I'm finally taking the step towards really having the setup I like.
string · 2021-06-22 08:06
>>26264 I ended up ripping out cl-lib entirely from my application, it was becoming more trouble than it was worth. I need more complex constructors and accessors than cl-defstruct allows for and simple predicates ended up being shorter and just as effective as my type declarations. Other macros like cl-flet, cl-do, and common lisp argument lists were also easily worked around.
Hououin Kyouma · 2021-12-28 01:34
I'm dreading trying to write a program in Emacs Lisp more complex than my configuration, but it's the closest I'll reasonably be able to get to easily writing a graphical program. A curveball is that my program is meant to exemplify an alternative internal representation for text, which clashes with Emacs', so I've thought of some tricks I may need to use to avoid issues, but it's all vague currently.
Acid Burn · 2022-02-17 23:20
>>7284 Just delete the .el you don't need then.
Dr. X · 2022-07-24 19:17
How to get good at elisp? I don’t have any project I would like to make I think. At least nothing worth the effort. I’ve learned it multiple times but never use enough to remember. I don’t use any other lisp. Really considering changing to neovim because vim script and lua are so much easier to remember.
Masami Eiri · 2022-07-25 08:30
>>32008 >How to get good at elisp? Read this: https://www.gnu.org/software/emacs/manual/eintr.html and start using elisp. I would use something else for writing your own projects with. If you are interested in Lisp, I recommend you learn R5RS Scheme. Start with Little Schemer and use either Guile or Chicken Scheme implementation. You said you liked Lua more than Lisp? That's alright. Install lua-mode and work through https://www.lua.org/pil/contents.html To be honest, most of time I just use recorded keyboard macros (https://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html) instead of elisp.
Mentat · 2022-07-25 15:36
>>32015 O already read that and I already read the little schemer. But I never really use lisps for anything and thus forget. It’s not so much that I like lua, I also barely used it, but it’s easier to remember. I guess the only solution is to find a lisp project to make.
limited · 2022-07-28 22:27
>>24529 I literally have a disorganized pile of sticky notes with ideas written on them because I got so sick of my infodump writer docs. Thank You!
let · 2023-03-16 04:19
On the topic of org-mode: Does anyone know how I could get the capture templates to evaluate the template blocks in a filename expression? Those are the blocks: https://orgmode.org/manual/Template-expansion.html I tried everything for the actual file name of the capture. But even if I use (function ...) instead of (file...) the %f and %U are never evaluated BEFORE being sent to the file name maker. I searched across dozens of sites and even within the org-captures.el file itself. Reason: I want to create a more zettelkasten-style version of org. Org-roam is too unstructured for my taste. I want to be able to take notes on note files, i.e. org files that I currently have open. The new note file should have the format "%currently-open-filename-note-%timestamp.org" The rest, inside the actual capture template, like automatically inserting a backlink etc. works just fine. It really just is the actual creation of the filename based on template elements that seems impossible. I know, I could use some builtin elisp function for the timestamp, but I do not know how to replace the %f, which is the name of the currently opened file from which I started the capture.
Iverson · 2023-11-06 04:53
I've been getting a lot into CTF's lately and since I already use Emacs for note taking and as my terminal emulator I was thinking about creating a minor mode for it. Using Emacs as an interface for stuff like msfvenom and metasploit seems alright as a first thing. My knowledge of elisp is limited so I'm taking this as a project to learn. Any ideas or suggestions are well received of course.
progn · 2024-04-06 00:04
>>10206 This is exactly what I do as well. Vim is much more snappy than Emacs over SSH when dealing with a config file, but Emacs is definitely faster for writing some C/C++ in. The tabbing work it does for you is amazing.
Trinity · 2024-10-19 06:04
>>12231 Honestly? For general-purpose programming, CL beats Elisp handily. However, Elisp is surprisingly good considering its age. Now that it has lexical binding, arbitrary-precision integers, and useful external libraries like s.el, I find it pretty comfy, even if it's not as good as it could be. >>18891 Putting (interactive) on the same line as the function's arguments is screwing up your indentation. >>19022 These unnecessary shell invocations are triggering me. You're writing the shell equivalents of SQL injection and you're going to get problems as soon as you pass a string with special characters like '. Try something in this vein instead: (let ((parsed-json (json-parse-string (car (process-lines "yt-dlp" "--no-warnings" "--dump-json" "--" url))))) (format "YouTube: %s: %s" (gethash "uploader" parsed-json) (gethash "title" parsed-json))) Notice how the process is invoked directly with a list of arguments. We don't use a shell at all, so we don't have to worry about escaping arguments, only about --. >>21493 What's wrong or "dumbed down" about Doom and Evil? They don't subtract functionality from Emacs, they add functionality and improve the defaults. >>23692 Looks nice, I only have nitpicks. - You may be using prog-snippet--name instead of prog-snippet-name for functions that are intended to be used from outside. The usual convention is single dash for "public" functions and double dash for "internal" functions. - You have some unprefixed functions in prog-snippet-db.el and prog-snippet-org.el. - There seems to be quite a bit of (unless db (setq db (prog-snippet-db--get-connection))) boilerplate spread across the package. Have you considered containing this boilerplate to prog-snippet-db.el and having functions outside of that file pass nil? Or maybe you could not have db arguments at all and just tell the user that the connection variable is dynamically bound and he can rebind it with let if they want, the way it's done with default-directory. >>24453 org-roam is for people who want to have a big cloud of densely linked small notes. Personally, I prefer to maintain larger org-mode documents that are basically articles written for myself. Something like Python.org * TUI libraries [2020] * Profilers [2021] * Comparison of ways to do C FFI [2022] * Best package managers [2023] >>32008 eintr.pdf, then just reading a lot of other people's code and writing your own.
Delilah · 2025-02-26 02:52
>>7281 >>13263 I simply cannot understand how people can use Vim professionally. I understand that to SSH into a server, it might be better to use Vim, but for the current work I simply cannot. Even for SSH you can simple TRAMP into the target server lol. One of the biggest problems, in my opinion, is the huge amount of plugins that you need to install to "mimic" what Emacs already does out of the box. This means less dependence on third-party code. In addition, we also have things like dap-mode, org-mode, helm that are simply impossible to reproduce in Vim with the same efficiency as Emacs. Another thing that bothers me a lot is having to memorize 1830748103741 commands for 813741037481 different programs. With Emacs I can centralize my entire workflow in one place, which makes things much easier when you change environments. Just put your .emacs in the root directory and you will basically be able to reproduce your custom environment. You can even have a .vimrc, but it won't be the same since you'll need to integrate a zillion different programs that you can't guarantee will be installed on the host machine. On top of all that, there's also the fact that Vim doesn't have a real GUI, which limits you a lot. The juggling of configurations that a person needs to do in Vim to have a decent environment is simply overwhelming. Emacs may even have some horrible defaults, but that doesn't mean you have to install hundreds of 3rd party programs to make the program usable. The nail in Vim's coffin was evil-mode. It simply doesn't make sense to use Vim directly in the terminal if you can simply emulate Vim through evil-mode and still enjoy everything that the Lisp environment is capable of. I see a lot of pedantic lunatics here talking about Unix philosophy, as if it were a dogma or something, but even if it were a dogma, Emacs is still Unix compliant since it still only does one thing and does it very well: running Emacs Lisp code. >I don't need several irc clients, email clients, man page viewers, and 4 shells. Just let me pick the one I like and not have to carry around the bloat of the rest. They all serve different purposes, you should know that. Every program inside Emacs does one thing because that's how it is supposed to be. Don't forget that Emacs is an Emacs Lisp interpreter. Still, you can just disable what you don't like/want.
Chan Siu Ming · 2025-04-05 03:37
>>38719 I used to think the same, but I learned to run emacs in server-mode on remote servers and use emacsclient to open files. This way of using emacs on a server is very fast. If you're newish to emacs, it's not obvious how to set this up, but once it is set up, it's wonderful.
Jim Hilger · 2025-04-05 17:13
I found an obscure but potentially useful Elisp library a few days ago. It's a queue that has blocking operations such that if you try to read from an empty queue, it'll block. If you try to do this in the main thread of execution, your Emacs will lock up hard and C-g won't get you out of it. However, if you run it in a separate thread like in the example below, Emacs will remain perfectly responsive. I feel like this can be used to simplify the structure of some asynchronous code. https://github.com/smizoe/mpmc-queue https://melpa.org/#/mpmc-queue (require 'mpmc-queue) ;' ;; setup queue (defvar *channel* (mpmc-queue--create)) ;; setup a worker in a separate thread to consume the queue (defvar *worker* (make-thread (lambda () (while t (let* ((msg (mpmc-queue-get *channel*))) (message (pp-to-string msg))))))) ;; from the main thread, send it messages (mpmc-queue-put *channel* '(watch "g" 104859912)) ;' (mpmc-queue-put *channel* '(unwatch "jp" 49185654)) ;'
nil · 2025-04-05 17:20
>>41591 Since then, I've experimented with creating a rate-limited work pipeline. I really like what this queue is letting me do, and I also feel that Elisp's threads are underutilized. (require 'mpmc-queue) ;' (defvar in (mpmc-queue--create)) (defvar rate-per-second 0.5 "This is the maximum number of executions allowed per second.") (defvar rate-limiter (mpmc-queue--create)) (defvar out (mpmc-queue--create)) (defvar in-log (get-buffer-create "*in-log*")) (defvar out-log (get-buffer-create "*out-log*")) (defvar worker/in->rate-limiter (make-thread (lambda () (while t (let* ((msg (mpmc-queue-get in))) (with-current-buffer in-log (goto-char (point-max)) (insert (concat (format-time-string "%T.%3N") " " msg "\n")) (mpmc-queue-put rate-limiter msg))))) "worker/in")) (defvar worker/rate-limiter->out (make-thread (lambda () (while t (let* ((msg (mpmc-queue-get rate-limiter))) (mpmc-queue-put out msg) (sleep-for (/ 1.0 rate-per-second) )))) "worker/rate-limiter")) (defvar worker/out (make-thread (lambda () (while t (let* ((msg (mpmc-queue-get out))) (with-current-buffer out-log (goto-char (point-max)) (insert (concat (format-time-string "%T.%3N") " " msg "\n")))))) "worker/out")) To see it in action, feed the queue with something like this. (cl-loop for n from 1 upto 10 do (mpmc-queue-put in (format "%02d" n)))
Agent Smith · 2025-04-06 04:41
>>41292 As someone who recently moved to Emacs from using Vim for years, in my experience it was easy because I simply didn't install extensions or addons. I configured it to format code in a way I found pleasant and moved on, and programmed Python, C, C derivatives, and other languages just fine in it. I only really moved over to Emacs as a curiosity, and still don't use any large packages as I just don't need them for my Common Lisp or Scheme work. That said, the power behind Emacs is obvious and I agree with you that if you want a large "development environment" and not just a text editor, it's a no brainer over Vim. Any "IDE worthy" Vim installation is a bloated mess of horribly slow Vimscript, or faster but still haphazard Lua if you're running NeoVim. It's a fad that I find very confusing in the face of something as comprehensive and performant as Emacs, but honestly I think people just have LISP forms and prefer their "nice" Vimscript or Lua. Still use Vim for small file edits or servers, and still learning Emacs LISP because it's far less immediately clear to me than Common Lisp or Scheme ever were, but I'm getting there.
Chan Siu Ming · 2025-04-06 08:59
>>41593 >it was easy because I simply didn't install extensions or addons I agree with this 100%. I think these emacs "distributions" which ship with ship with 100+ packages are harmful for new users. Just using emacs as a text editor is straightforward, with the exception of the archaic default keybinds (copy on alt+w and paste on ctrl+y are terrible), there isn't a massive barrier to entry. For intermediate use, when a user gains more experience with emacs and wants to modify his config it's also easier to hack on a clean init.el (and that is where the true magic of emacs lies). I mainly used vim/vscode before switching to emacs. I tried spacemacs first, then a complex custom config with evil/other packages. Emacs only really clicked for me when I ditched all that, and learned to do things the emacs way before customizing it to my own needs.
John Doe · 2025-04-11 07:31
>>41596 The big distros are good for dealing with whiny bitches online who say things like: WHY CAN'T EMACS DO ____? In those situations, you throw something like Doom at them to show them that Emacs can do all that and more. There's value in making them shut up by demonstrating ability.
Neo · 2025-04-15 01:52
(defun insert-setq (variable) "Insert a setq expression for a VARIABLE into the current buffer. This is useful when hacking on variables that usually get their values via repeated calls to `add-to-list'. (That's OK for configuration, but annoying during development.) Example: \\[insert-setq] RET display-buffer-alist RET " (interactive "v") (let* ((data (eval variable)) (need-quote (if (eq (type-of data) 'cons) "'" "")) (point-a (point))) (insert (format "(setq %s %s%s)" (symbol-name variable) need-quote (pp-to-string data))) (let ((point-b (point))) (indent-region point-a point-b)))) I came up with this while I was debugging `display-buffer-alist`. In my config, the value of `display-buffer-alist` was built up incrementally using `add-to-list`, but while debugging, I just wanted to be able to setq its value repeatedly. M-x insert-setq RET display-buffer-alist RET
James K · 2025-04-15 02:49
>>41658 Damn that's smart. Reminds me of a lot of the old Smalltalk (and lisp) systems where you could look up the value of a variable and it would open in a GUI window that let's you edit it in real time. I wonder if it will ever be possible to edit the values displayed in *Help* buffers?
synchronized · 2025-04-15 03:49
>>41659 That sounds possible, but the most challenging part would be building a UI for it. It's challenging for me, anyway, because I haven't built many UIs. For just looking at big nested data structures, I've started using tree-inspector. http://elpa.gnu.org/packages/tree-inspector.html Its display code is a little buggy if you try to use it repeatedly, so I usually kill its buffer before running it again. When rendering a data structure to a fresh buffer, it's always been fine in my experience.
if · 2025-04-15 05:06
>>41659 isn't this what the customize interface does?
Dox · 2025-04-15 06:37
>>41662 I think he's looking for something more generalized.
Apoc · 2025-04-15 12:15
Whats the most basic setup that gives me a good lsp client and evil mode? Doom or space macs are too heavy. I want something light but don't want to spend my time tinkering.
cdr · 2025-04-15 17:40
>>41666 Emacs includes the Eglot LSP client since version 29, so I recommend that you have Emacs 29 or newer first. https://www.gnu.org/software/emacs/manual/html_mono/eglot.html#Quick-Start I don't know what languages you're programming in, but you're responsible for installing the external LSP server programs for the languages you work in yourself. Bare minimum evil config? (use-package evil :ensure t :init (setq evil-want-integration t) ;; This is optional since it's already set to t by default. (setq evil-want-keybinding nil) (setq evil-undo-system 'undo-fu) :config (evil-mode 1)) (use-package evil-collection :after evil :ensure t :config (evil-collection-init)) This bare minimum config is from the README of evil-collection. It's going to be missing a lot of creature comforts though. What I would recommend instead is getting Prot's basic config, and then adding the above evil configuration to it. https://protesilaos.com/codelog/2024-11-28-basic-emacs-configuration/ Scroll to the bottom for the full config.
Hacker · 2025-04-15 17:45
>>41670 I just noticed that undo-fu part which is something extra I added, but I recommend it. It's a sane and linear undo and redo that behaves the way you expect. Add this additional use-package expression to the config. (use-package undo-fu :ensure t)
Neuromancer · 2025-04-16 15:44
>>41670 Something that I'm surprised that Prot left out is which-key. It's a tremendous aid to command discovery, and I highly recommend it.
Turing · 2025-04-17 08:01
I need some advice. For the past year, I've been learning data structures in Elisp and making an Org Babel package for an SQL mode. So far, I’ve managed to get headers, different result formats, variable substitution, and async all working. I couldn’t use all the Babel mechanisms in ob-comint because I had to handle retrieval of query results and track states, sessions, and other stuff. So I wrote a separate package to keep track of source blocks, their positions, and so on. From these two packages, I got the idea to make another one when I saw yesql-cl (https://github.com/ruricolist/cl-yesql). I thought maybe I could use Babel to embed source blocks and execute them directly in Elisp from anywhere (not just using CALL), similar to how org-sbe does it. Then I got another idea and made yet another package that uses those three packages to build a new one, and so on. My question is: How many dependencies are too many? The more stuff I make that depends on my previous packages, the more uneasy I feel about whether it’s good practice to create a package that requires three or more other packages I made. Feels like a salesman trying to push my other products on a customer by “requiring” the use of all the other packages. tldr: made too many packages that depend on previous packages and worried if people don't like that level of dependency.
drop · 2025-04-17 17:58
>>41746 >How many dependencies are too many? >... >tldr: made too many packages that depend on previous packages and worried if people don't like that level of dependency. As long as the dependencies don't hog up too many resources, I wouldn't mind. Also, suppose I installed your package and later decided to uninstall it, leaving all those dependencies still lingering in my system. There are built-in ways to uninstall unused dependencies, so it's not a big deal. ;; See a list of unused dependencies (package--removable-packages) ;; Uninstall unused dependencies ;; M-x package-autoremove (package-autoremove) Source: https://emacs.stackexchange.com/questions/18253/how-does-package-autoremove-decide-which-packages-to-remove If you disagreed with the list `(package--removable-packages)` returned, you could manually `M-x package-delete` too.
Hagbard Celine · 2025-04-21 04:36
For orb-babel users, I highly recommend adding ob-async to your installation. It lets you add an `:async` keyword that will run the code asynchronously which means Emacs stays responsive. #+begin_src shell :async sleep 3 && echo done #+end_src Without ob-async, Emacs will block during that sleep. With ob-async, Emacs remains responsive. https://melpa.org/#/ob-async https://github.com/astahlman/ob-async
Delilah · 2025-04-22 07:09
>>41810 I looked into it a couple weeks ago and found that there's already an async mode built into babel, it was integrated through ob-comint and upstreamed in org 9.5, not for every mode though, I think I was implemented into ob-sh and ob-python, ob-ruby and ob-R The package that was up streamed was https://github.com/jackkamm/ob-session-async which was a fork of ob-async afaik.
Jim Hilger · 2025-04-23 03:18
>>41847 I didn't know about that. Thanks for the heads up.
Masami Eiri · 2025-04-23 12:55
I just discovered calc-fdiv. I believe the "fdiv" stands for "fractional division". It works like regular division except you get a fraction instead of a floating point value. Try inputting the following into `M-x calc`. 1080 2340 / 1080 2340 : I was trying to figure out what the aspect ratio for various screens were, and fractional division came in very handy.
Nguoi La · 2025-04-24 06:05
>>41810 >>41847 I think I found a bug in ob-async. I wonder if anyone else can reproduce this. You'll need an emacs configuration with and without ob-async to test this. * Define A Named Src Block #+name: double #+begin_src elisp :var n=1 (* n 2) #+end_src * CALL without ob-async loaded #+call: double(5) #+RESULTS: : 10 * CALL with ob-async loaded #+call: double(5) (From *Messages* buffer) apply: Wrong number of arguments: #<subr ob-async-org-babel-execute-src-block>, 5
Zuse · 2025-04-24 10:49
(defun md5sum (file) (with-temp-buffer (insert-file-contents-literally file) (md5 (current-buffer))))
Marly Krushkhova · 2025-04-30 10:21
My new favorite way of using jq is to write jq expressions in org-mode src blocks. https://github.com/ljos/jq-mode https://jqlang.org/ - Below is an org document with multiple jq expressions that work on the same JSON document. - The JSON can be found here: https://pastebin.com/UKtNrGGt . - The script that generated the JSON document is a slightly updated version of >>41961 . - To evaluate a src block, put your cursor anywhere inside the block and hit `C-c C-c`. - If you get sick of Emacs asking you if you're sure, `(setq org-confirm-babel-evaluate nil)`. * Prefectures #+begin_src jq :in-file apartments.json :cmd-line "-r" :wrap example csv [ .[] | {addr_prefecture} ] | sort | unique | .[] | .addr_prefecture #+end_src #+begin_src jq :in-file apartments.json :cmd-line "-r" :wrap example csv [ .[] | {addr_prefecture} ] | sort_by(.addr_prefecture) | group_by(.addr_prefecture) | map({count: length, prefecture: .[0].addr_prefecture}) | .[] | "\(.count)\t\(.prefecture)" #+end_src * Aichi #+begin_src jq :in-file apartments.json :cmd-line "-r" :wrap src json [ .[] | select(.addr_prefecture == "Aichi") ] | sort_by(.monthly_cost) #+end_src * Fukuoka #+begin_src jq :in-file apartments.json :cmd-line "-r" :wrap src json [ .[] | select(.addr_prefecture == "Fukuoka") ] | sort_by(.monthly_cost) #+end_src * Hokkaido #+begin_src jq :in-file apartments.json :cmd-line "-r" :wrap src json [ .[] | select(.addr_prefecture == "Hokkaido") ] | sort_by(.monthly_cost) #+end_src * Osaka #+begin_src jq :in-file apartments.json :cmd-line "-r" :wrap src json [ .[] | select(.addr_prefecture == "Osaka") ] | sort_by(.monthly_cost) #+end_src * Tokyo - I plan to break this down by city since there are a lot of properties in this prefecture. * Available Now #+begin_src jq :in-file apartments.json :cmd-line "-r" :wrap src json [.[] | select(.available_from == "Available Now")] | sort_by(.monthly_cost) #+end_src - Paging through the results manually would have been painful, so I decided to scrape the data and query it locally instead. - Now that I have the data locally, I can perform queries beyond what the web site's search feature allows as long as I can write a jq expression for it. - Writing jq expressions in Emacs is a lot more comfortable than writing jq expressions on the command line. - I can iterate a lot faster, and I feel more free to write complex multi-line expressions, because I'm in a proper editing environment and not just a command line.
Apoc · 2025-04-30 11:29
>>41666 On the LSP front, I'm a little jealous of Helix. LSP just works there, and it's fast by default. Editing the same big JSON document using the same LSP server, Emacs+Eglot is so much slower than Helix. It's so bad that I have to `M-x eglot-shutdown`. I know they're working on introducing Scheme as an extension language. I hope that works out well for them, and I hope they can take what's good from Emacs and Elisp and bring it to their own editor. (Put docstrings on everything, please!) https://github.com/mattwparas/helix https://github.com/mattwparas/helix/blob/a9d5557a3b3c11767432bdacd36ccb3bea02bfa5/STEEL.md
renames · 2025-05-01 03:41
>>41876 If you look at the GitHub issues and pull requests for ob-async, I think there are fixes for this that haven't been merged.
Dujour · 2025-05-01 05:09
babbies first emacs lisp function (defun de-re () "Shortcut to desktop-read" (interactive) (desktop-read))
Nobody special · 2025-05-01 07:52
>>41978 If you're just making alternate names, you can save a stack frame by using defalias. (defalias #'de-re #'desktop-read "Shortcut to `desktop-read'.")
Lain Iwakura · 2025-05-02 12:30
>>41978 What helped me accelerate my Elisp education was to make frequent use of `C-h f` and `C-h v` whenever I was curious about anything Emacs-related. I also like exploring via typing code into `M-x ielm`. Learn to ask Emacs questions about itself, and it can tell you a lot.
Nameless · 2025-05-03 07:30
>>41984 Thanks Lain, I've added that defalias in. Now, newb question, but what's a stack frame? >>41995 Yeah, the C-h * functions are really useful for learning Emacs functions. For elisp itself though, I've been reading Bob Chassell's Introduction to Programming in Emacs Lisp (https://www.gnu.org/software/emacs/manual/pdf/eintr.pdf). It's definitely really simple to get into, and worth the read.
cdr · 2025-05-03 10:55
>>42005 >Now, newb question, but what's a stack frame? In most languages, when you run a program, some memory is set aside for remembering where you were in the code before calling a function. This is called the stack. - When you call a function, the address of the current location in code is pushed on to the stack. - When you return from a function, the address in the stack is read, jumped to, and popped off the stack. - The "frame" part of "stack frame" comes from how some languages also store local variables in the stack, so the contents of the stack for one function call is a return address + local variables which got the name "stack frame". ## The Difference Between Wrapping In Defun Versus Using Defalias - When you created the function de-re which wrapped the function desktop-read, those are two distinct functions. - Thus, calling this version of de-re adds two stack frames to the stack -- one for de-re and one for desktop-read. - However, when you use defalias to define de-re, de-re and desktop-read are the exact same function. - Calling this version of de-re only adds one stack frame to the stack. ## Tangent: Stack Overflow - A stack overflow is when the finite amount of memory set aside for the stack is used up. - This is often caused by buggily implemented recursive functions that don't terminate as intended. - Tail call optimization prevents the stack from blowing up, and it's an important feature for languages that rely on recursion for most of their looping.
Otto Normalverbraucher · 2025-05-03 12:53
>>42005 >https://www.gnu.org/software/emacs/manual/pdf/eintr.pdf C-h R eintr RET
Jean Dupont · 2025-05-06 07:37
Prot wrote a book on Elisp recently. https://protesilaos.com/emacs/emacs-lisp-elements It's available in other formats as well. https://github.com/protesilaos/emacs-lisp-elements
Elliot Alderson · 2025-05-06 13:59
>>42053 >be greek >call your book "Elements" for fuarrrk's sake
Wintermute · 2025-05-07 01:55
>>42019 Info-find-file: Info file ‘emacs’ does not exist; consider installing itInfo-find-file: Info file ‘emacs’ does not exist; consider installing it I think Debian packages it somewhere, but I think it's just easier to use docview. >>42015 Huh. Thanks for the detailed write up Lain. Is memory management something you often have to worry about with Elisp?
string · 2025-05-07 07:20
>>42060 >Huh. Thanks for the detailed write up Lain. Is memory management something you often have to worry about with Elisp? You do have to be mindful of the stack in when you use recursion in Elisp, because it doesn't implement tail call optimization on regular functions. However, there is a way to get tail call optimization if you use named-let. https://arnesonium.com/2022/11/pattern-matching-tail-recursion-emacs-lisp PS: I wouldn't call it "memory management" in this case, because that term is usually reserved for dynamic memory allocation/deallocation from the heap and nothing to do with the stack. If you asked a random Elisp programmer whether you have to worry about memory managment in Elisp, the answer would be "No," because Elisp is garbage collected (meaning memory allocations/deallocations from the heap happen automatically).
St. IGNUcius · 2025-05-07 08:15
>>42060 >Info-find-file: Info file ‘emacs’ does not >I think Debian packages it somewhere On Debian and Debian derivatives, you need to install emacs-common-non-dfsg package. You may also need the texinfo package. You can also alternatively use GNU Guix package manager to get Emacs: * Go to Guix Site and find the manual: https://guix.gnu.org/manual/devel/en/guix.html#Installation * Run the installer script and accept defaults. * Install Emacs: guix install emacs (you don't need to use sudo when you want to install it for your user)
Spike Spiegel · 2025-05-09 08:19
>>42060 >but I think it's just easier to use docview. If you're going to read PDFs in Emacs, I highly recommend setting up pdf-tools. It renders documents more accurately and beautifully, especially when it comes to fonts. This is my config. (use-package pdf-tools :ensure t :hook ((pdf-view-mode . pdf-view-themed-minor-mode) (pdf-view-mode . pdf-view-fit-page-to-window)) :config (pdf-tools-install)) pdf-view-themed-minor-mode is totally optional, but I like it a lot for monochrome PDF documents, because it makes the document match the colors of your current emacs theme.
Armitage · 2025-05-13 06:15
>>42055 He's not done with his elements yet. Check out his new themes. https://protesilaos.com/codelog/2025-05-13-emacs-doric-themes/
Nemissa · 2025-05-24 06:49
>>42064 >guix I forget, but isn't that source based? >>42081 I have tried to use pdf-tools, and it definitely is easier and nicer to use, but the fact that desktop-save doesn't save your position in it is a dealbreaker for me ;_;
Sabo Engle · 2025-05-24 07:04
>>42178 >>guix >I forget, but isn't that source based? Technically no, but counting all of the severely outdated packages you can count it as source based kek
over · 2025-05-28 10:59
(apply #'color-rgb-to-hex (append (color-complement "#ffffff") '(2))) ;; => "#000000"
Jim Hilger · 2025-05-28 12:21
I just discovered something built-in and super useful. https://emacs.stackexchange.com/questions/21180/is-there-a-way-to-show-open-a-file-from-a-uri-url - url-handler-mode :: This is a global minor mode that let's you load URLs with `C-x C-f` (aka find-file) - global-goto-address-mode :: This is a global minor mode that makes URLs in the buffer clickable. - goto-address-mode :: This is a regular minor mode version in case you prefer to only use it sometimes.
Spike Spiegel · 2025-05-31 20:53
>>41659 >Reminds me of a lot of the old Smalltalk (and lisp) systems where you could look up the value of a variable and it would open in a GUI window that let's you edit it in real time. If you're writing Common Lisp and you have Sly or Slime setup, that functionality already exists. Just pull up the inspector. M-x sly-inspect M-x slime-inspect It's an Emacs window and not a GUI window but close enough.
Leto Atreides I · 2025-06-02 21:25
>>42253 It better be >flood detected, post discarded Total soykaf, but heres a simple Diffie-Hellman key exchange simulator I wrote today. I haven't been bothered to automate everything yet. ;; Diffie-Hellman-Merkle key exchange simulator (defun random-prime (min max) "Generate a random prime number between MIN and MAX." (let* ((min (or min 2)) (max (or max 1000)) (candidates (cl-remove-if-not #'primep (number-sequence min max))) (count (length candidates))) (if (zerop count) (error "No primes found in range %d to %d" min max) (nth (random count) candidates)))) (defun primep (n) "Check if N is a prime number." (cond ((< n 2) nil) ((= n 2) t) ((zerop (% n 2)) nil) (t (let ((limit (1+ (floor (sqrt n))))) (cl-loop for i from 3 to limit by 2 never (zerop (% n i))))))) (defun smallest-unsigned-num-by-bit-length (n) "Return the smallest unsigned number that uses exactly N bits." (if (<= n 0) 0 (ash 1 (1- n)))) (setq limit 1000) (setq g (abs (random limit))) ;; generator (setq n (abs (random-prime 2 limit))) ;; AKA P, large prime number (setq a (abs (random limit))) ;; Alice's secret key (setq b (abs (random limit))) ;; Bob's secret key (setq A (mod (expt g a) n)) ;; Alice's public shared secret (setq B (mod (expt g b) n)) ;; Bob's public shared secret (setq alice-s (mod (expt B a) n)) (setq bob-s (mod (expt A b) n)) (message "Alice's secet is %d" alice-s) (message "Bob's secret is %d" bob-s) (if (= alice-s bob-s) (message "Bob and Alice have a shared secret!!") (message "Bob and Alice's secrets are different."))
roll · 2025-06-06 19:04
>>42254 I gave it a try for fun. It's very neatly written.
DEBUG-CONTENTS · 2025-06-11 19:17
;; Have you ever wanted to edit the current URL and load it while using eww? ;; It's something I've wanted to do often. ;; Now I can. ;; Also, if you give it a prefix argument, it'll open the URL in a new buffer ;; just like regular `M-x eww'. ;; C-u M-x eww-edit-url RET new-url RET (defun eww-edit-url (&optional url) "Edit the current URL and go to it with eww." (interactive (let* ((current-url (if eww-data (plist-get eww-data :url)))) (list (read-string "URL: " current-url nil current-url)))) (eww url current-prefix-arg))
Trinity · 2025-06-11 19:52
>>42368 (defun eww-edit-url (&optional url) "Edit the current URL and go to it with eww." (interactive (let* ((current-url (or (if eww-data (plist-get eww-data :url)) (thing-at-point 'url)))) (list (read-string "URL: " current-url nil current-url)))) (message "%s !!!" url) (eww url current-prefix-arg)) - I let (thing-at-point 'url) act as a secondary default value for the URL. - That means you can be in any buffer with a URL in it, and if your cursor is in the URL, it'll be used as the target for eww.
Tomohisa "Tom" Kanezaki · 2025-07-06 06:55
Why does this work in Elisp? I thought you had to use funcall. ((lambda () (+ 1 2)))
Rick Deckard · 2025-07-06 09:17
>>42545 I'm no elisp expert, but in common lisp, at least, the first element in a form can be either a function name or a lambda form.
quote · 2025-07-06 13:32
>>42545 (info "(elisp) Function Indirection") By contrast, the following example calls a function without any symbol function indirection, because the first element is an anonymous Lisp function, not a symbol. ((lambda (arg) (erste arg)) '(1 2 3)) ⇒ 1 Executing the function itself evaluates its body; this does involve symbol function indirection when calling ‘erste’. This form is rarely used and is now deprecated. Instead, you should write it as: (funcall (lambda (arg) (erste arg)) '(1 2 3)) or just (let ((arg '(1 2 3))) (erste arg))
Drifter · 2025-07-09 04:07
I'm not sure where else to ask this but I'm pretty new to emacs so this might be a mistake on my end, I just can't figure for the life of me how to get this solved I've got the following markup in this org file * TODO Task to do SCHEDULED: <2025-07-09 Wed +1d> but when I mark it as DONE via C-c C-t it just won't get set back to TODO no matter what I try I've already set (setq org-todo-repeat-to-state ...) to both t and "TODO" but it just won't fuarrrking work, it seems to be an unique problem as most of the stuff that I've found online were just silly mistakes such as forgetting to set org-todo-repeat-to-state or using the wrong key to get it marked as DONE. I've also tried setting the :REPEAT_TO_STATE: TODO property but that doesn't work either.
Shogun · 2025-07-09 11:46
>>42567 Try `emacs -q` if it works with Emacs that has no config loaded, then it's the fault of your config. Then just binary chop this bitch.
Church · 2025-07-10 03:21
>>42572 Thanks a lot :-D my org config was just 26 LoC and very simplistic so out of idiocy I just assumed that there's no way there's something wrong with it. The problem was apparently in org-todo-keywords, they only mark the last keyword as DONE but I seem to have skipped over that while reading it. Thanks again, this problem was a huge burden and seeing that it only happened to me was even more annoying.
Haruyoshi · 2025-07-10 10:55
I want to use my Emacs for Java programming, but I'm overwhelmed by Emacs plugins to choose from. Which one is the best for beginners to choose from? I don't have any special requirements other than being able to program Java in Emacs.
↑ · 2025-07-10 11:58
>>42574 As of right now, your only viable option is to use a LSP (https://xpressrazor.wordpress.com/2020/11/04/java-programming-in-emacs/). Other options like JDEE, emacs-eclim or megahanda are abandoned or even no longer supported.
Tomohisa "Tom" Kanezaki · 2025-07-11 04:59
Is it possible to make imenu work with info manuals in Emacs. I think it could improve info manual navigation a lot if such a thing were possible. If not, maybe a function like consult-info-section could be written such that you could jump to any node in the current info document via consult (if you're a consult user).
let · 2025-07-19 12:13
Have you ever mostly liked a theme except for a few minor things? The following is a solution I came up to solve that problem. - i/tweak-themes is a function that is added as an :after advice to load-theme that applies changes found in my/theme-tweaks. - my/theme-tweaks is a variable containing an alist where the keys specify the theme and the values are a function. (defun match-symbol-or-regexp (given test) "See if the GIVEN symbol matches the TEST pattern. The TEST pattern may be a symbol or a regexp." (if (symbolp test) (eq given test) (let* ((s (format "%s" given))) (string-match-p test s)))) (defun i/tweak-themes (theme &optional no-confirm no-enable) "Apply custom theme modifications as defined in `my/theme-tweaks'. THEME is the main parameter I care about. NO-CONFIRM doesn't matter to this. NO-ENABLE might though. Maybe don't do anything if NO-ENABLE is true." (message "theme: %s, no-confirm: %s, no-enable: %s" theme no-confirm no-enable) (if-let* ((enabled (not no-enable)) (tweaks (mapcar #'cdr (cl-remove-if-not (lambda (test.fn) (match-symbol-or-regexp theme (car test.fn))) my/theme-tweaks)))) (progn (message "tweaks: %s" tweaks) (cl-loop for th in tweaks do (funcall th))))) (advice-add 'load-theme :after 'i/tweak-themes) My config currently looks like this. The key can either be a symbol that matches the exact theme or a regexp that can match multiple themes. (defvar my/theme-tweaks `((kanagawa-wave . ,(lambda () (my/tab-bar :background "#0d1b1e" :foreground "#c5e99b") (set-face-attribute 'org-document-title nil :foreground "#89b4fa") (set-face-attribute 'org-block nil :background "#242024") (set-face-attribute 'comint-highlight-prompt nil :background 'unspecified :foreground "#89b4fa"))) (kanagawa-dragon . ,(lambda () (my/tab-bar :background "#0d1b1e" :foreground "#c5e99b") (set-face-attribute 'org-document-title nil :foreground "#ade25d") (set-face-attribute 'org-block nil :background "#242024") (set-face-attribute 'comint-highlight-prompt nil :background 'unspecified :foreground "#ade25d"))) ;; Apply to all kanagawa- themes. ("^kanagawa-" . ,(lambda () (set-face-italic 'font-lock-keyword-face nil))) (uwu . ,(lambda () (my/org-faces) (my/shr-faces))) (south . ,(lambda () (my/tab-bar :background "#7798aB" :foreground "#0d1b1e") (my/org-faces) (highlight-indent-guides-mode -1) )) ;; Apply to all ef- themes. ("^ef-" . ,(lambda () (my/org-faces) (my/shr-faces) (my/info-faces))) (ef-dream . ,(lambda () (set-face-attribute 'org-done nil :foreground "#7777bb"))) ;; Apply to all kaolin- themes. ("^kaolin-" . ,(lambda () (my/org-faces) (my/shr-faces) (my/info-faces))) (catppuccin . ,(lambda () (my/org-faces)))) "This is an alist that defines theme-specific changes. The keys are theme names, and the values are functions that apply these changes.") Something else that I strongly recommend is disabling previously loaded themes before loading a new theme. In Emacs, you're allowed to load more than one theme at a time, and what ends up happening is that they bleed into each other. I work around that with the following. ;; https://www.reddit.com/r/emacs/comments/30b67j/comment/cpqug8q/ ;; [2025-03-26 Wed 09:53] rewritten to use advice-add (defun i/disable-loaded-themes (theme &optional no-confirm no-enable) "Disable any loaded themes before enabling a new THEME. This prevents overlapping themes; something I would rarely want. THEME, NO-CONFIRM, and NO-ENABLE are ignored in this advice function." (dolist (theme custom-enabled-themes) (disable-theme theme))) (advice-add 'load-theme :before 'i/disable-loaded-themes)
Nell · 2025-07-19 15:49
>>42578 I don't follow. Info-mode starts in narrowed buffer to give the "ilusion" of chunks, then it moves the narrowing to the next chapter. Imenu seems orthogonal to that functionality, because it returns an alist of indexes in a file and it's names. Also, I belive this functionality exists via 'g' when you are in info buffer, there you can choose the node that interests you, and since it uses autocompletion (though I don't know since I use the default) the sane framework should be able to use it.
Vasya Pupkin · 2025-07-19 18:17
>>7275 I'm a Vimcel but yes for the love of god do not use Vimscript for anything more than 5 lines. Transpile to it if you need to.
Erik Johansson · 2025-07-30 01:29
>>42638 I discovered Info-toc. This is close enough to how I want to navigate info docs. I wanted to be able to see a structural outline of the info doc for navigation purposes.
progn · 2025-07-30 01:35
I discovered a nice way to create tables in org-mode. #+startup: indent * org-table-convert-region - Start with some CSV. - Select it to create a region. - C-u M-x org-table-convert-region =before= face,background,other tab-bar,medium tab-bar-tab,darkest,bold tab-bar-tab-group-current,darkest,bold+colored tab-bar-tab-group-inactive,medium,colored tab-bar-tab-inactive,lightest tab-bar-tab-ungrouped,lightest =after= | face | background | other | |----------------------------+------------+--------------| | tab-bar | medium | | | tab-bar-tab | darkest | bold | | tab-bar-tab-group-current | darkest | bold+colored | | tab-bar-tab-group-inactive | medium | colored | | tab-bar-tab-inactive | lightest | | | tab-bar-tab-ungrouped | lightest | |
setq · 2025-08-01 04:53
>>42637 I realize now that the work I was doing with i/disable-loaded-themes (which was good) was being undone by my own code that was calling set-face-attribute which reintroduced bleed through when changing themes. <SOLUTION The solution I arrived at was to use custom-theme-set-faces to apply theme specific changes. Unfortunately, it wasn't possible to just set one attribute of a face and leave everything else alone. If an attribute were left unset, it would blast it away with a default value which I believe was 'unspecified. That was such an unhelpful behavior, so I ended up writing a wrapper around custom-theme-set-faces called ctsf that: - changes the attributes you specify and leaves everything else alone - simplifies the parameters you need to send (to suit my default use case) ;;;; ctsf system ;; Thanks to github copilot for this one. (defun alist-to-plist (alist) "Convert ALIST to a plist." (apply #'append (mapcar (lambda (pair) (list (car pair) (cdr pair))) alist))) ;; https://emacs.stackexchange.com/a/5630/37580 (defun plist-merge (&rest plists) "Merge PLISTS together." (if plists (let ((result (copy-sequence (car plists)))) (while (setq plists (cdr plists)) (let ((plist (car plists))) (while plist (setq result (plist-put result (car plist) (car (cdr plist))) plist (cdr (cdr plist)))))) result) nil)) (cl-defun merge-face-spec (face new-spec) "Merge the existing spec for FACE with the given NEW-SPEC." (let* ((attrs (face-all-attributes face (selected-frame))) (old-spec (alist-to-plist attrs)) (spec (plist-merge old-spec new-spec))) spec)) (cl-defun ctsf (theme &rest face-specs) "Expand FACE-SPECS for THEME and apply `custom-theme-set-faces'." ;;(message "t %s f %s" theme face-specs) (let* ((full-specs (mapcar (lambda (spec) ;; (face new-spec) => ;; (face ((t full-attrs)) t) (pcase-let* ((`(,face ,new-spec) spec) (full-attrs (merge-face-spec face new-spec))) `(,face ((t ,full-attrs)) t))) face-specs))) ;; (message "full-specs %s" full-specs) (apply #'custom-theme-set-faces (append (list theme) full-specs)))) More on this later....
Agent Jones · 2025-08-04 03:22
>>42698 - A lot of older themes don't customize faces for tab-bar-* and fringe. - I notice this often, because I use tab-bar-mode which makes use of the tab-bar-* faces and olivetti-mode which makes use of the fringe face. - The theme in the screenshots is gotham is a good example of such a theme. - I used my ctsf system to fix gotham like this. ;; fix the most common theme deficiencies (setq my/theme-tweaks `((gotham . ,(lambda () (my/fringe) (my/tab-bar-auto :percent 50.0))) )) The code for my/fringe uses ctsf to configure the fringe correctly for the current theme. (cl-defun my/current-theme () "Return the currently loaded theme." (car custom-enabled-themes)) (cl-defun my/fringe (&key (theme (my/current-theme))) "Make the fringe background the same as the default for the current THEME." (interactive) (let* ((default (face-all-attributes 'default (selected-frame))) (bg (plist-get :background default))) (ctsf theme `(fringe (:background ,bg))))) The code for my/tab-bar-auto is a bit more involved. In addition to introspecting the current theme for colors, it also does some color math to pick appropriate colors for the tab-bar faces. This uses ctsf also. (cl-defun my/tab-bar-auto (&key (percent 35.0)) "Setup appropriate tab-bar-* faces varying, color brightness by PERCENT." (interactive) (let* ((default (custom-face-get-current-spec 'default)) (dflt (cadar default)) (theme (car custom-enabled-themes)) (bg (plist-get dflt :background)) (fg (plist-get dflt :foreground)) (dark? (equal 'dark (color-light-or-dark-hex bg)))) ;;(message "theme %s bg %s dark? %s" theme bg dark?) (if dark? (let* ((medium (color-lighten-hex bg percent)) (lightest (color-lighten-hex medium percent))) (ctsf theme `(tab-bar (:background ,medium :foreground ,fg)) `(tab-bar-tab (:background ,bg :foreground ,fg)) `(tab-bar-tab-group-current (:background ,bg :foreground ,fg)) `(tab-bar-tab-group-inactive (:background ,medium :foreground ,fg)) `(tab-bar-tab-inactive (:background ,lightest :foreground ,fg)) `(tab-bar-tab-ungrouped (:background ,lightest :foreground ,fg)))) (let* ((medium (color-darken-hex bg percent)) (darkest (color-darken-hex medium percent))) (ctsf theme `(tab-bar (:background ,medium :foreground ,fg)) `(tab-bar-tab (:background ,bg :foreground ,fg)) `(tab-bar-tab-group-current (:background ,bg :foreground ,fg)) `(tab-bar-tab-group-inactive (:background ,medium :foreground ,fg)) `(tab-bar-tab-inactive (:background ,darkest :foreground ,fg)) `(tab-bar-tab-ungrouped (:background ,darkest :foreground ,fg))) )))) I had to write a few more color functions that I'd like to contribute to the built-in color.el eventually. I really like what color.el provides, but I feel like it's missing a few functions that would make it tremendously more useful to theme authors. The most common color format used in themes is the RGB hex format (like #ff0022), and I needed to add a few more functions to help me directly work with colors in this format. (defun color-hex-to-rgb (color) "Transform a hex encoded COLOR to individual RGB components." (let* ((_ (string-match (rx "#" (group (= 2 hex-digit)) (group (= 2 hex-digit)) (group (= 2 hex-digit))) color)) (r (cl-parse-integer (match-string 1 color) :radix 16)) (g (cl-parse-integer (match-string 2 color) :radix 16)) (b (cl-parse-integer (match-string 3 color) :radix 16))) (mapcar (lambda (n) (/ n 255.0)) `(,r ,g ,b)))) (defun color-lighten-hex (color percent) "Make a COLOR lighter by the specified PERCENT." (let* ((rgb (color-hex-to-rgb color)) (hsl (apply #'color-rgb-to-hsl rgb)) (hsl-light (apply #'color-lighten-hsl (append hsl `(,percent)))) (rgb-light (apply #'color-hsl-to-rgb hsl-light)) (rgb-normal (mapcar (lambda (n) (* n 255.0)) rgb-light))) (apply #'format (cons "#%02x%02x%02x" rgb-normal)))) (defun color-darken-hex (color percent) "Make a COLOR darker by the specified PERCENT." (color-lighten-hex color (- percent))) ;; ported this python function ;; https://stackoverflow.com/a/58270890 (defun color-light-or-dark-hex (hex) "Return whether the HEX color is light or dark." (pcase-let* ((`(,r ,g ,b) (color-hex-to-rgb hex)) (hsp (sqrt (+ (* 0.299 (* r r)) (* 0.587 (* g g)) (* 0.114 (* b b)))))) (if (> hsp 0.5) 'light 'dark))) Summary: - I originally used set-face-attribute, but that approach was too global and made it hard to isolate changes to one theme. - I then tried using custom-set-theme-faces instead, but its default behavior was to completely overwrite faces. - I wrote ctsf to wrap custom-set-theme-faces such that it preserved existing face attributes and only changed what you specified. Finally, I was able to isolate changes to a theme, and provide a system for safely customizing and fixing existing themes.
Otto Normalverbraucher · 2025-08-04 03:46
>>42698 My full customization for gotham currently looks like this. ;; enhance the theme even more (setq my/theme-tweaks `((gotham . ,(lambda () (my/fringe) (my/tab-bar-auto :percent 69.0) (my/org-faces) (ctsf 'gotham '(org-block (:background "#10161c" :inherit unspecified))) (my/shr-faces) (my/info-faces))) )) - Beyond fixing deficiencies, I like to enhance too. - I'm glad that I have a system in place that lets me do this in a reliable way. - I feel like if I cleaned this up, I could have something worth putting up on MELPA.
protected · 2025-08-04 06:22
>>42726 - The various my/*-faces functions just change heading sizes using the ctsf function. - I used to do this with set-face-attribute, but that unintentionally interfere with other themes. (cl-defun my/shr-faces (&key (theme (my/current-theme))) "Set heading sizes for the current THEME for shr-h*." (interactive) ;; heading sizes (ctsf theme '(shr-h1 (:height 2.5 :weight bold)) '(shr-h2 (:height 1.5 :weight bold)) '(shr-h3 (:height 1.2 :weight bold)))) ;; https://emacs.stackexchange.com/a/75240/37580 (cl-defun my/org-faces (&key (theme (my/current-theme))) "Customize org-* faces for current THEME." (interactive) (ctsf theme '(org-document-title (:height 2.5 :weight bold)) '(org-level-1 (:height 1.5)) '(org-level-2 (:height 1.2)))) (cl-defun my/info-faces (&key (theme (my/current-theme))) "Customize info-* faces for current THEME." (interactive) (ctsf theme '(info-title-1 (:height 2.5)) '(info-title-2 (:height 1.5)) '(info-title-3 (:height 1.2)) '(info-menu-header (:height 1.4)))) (cl-defun my/markdown-faces (&key (theme (my/current-theme))) "Customize markdown-* faces for current THEME." (interactive) (ctsf theme '(markdown-header-face-1 (:height 2.5)) '(markdown-header-face-2 (:height 1.5)) '(markdown-header-face-3 (:height 1.2))))
Emmanuel · 2025-08-15 03:45
Emacs 30.2 was released yesterday. https://github.com/emacs-mirror/emacs/releases/tag/emacs-30.2 https://www.gnu.org/savannah-checkouts/gnu/emacs/news/NEWS.30.2 The NEWS file isn't very informative, but git can fill in the blanks. https://github.com/emacs-mirror/emacs/compare/emacs-30.1...emacs-30.2
Ender · 2025-08-23 02:14
I found something interesting. There is a elisp package that can be used to show the diff of elisp source during package upgrades. >https://github.com/kn66/package-upgrade-guard.el But it's not in elpa, nongnu or melpa, yet. How do I install it from git? Do I just clone the repo to ~/.emacs.d and add (add-to-list 'load-path "~/.emacs.d/foobar") to my .emacs config?
Stallman · 2025-08-23 02:39
>>42835 That would work, but if you have an Emacs 30+, you can just use the code snippet from the README that'll `git clone` for you. (use-package package-upgrade-guard :vc ( :url "https://github.com/kn66/package-upgrade-guard.el.git" :rev :newest) :config (package-upgrade-guard-mode +1)) https://tony-zorman.com/posts/use-package-vc.html
↑ · 2025-09-02 14:10
The paredit.org domain expired a few days ago. https://archive.is/KtoJp (Archive) https://github.com/emacsmirror/paredit/ (Git Mirror)
Jens Hansen · 2025-09-03 02:06
>>42835 This (or something like this) might also be merged into Emacs: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74604#41
Lunch · 2025-09-06 01:23
>>42889 >The paredit.org domain expired a few days ago. It's back.
Alyosha · 2025-09-07 20:58
>>10641 I agree with this. I first tried emacs with doom, and it just complicated me. The "better defaults" one is pretty good, only like 50 lines i think. But I can only say that now that I know what the code is doing. >>10665 spacemacs? lol.
if · 2025-09-21 23:58
>>42931 >spacemacs When it first came out, it pulled a lot of people into Emacs, because it made Emacs look sexy for once. The space menu also proved very popular, and a lot of people copied it. Give Spacemacs some credit where it's due.
Church · 2025-09-28 02:27
>>42931 I also moved from doom to vanilla. But at the same time if there was no doom I may never have actually tried emacs from vim. The low time investment and fanciness is definitely helpful for making the first switch, although i agree i wouldn't want to use it long term.
typedef · 2025-10-01 06:09
>>43226 I always end up being to ambitious with my vanilla config so I never completely move away from doom. I think this is the 4th time I've started migrating and then end up coming back. My biggest stopper is movement, I want to go fill vanilla keybinds and maybe Meow in the future. But I'm so used to evil that it's incredibly clunky doing work as always. Any tips on migrating?
list · 2025-10-01 06:50
>>43262 One thing that helped me is putting it all in a giant org file and documenting everything so that when I want to change a part years later i can easily find where to go and how to change it. Also remember that you have all of emacs lisp so you can make your own frameworks for certain parts of your configuration to keep things systemic. For evil I still use it when programming in non-lisp languages, I guess i wouldn't conflate moving to vanilla with giving up evil.
Armitage · 2025-10-21 11:55
Here's a small quality-of-life improvement that I should have done a long time ago. When you try to open a webm or mp4 through dired, Emacs will open it with mpv in the background if you have this config. (use-package dired-open :ensure t :config (setq dired-open-extensions `(("webm" . "mpv") ("mp4" . "mpv")))) https://melpa.org/#/dired-open https://github.com/Fuco1/dired-hacks?tab=readme-ov-file#dired-open
Joey · 2025-11-24 17:26
>>41658 ;; https://boards.4chan.org/g/thread/104995871/#p105038803 ;; https://desuarchive.org/g/thread/104995871/#105038803 (defun insert-setq (variable) "Insert a setq expression for a VARIABLE into the current buffer. This is useful when hacking on variables that usually get their values via repeated calls to `add-to-list'. (That's OK for configuration, but annoying during development.) Example: \\[insert-setq] RET display-buffer-alist RET " ;; [2025-05-08 Thu 22:47] The interactive expression was shamelessly copied from describe-variable. (interactive (let ((v (variable-at-point)) (enable-recursive-minibuffers t) (orig-buffer (current-buffer)) val) (setq val (completing-read (format-prompt "Insert variable" (and (symbolp v) v)) #'help--symbol-completion-table (lambda (vv) (or (get vv 'variable-documentation) (and (not (keywordp vv)) ;; Since the variable may only exist in the ;; original buffer, we have to look for it ;; there. (buffer-local-boundp vv orig-buffer)))) t nil nil (if (symbolp v) (symbol-name v)))) (list (if (equal val "") v (intern val))))) (let* ((data (eval variable)) (need-quote (if (eq (type-of data) 'cons) "'" "")) (point-a (point))) (insert (format "(setq %s %s%s)" (symbol-name variable) need-quote (pp-to-string data #'pp-28))) (let ((point-b (point))) (indent-region point-a point-b)))) Here's an updated version of insert-setq. >Changes - Completion list code was ported from describe-variable. - pp-28 is used to ensure better looking data serialization. >Try it out. - In the *scratch* buffer, do: M-x insert-setq RET ffap-alist RET
Ein · 2025-11-30 05:02
Improved paredit navigation for evil users: (setq evil-move-beyond-eol t) ;; Integrate paredit navigation commands in a vi style. (evil-define-key '(normal visual) paredit-mode-map ;; paredit function overriden evil function ;; ---------------- ----------------------- ")" #'paredit-forward ; evil-forward-sentence-begin "(" #'paredit-backward ; evil-backward-sentence-begin "]" #'paredit-forward-down ; evil-forward-section-begin "[" #'paredit-backward-down ; evil-backward-section-begin "}" #'paredit-forward-up ; evil-forward-paragraph "{" #'paredit-backward-up ; evil-backward-paragraph ) NOTE: evil-move-beyond-eol must be set to t for many of the paredit-navigation functions to work. image credit: https://xcancel.com/_iori_xx21/status/1995058288682295566
Wintermute · 2025-12-19 02:54
>>7270 I found the perfect note-taking system. It's called howm. It's simple and easy, similar to a personal Wiki. >https://github.com/kaorahi/howm Tutorials: * https://emacs101.github.io/howm.html * https://leahneukirchen.org/blog/archive/2022/03/note-taking-in-emacs-with-howm.html
Aristóteles Amadópulus · 2026-01-18 18:15
I made it on to MELPA for the first time. https://melpa.org/#/info-nav https://codeberg.org/ggxx/info-nav The purpose of this package is to make info documents easier to navigate by making the table of contents drive navigation. Even an Emacs novice who doesn't know Emacs keybindings can point and click his way through info docs without getting lost.
Unknown · 2026-01-20 07:56
A new documentation site for Emacs has been created. He provides a nice sidebar for the docs that helps you navigate those big info files. https://doc.emacsen.de/
setq · 2026-01-21 19:28
Have you ever wanted to know the Chinese Zodiac element and animal for a given year? Every time a new year rolls around, I inevitably end up looking this up, and in the back of my mind, I knew this could easily be computed. Today, I finally decided to get this figured out. (defvar cz-animals '(rat ox tiger rabbit dragon snake horse goat monkey rooster dog pig) "These are the 12 animals of the Chinese Zodiac.") (defun cz-animal (year) "Return Chinese Zodiac animal for YEAR." (let* ((offset (mod (- year 4) 12))) (nth offset cz-animals))) (defvar cz-elements '(wood fire earth metal water) "These are the 5 elements of the Chinese Zodiac.") (defun cz-element (year) "Return Chinese Zodiac element for YEAR." (let* ((offset (/ (mod (- year 4) 10) 2))) (nth offset cz-elements))) (defun cz-sign (year) "Return the Chinse Zodiac element and animal sign for the given YEAR." (list (cz-element year) (cz-animal year))) In org-mode, you could create a src block like the following. #+begin_src elisp (let* ((range (number-sequence 2025 2050 1)) (signs (-zip range (mapcar #'cz-sign range)))) (append (list '("year" "element" "animal") 'hline) signs)) #+end_src Evaluating it would create a table like this. | year | element | animal | |------+---------+---------| | 2025 | wood | snake | | 2026 | fire | horse | | 2027 | fire | goat | | 2028 | earth | monkey | | 2029 | earth | rooster | | 2030 | metal | dog | | 2031 | metal | pig | | 2032 | water | rat | | 2033 | water | ox | | 2034 | wood | tiger | | 2035 | wood | rabbit | | 2036 | fire | dragon | | 2037 | fire | snake | | 2038 | earth | horse | | 2039 | earth | goat | | 2040 | metal | monkey | | 2041 | metal | rooster | | 2042 | water | dog | | 2043 | water | pig | | 2044 | wood | rat | | 2045 | wood | ox | | 2046 | fire | tiger | | 2047 | fire | rabbit | | 2048 | earth | dragon | | 2049 | earth | snake | | 2050 | metal | horse |