16 ms·
The benefits of everything being a buffer in Emacs
- hprotagonist 4y agoi absolutely love wdired. it’s magic. for extra fun, it combines well with multiple-cursors or visual-regexp-steroids, at which point bulk renaming is basically a game.
- marco_craveiro 4y agoI also love wgrep. [1] [1] https://melpa.org/#/wgrep https://melpa.org/#/wgrep
- hprotagonist 4y agoand rg.el, which is that UX for ripgrep.
- b3n 4y agoYou can also use the built in rgrep functionality with ripgrep, just do something like (grep-apply-setting 'grep-find-command "rg --no-heading ")
- stevenhuang 4y agodam, where's vim's equivalent for this?? whenever I get into netrw I always have to lookup its special bindings to create/rename. I'm jealous :P
- hprotagonist 4y agoi suppose you could hack something together with fzf and sed and rg. I've seen some pretty hairy stuff done that way.
- avbanks 4y agoMoved from Vim to Doom Emacs (w/ vim keybindings) and I'd recommend. Dired, Magit, and Org-Mode have all been great.
- ossusermivami 4y agovidir from moreutils does this over an agnostic $EDITOR https://manpages.debian.org/testing/moreutils/vidir.1.en.html https://manpages.debian.org/testing/moreutils/vidir.1.en.htm...
- anschwa 4y agoYes! wdired and wgrep are really fun. It's amazing how Emacs utilizes buffers to offer a very powerful and consistent user interface. I think some other compelling examples are compilation-mode and magit.
- mbork_pl 4y agoThis is a cool anecdote about something that happened to me last week. I'd love to hear similar anecdotes where people who use Emacs (or Vim, or other software sophisticated enough) were able to combine its features in unexpected ways.
- convolvatron 4y agoC-x r k C-x b *scr C-I C-x r y M-< (+ M-> ) C-j
- mxmdkdop 4y ago[flagged]
- kriyative 4y agoI don't think they were trying to be. Broadly, those are the key bindings to copy a column of characters (presumably numbers) paste them into the `scratch` buffer and sum them, give or take some assumptions
- jgrahamc 4y ago"Kill" text in a "rectangle" and save its contents C-x r k Switch to the scratch buffer (think there's a missing RET at the end) C-x b *scr C-I "Yank" the "rectangle" saved in the first command C-x r y Moves to the start of the buffer and sets a "mark" M-< Literals that are entered at the start of the buffer (+ Move to the end of the buffer M-> Another literal ) Executes the buffer (or at least the LISP expression at the cursor). Note the scratch buffer allows you to type arbitrary LISP stuff and execute it with C-j. C-j So, suppose the initial buffer contained 1 1 2 3 Then the scratch buffer would get turned into (+1 1 2 3 ) And when executed this would add the list of numbers and look like this: (+ 1 1 2 3) 7
- wging 4y ago> Switch to the scratch buffer (think there's a missing RET at the end) In vanilla emacs you need a RET, but I bet that like many people, OP's using a mechanism that will just select the matching item if there's a unique match, rather than the built-in buffer selection mechanism. I use ido (with flx-ido for fuzzy completions), and it works for me as stated: C-i in the minibuffer runs `ido-complete`, which selects the unique completion if there's only one. (By default, that is, this is emacs and so of course there's a variable `ido-confirm-unique-completion` that you can set to customize this behavior.)
- luispauloml 4y agoReminds me of "Episode 16: dired" of Emacs Rocks: https://emacsrocks.com/e16.html https://emacsrocks.com/e16.html
- seanw444 4y agoFor me it's not the "unusual synergy" between its applications that's handy. I rarely have a situation that is significantly faster than it would be in any other editing environment. What makes it amazing to me is the uniformity of it. Everything operates the same, and the keybinds apply everywhere that they're supposed to. There are many programs that are not that way, and it's kind of jarring. Also, every buffer is a blender of modes. Want a new feature or some handy functionality? Activate a mode. My only argument against Emacs used to be its sluggishness, but that's no longer a thing with native compilation. So now I'm pretty sure Emacs has spoiled me, and I'll never be able to enjoy another text editor again.
- agumonkey 4y agoThere's probably some room for improvements. People say lispmachines were still more interesting down and up compared to emacs. A few things I'd like to have is keymap collisions handling, but as anything in emacs, i can always code it with enough time :)
- theonething 4y ago> I'm pretty sure Emacs has spoiled me Comments like this make a long time Vim lover like me very curious, but I guess not curious enough to try it. Maybe one day. What both Emacs and Vim have in common is an intimidating learning curve. You can't just dip your toe in. You gotta jump in head first, sink for awhile and then hopefully learn to swim. Only then will you know if you like it.
- shadowofneptune 4y agoThis was not my experience with Emacs, oddly enough. I started using it because it was the only editor that both supported a terminal and had a top bar. Like a windows program, pressing F10 gets you a File, Options, etc. menu that helped me get through that first session. Emacs (and other Vi's, I should note) has made a nod towards accessibility that Vim has not.
- w0m 4y ago
- shadowofneptune 4y agoWith the Emacs shell, this goes a step further. Emacs functions and /bin/ commands are put in the same namespace. '+' is now a command that can be run at the command line, while 'grep' can have its output redirected to a buffer instead of a file (Sadly no input redirection). This, all while itself being a buffer. It doesn't work well with full-screen programs, or ones that use escape sequences. Sadly there's no away around that besides keeping a list of those programs. Unix programs have never needed to say to the OS "I am a fullscreen program" due to how little a traditional shell actually interacts with a programs. Emacs is my login shell now. I feel however that other, more pure attempts at this like the Canon Cat and Plan 9's text editor were smothered by the Mac/Windows interface of GUI programs which rarely interact. A more evolved shell never had the chance to arise.
- jrockway 4y ago> It doesn't work well with full-screen programs eshell, at least in the past, is quick to involve ansi-term (M-x ansi-term) when launching a program that requires it. I recall being able to run Emacs inside of Emacs circa 2008, not sure if things have changed since then.
- _emacsomancer_ 4y agoThere's also eshell-vterm[1], which allows eshell to use vterm for visual commands. [1]: https://github.com/iostapyshyn/eshell-vterm https://github.com/iostapyshyn/eshell-vterm
- celrod 4y agoI haven't tried eat (Emulate A Terminal) yet, but I've been meaning to: https://codeberg.org/akib/emacs-eat https://codeberg.org/akib/emacs-eat Eat is an terminal emulator supporting eshell, written in elisp. It also supports full screen programs. It claims vterm is 1.5x faster, though, but that eat doesn't flicker while vterm does. I haven't noticed vterm flickering, or maybe I just don't notice?
- 4y ago
- abudabi123 4y agoThe Unicode has a Unihan_Readings.txt file that can be transformed into a readings-table for Emacs to help you accelerate your learning the character definition and key sequence for input method. To help your eyesight you can configure Emacs to enlarge the East Asia fonts. What I don't know how is to append to the "chinese-ctlaub" input method missing key sequence for input method. For example, 雈, code point #x96c8, the chinese-ctlaub input sequence is missing. I'd like to update chinese-ctlaub with the reading "woon4". See https://humanum.arts.cuhk.edu.hk/Lexis/lexi-mf/search.php?word=雈 https://humanum.arts.cuhk.edu.hk/Lexis/lexi-mf/search.php?wo... Here is the emacs lisp configuration. 1 2 3 4 ;; --- create readings table 5 6 ;; #!/bin/sh 7 ;; M='path_to/unidata/Unihan_Readings.awk' 8 ;; X='path_to/unidata/Unihan_Readings.txt' 9 ;; Y='./uni-unihan-readings.el' 10 ;; awk -f "$M" "$X" > "$Y" 11 12 13 ;; --- readings table to load 14 15 ;; (defvar readings-table 16 ;; (make-char-table 'readings-table nil) 17 ;; "Char table of definitions for East Asian characters.") 18 ;; (aset readings-table #x340C "a tribe of savages in South China") 19 ;; (aset readings-table #x3416 "㐖毒, an old name for India") 20 21 ;; --- keybindings to locate definition or key sequence 22 23 (load "~/lib/emacs/x/Unihan_Readings.el") 24 25 (defun x/define-char () 26 (interactive) 27 (message "%s" (aref readings-table (following-char)))) 28 29 (defun xb/quail-show-key () 30 "Always apply quail-show-key to chinese-ctlaub input method." 31 (interactive) 32 (if (string= current-input-method "chinese-ctlaub") 33 (quail-show-key) 34 (progn 35 (set-input-method "chinese-ctlaub") 36 (quail-show-key) 37 (toggle-input-method)))) 38 39 (defun xxb/quail-show-key () 40 "Always apply quail-show-key to chinese-py-b5 input method." 41 (interactive) 42 (if (string= current-input-method "chinese-py-b5") 43 (quail-show-key) 44 (progn 45 (set-input-method "chinese-py-b5") 46 (quail-show-key) 47 (toggle-input-method)))) 48 49 (add-hook 'text-mode-hook 50 (lambda () 51 (define-key text-mode-map (kbd "<f1> <up>") 'x/define-char) 52 (define-key text-mode-map (kbd "<f1> <right>") 'xb/quail-show-key) 53 (define-key text-mode-map (kbd "<f1> <left>") 'xxb/quail-show-key))) 54 55 ;; (setq view-mode-hook nil) 56 (add-hook 'view-mode-hook 57 (lambda () 58 (define-key view-mode-map "w" 'x/define-char) 59 (define-key view-mode-map "a" 'xxb/quail-show-key) 60 (define-key view-mode-map "d" 'xb/quail-show-key))) 61 62 (dolist (charset '(kana han symbol cjk-misc bopomofo)) 63 (set-fontset-font 64 "fontset-default" 65 charset (font-spec :family "BabelStone Han" :size 28)))
- shadowgovt 4y agoThis was the first tricky bit to wrap my head around when using emacs: "Why do they call files 'buffers?' Every other text editor just calls them files." Wrapping one's head around the difference is IMHO the first step into grasping why emacs sticks around after all these decades.
- vidarh 4y agoI use my own custom text editor, but came from emacs, and one of the best choices I made was to copy that bit.
- spudlyo 4y agoWindows and frames, killing and yanking, point and mark, slurping and barfing -- there's a lot of Emacs nomenclature that confuses people initially.
- hollerith 4y agoI do not catch your meaning. Every text editor I know of makes its edits to an in-memory copy of the file. If interactive edit commands operated directly on the file, the Save command would make no sense. Emacs calls the in-memory copy a buffer. (VSCode calls it an editor.)
- shadowgovt 4y agoMost text editors call it "file" or "document," even if it's not yet backed by disk. It's a subtle difference, but I think emacs's decision to call them "buffers" (though it makes the editor a space-alien by modern standards, that much harder to learn) makes more clear that the user should have no expectation that any of the buffers ever get backed to long-term storage. Once one wraps one's head around that, a lot of things get much easier (including and especially writing document editing functions; where most systems would have you store blobs of text in string variables, emacs really wants you to pop up temporary buffers and manipulate them like any other buffer, with the added benefit that if a function fails mid-execution, the regular buffer editing tools make it easy to inspect the failed state).
- mjw1007 4y agoYes, this sort of consistency is very valuable. It's far too common that the interface an IDE gives you for something like adding a watchpoint is "type an expression into this small area in a dialog box, using a restricted subset of my text-editing features". I sometimes think the main attraction of print-style debugging is that it doesn't do that to you.
- textread 4y ago"It is better to have 100 functions that operate on one data structure than to have 10 functions that operate on 10 data structures" - SICP <3
- xyzwave 4y agoI’m guessing SICP took that from Alan J. Perlis, considering he wrote the foreword. http://www.cs.yale.edu/homes/perlis-alan/quotes.html http://www.cs.yale.edu/homes/perlis-alan/quotes.html
- czx4f4bd 4y agoIt's from the forward. Page xvii in this copy: https://web.mit.edu/6.001/6.037/sicp.pdf https://web.mit.edu/6.001/6.037/sicp.pdf
- czx4f4bd 4y agoI would posit that this is also why spreadsheets and shell scripts remain so widely used.
- why-el 4y agoOh yeah, it gets even more interesting in large refactors, say an involved rename that requires you check the context before you do so (like not just global search and replace). I do a search, this opens a buffer with all results, with file name, position, all that, and Emacs can allow you to "peek" into the file without even leaving the search buffer focus (i.e use a split screen). Then, use https://github.com/mhayashi1120/Emacs-wgrep https://github.com/mhayashi1120/Emacs-wgrep to do the magic of in-place editing.
- TacticalCoder 4y agoSpeaking of spellchecking... As devs we tend to use lots of weird words and acronyms and they're not, by default, in the spellchecker that Emacs (or other editors) do use (aspell in my case). You can add them but then I take it many of us keep "adding to the wordlist" the same words (for example, yes, "abs", "stdin" and "stdout" are correctly spelled, etc.). Does anyone know of a good source of "programming vocabulary" made to add to spellcheckers?
- teddyh 4y agoMaybe https://en.wikipedia.org/wiki/Free_On-line_Dictionary_of_Computing https://en.wikipedia.org/wiki/Free_On-line_Dictionary_of_Com...
- TacticalCoder 4y agoThanks, I just checked Foldoc: there's definitely quite some stuff in there but then I tried terms like "Clojure" and "iptables" (which aren't recent by any means) and they're apparently not in that dictionary but it's a start, I'll dig a bit more.
- fithisux 4y agoI wish I could learn using Emacs. With Vi I make already baby steps.
- sph 4y agoIt's like learning to ride a bike. It's scary at first, but you once it clicks you will forever know how to ride a bike. And bikes and Emacs both will still be around in 30 years. Would you rather spend the next weekend learning Emacs, or a React library no one will ever use again in 6 months?
- iLemming 4y agoThis is what I did, years back. I created a single Org-Mode file called tasks.org. I didn't know anything about Org-Mode and in general, was a total noob in Emacs. Whenever I had a question or felt like whatever I'm doing is taking too long or does require repetition, or simply annoyed me for any reason, I would add a new item to that list. Slowly I learned Org-Capture, which allowed me to add items to the list much faster and without switching contexts. My list kept growing, and that forced me to learn more efficient ways of finding stuff - e.g., Org-Agenda, scheduling, deadlines, etc. Some items, over time, have become irrelevant so I learned how to archive them. Some problems required basic knowledge of Emacs-Lisp, so I started using Org-Babel to have source blocks where I would write and play around with tiny (and sometimes bigger) elisp snippets. That lead me to the discovery of indirect buffers and I realized how amazing they are. That single .org file had become a very important part of my life. I started using it for other things, not just to learn Emacs and Org-Mode. By the time I discovered Org-Roam and jumped into Zettelkasten, I was doing pretty much almost everything I do on the computer, in Emacs. Today I write code, check email, browse articles and blogposts, manage all my files, read books, extract subtitles from videos (to take notes), and keep my personal journal - I do all that in Emacs. And it all started with a simple .org file. Eventually, this approach become my personal philosophy, my absolute recipe for any problem in my life - If you need to solve something, start with a simple list.
- butterisgood 4y agoPlan 9 makes it easy to search your terminal buffer history (it's in /dev/text) (Ok I shouldn't call it a terminal... it's a rio window with a shell in it... it's not a terminal) Acme does similar things letting you manipulate the tag line, or body of a given window. "Everything is a file" can be a nice interface even at the widget/application level. "Everything is a buffer" in Emacs likely enjoys the same benefits (and predates Plan 9 and Acme)
- Lapsa 4y agohoped to be impressed. better luck next time
- DonHopkins 4y agoMeanwhile, in an alternate universe: https://www.donhopkins.com/home/ties/scans/WhatIsEmacs.pdf https://www.donhopkins.com/home/ties/scans/WhatIsEmacs.pdf
- amadeuspagel 4y agoYes I know of another OS allowing this: The browser. If I rename a file in google drive it's just an input field, and spellcheck works there like in any other input field.
- kleiba 4y agoDoes it suggest the correct spelling, or just mark a misspelled word?
- iLemming 4y ago> If I rename a file in google drive it's just an input field You still have to right-click on it, then select from the list, then click again. You cannot bind any keyboard key for that specific action, you cannot replace it with a spellcheck engine you like, you can't search and replace multiple things based on regexp, no multiple cursors, no vim-like navigation, you can't change things in nested dirs without going inside, etc., etc. What's the point of your comment here, I honestly don't understand. It's as if we were discussing femtosecond laser (or plasma blade) capsulotomies (eye surgeries), and you'd be like "one French fella invented a method for this shit sometime in 18th century using nothing but a sharp blade..."
- volforix 4y agoAfter using Emacs for years (huge fan!) I finally realized that Emacs hinders my productivity instead of improving it. Thus I moved to other tools, sadly, and never looked back. In this case I would use Text Extractor (part of M$ PowerToys) and Google Translate.
- nonrandomstring 4y agoFor me the consistency of Emacs lies not only in its user interface but in stable longevity. Productivity is important, yes, but is only one dimension in complex decision space of software. What will you use next year when Microsoft throws its powertoys out of the pram and Google makes translate obsolete? Emacs is almost 50 years old, and I hope to be using it in another 50.
- volforix 4y agoGood point. I'll switch back to Emacs as soon as it's best tool for my task again.
- iLemming 4y ago> After using Emacs for years (huge fan!) I finally realized that Emacs hinders my productivity instead of improving it. I always take these kinds of statements with a grain of salt. Please don't get me wrong, perhaps, you had objective reasons to move from Emacs. Maybe you thought they were objective reasons, even though they weren't as such. I spoke to many "former Emacs users", and in most cases, it usually turns out that either: the person had shallow exposure or limited knowledge, or they've never attempted to learn modern Emacs packages and how they can interoperate. In most cases, they've never written a single Emacs package to solve their personal use cases, let alone publish one for the public. I'm not saying that Emacs cannot reduce productivity. Oh, no, it very well can. And very often it drags you into the rabbit hole of "improving your workflow". It can be extremely frustrating, even for someone "after years of using Emacs" to attempt to fix a simple problem as the desired placement for a window. The complexity of choice can be exhausting. Especially, at moments when you're "in the zone" of trying to solve an unrelated problem. Emacs can get in the way. And most people just can't find the discipline to continue. Often they'd give up, without even trying. And the "novelty bias" of using different IDE creates an illusion that they have wasted time with Emacs. The truth is - learning Emacs is a journey. You just need to keep going. And at some point, you may realize that there's simply nothing better than Emacs out there that can simplify your workflow and increase your productivity when dealing with textual information. - Emacs has a better search. It offers way too many different ways for searching things - locally, remotely, recursively, partially, contextually, dynamically, etc. With filtering the results and sifting through and editing at the same time. - It has some amazing window manipulation capacities. You can precisely control how, where, and what gets to show up on the screen, without having to constantly move things around, drag and resize with the mouse. - Its extensibility simply cannot be matched. I just can't imagine anyone building let's say an InteliJ plugin, with a command that calls a function defined in a different plugin but also redefines some specific calls in that function to its internal, private methods. In Emacs, I can pick a function defined (for example) in Magit, look at the source code, and tell it to redirect its internal, private calls to my own substitute, whenever it gets called. Emacs not only improves productivity. It brings joy to the process of writing. Writing just anything - text, math formulas, or code. But getting to that point is not quick or straightforward. And of course, just like anything, Emacs is not a universally guaranteed tool to make you more productive or happy. Some people just "don't get it", and that's quite all right. But for many, there isn't a better alternative. You can offer a myriad of other tools claiming that the combination of them makes you insanely productive, and to that, I would say: "great, I'll delegate some calls to them from within Emacs..."
- xenodium 4y agoThe emacs rocks episode on multiple cursors does a great job showing the power of everything in the buffer. It’s well worth watching until the end, it’s got a wonderful finale https://emacsrocks.com/e13.html https://emacsrocks.com/e13.html ps. I write the ocasional emacs post at https://xenodium.com https://xenodium.com
- AiAi 4y agoI remember this video being a great motivation for learning Emacs, the `multiple-cursors` package is awesome. Thanks for sharing your content too!
- xenodium 4y agoNice to hear. For me also! it’s my all-time favourite from emacsrocks.
- agumonkey 4y agomagnars has a real talent, most his videos are extra fun and packing dense info he's also behind dash.el (clojure fp builtins for emacs)
- mark_h 4y agoHe's also behind expand-region! (Although, I've started experimenting with the much-smaller treesitter-based https://github.com/casouri/lunarymacs/blob/master/site-lisp/expreg.el https://github.com/casouri/lunarymacs/blob/master/site-lisp/...) I'm pretty sure when he wrote all of that stuff that he'd only been using Emacs for around a year. The benefit of someone that talented, or groks Emacs immediately, and is familiar enough with the outside-ecosystem to know what he wants to borrow, I suppose.
- billforsternz 4y agoJef Raskin, one of the people who conceived the Macintosh at Apple, spent decades advocating user interface ideas that didn't (yet?) reach a wide audience. I recall he wanted the user to be able to manipulate and interact with the filesystem in the same way as everything else, including spell check and correction. This Emacs user manages to do that with filenames within Emacs although it seems a little clunky.
- meonmyphone 4y agoI remember when I discovered this feature, I found it so cool! Emacs always surprises me with something like that.
- gardenhedge 4y agoSometimes I feel like I'm the only one who doesn't care for Emacs.. then I remember the real world where I've never heard of it being mentioned and never seen anyone using it.
- iLemming 4y agoThere are close to forty thousand McDonald's restaurants. It's the biggest fast-food chain in the history of this planet. That still doesn't make it the best, mouthwatering, finger-licking food. The "real world" is not where every programmer uses VSCode. That would be a dystopia.
- gardenhedge 4y agoThe "real world" is a reference to what I experience outside of the internet. With McDonald's my real world experience is that it's a popular restaurant. I don't understand why you're arguing that McDonald's isn't the best. I didn't say Emacs wasn't the best. I said I've literally never seen it used or discussed outside of the internet.
- iLemming 4y agoYou misread my McDonald's analogy. Einstein once perfectly formulated the meaning of it: "What is right is not always popular and what is popular is not always right". Besides, Emacs is not as unpopular in "the real world" as you think. You may say it's purely anecdotal. Even label me a confirmation bias gull. But let me tell you my "anecdote". I've been programming for over two decades, and until around 2013, I was just like you. I've never seen anyone using Emacs. I've heard about it. I read some news on the Internet but have never seen it in the wild. And one day, I took a flight from New York to San Francisco. My next-seat guy opened a laptop and started typing things in Emacs. I just couldn't help it. I pretended to be asleep and kept peeking. After forty minutes of that lame game, I simply couldn't hold it anymore and started asking questions. Until that point in my career, I haven't seen anyone coding like that guy - without googling things; without StackOverlfow; without constantly jumping between documentation, terminal console, utility apps, and the editor. It was all in one place. It was clean and strangely ascetic - no toolbars or menu, no icons, no progress bars, no multitude of numbers indicating different things. Another thing that fascinated me was how easily he manipulated window panes using only the keyboard. Clearly, he was "in the zone" - it seemed as if he had zero context switching. That was very different from how I wrote code and most of my colleagues as well. And he wasn't using some esoteric, little-known language. He was writing in Golang. I didn't know it; still, it wasn't some completely alien thing to me. That flight, though, wasn't enough to inspire me to try Emacs. Soon enough, I forgot about it. Three months later, I made a jump in my career. At my new job, there were a handful of Emacs users. I learned many new things from them (unrelated to Emacs). And that's when I installed Emacs on my machine for the first time. It still would take me another two years to transition. A year later, I got a great offer and bounced again. Better salary, a better workplace, a more prominent company, different kinds of challenges, tougher team - plainly an upgrade from every perspective. In this team, I had more than two dozen developers using Emacs. And that turned out to be a reoccurring pattern for me. With every new team, the more experienced and seasoned developers in it - the chance for more Emacsers would increase. In my current team, most of the devs (more than a few dozen) use Emacs. We have exactly one person using Neovim (there were two, but one left), one VSCode, and a single IntelliJ person. There are probably more non-emacs people here, but in the groups of my immediate proximity, there's an uncontested Emacs majority. No, I'm not saying that non-Emacs users are lesser and that every self-esteemed coder absolutely has (at least) to try Emacs. Or that it is guaranteed that Emacs would make you a better programmer. No, no. I'm not saying that. It's just, ... In my (of course, totally subjective) empirical experience, programmers using Emacs generally tend to be very good at what they do. > I don't understand why you're arguing that McDonald's isn't the best So you see? It's just like Einstein said - "... it is not always right." For you, McDonald's may feel "right" and might be "the best." Albeit, for me, it is not. Our "real worlds" - yours and mine, differ. Today they do. Tomorrow, that may change.
- iLemming 4y agoDired is just one of the great examples of "everything is a buffer" benefits. It lets you do some pretty gimmicky stuff like for example, converting the textual representation of a directory (the output of `ls -lR`) to a proper Dired structure you can navigate through (google 'Virtual Dired'). One of the more utilitarian examples is the use of Indirect buffers. You can, for example, create an indirect clone buffer of a file, narrow some portion of text in the original buffer, and in the cloned buffer, move the cursor to a different location. And then work with two buffers as if they're related to completely different files - narrowing, widening, selecting and deleting things. And when you save, the changes from multiple places get reflected in the same file. The total bananas about this stuff is that you can change the major mode of the indirect buffer. That for example, lets you edit comments in e.g., python code containing json snippets having highlighting, syntax checking, etc. for json, as if the underlying file is not .py, but .json.
- pama 4y agoDired is indeed a neat example. As per the linked post, one fancy thing one can do is make the buffer view of the directory editable, rewrite names for the files using the full power of Emacs editing and then dump the modified file names to disk. It is also cool that a new shell in a dired buffer starts in that directory. If the dired buffer was displaying a directory in a remote machine, then the shell starts in that directory on that machine. Just like things should be.
- LAC-Tech 4y agoI love the idea of emacs but I find it completely unusable. I've tried several times.
- Vekz 4y agoOne example of synergy I have is that of TODO code comments and org-mode agenda scheduling. For context, some programmers leave //TODO comments through their projects. org-mode uses a notation syntax of *TODO to capture and schedule an agenda item for later completion. These agenda items can be scheduled on a calendar and the agenda can be queried for day, week, month TODOS. Org mode has custom templates for capturing org agenda items. I've made a "TODO code comment" capture template that I can execute on TODO comments. Once executed the template creates org-mode entries which are added to the calendar and link to the comments file and line number.
- wanderingmind 4y agothis is one thing I miss in VSCode. Can you please share the lisp code you have to customize the org-mode for this. This will be a huge favor for a lot of programmers.
- Vekz 4y agoThis is what I have, it def could be improved: (defun capture-comment-line (&optional line) (let ((c (save-excursion (save-window-excursion (switch-to-buffer (plist-get org-capture-plist :original-buffer)) comment-start) ))) (while (string-prefix-p c line) (setq line (string-remove-prefix c line))) (comment-string-strip line t t) )) (setq org-capture-templates '(("C" "TODO code comment" entry (file+headline "~/org/brain/code.org" "Tasks") "\* %(capture-comment-line \"%i\")\n %a" )))
- wanderingmind 4y agoThank you very much
- major505 4y agoMan, I really like the idea behind Emacs, of integrating everything in the way it becomes an ID, but I cant just get into it, specially the weird shortcuts. After years in Vim, and Visual Studio, is hard to wrap my head around the Emacs way to do stuff. Maybe I try again in my next vacation, when I will get some free time.
- herewulf 4y agoI have to wonder if this is sort of an unspoken rebuttal to the recently posted Project Mage[1] and the more amusingly written but equally intriguing "Emacs is not Enough"[2]. Well, I recently encountered a situation where "everything is a buffer" was not good. I had a Common Lisp SLY REPL buffer open and was testing out INSPECT[3]. This puts the REPL in a state where after printing some text it waits for key presses but that's not obvious and I'm using evil mode so q (for quit) just starts recording a macro and I can't enter insert mode because Emacs thinks the buffer is read only. I could only kill the buffer and start anew (while avoiding INSPECT -- turns out SLY has nice inspection functionality of its own but I shouldn't have to know to avoid running some function in the REPL!). Surely there are some workarounds or bugfixes to be had but the whole REPL-is-a-buffer feels very rough around the edges. [1]: https://news.ycombinator.com/item?id=34380373 https://news.ycombinator.com/item?id=34380373 [2]: https://news.ycombinator.com/item?id=34375137 https://news.ycombinator.com/item?id=34375137 [3]: Specifically: (inspect *)
- kyberias 4y agoI'm not an Emacs user so what I'm about to say may be based on totally incorrect information. Seems to be that Wdired is just a hack that represents file and directory metadata in a textual format (in a buffer in Emacs parlance). It's not obvious to anyone that editing a filename in this buffer actually goes to the file system and changes the name of the file. It's even less obvious that removing rows removes files or directories. It actually sounds rather dangerous to use. This is not functionality that emerges from some elegant design of Emacs, it seems it's just a hack.
- trocado 4y agoIt's very obvious because you have to activate the wdired mode, and then accept the changes.
- a_e_k 4y agoFirst, Wdired is not the normal mode for Dired. You have to hit a key to activate that mode. Second, it doesn't actually make any changes to the file system until you hit the key combo to commit them. And the files aren't deleted immediately, even when you do commit; they're just flagged for deletion in the standard Dired interface. You'll have to hit a button to actually "expunge" them from there, and that asks for confirmation again before doing so. Think of Wdired more as a convenient way to build up a transaction of FS changes. And since everything is a buffer, undo works just fine until you commit it. Or you can load up fresh Dired view of the original metadata in another buffer and ediff them to verify your changes before you commit. :-)
- fit2rule 4y ago[dead]