Emacs

44 readers
1 users here now

Our infinitely powerful editor.

founded 4 years ago
MODERATORS
26
6
Emacs RFC 2646 email flowing (idiomdrottning.org)
submitted 4 months ago* (last edited 4 months ago) by Sandra@idiomdrottning.org to c/emacs@lemmy.ml
 
 

Emacs RFC 2646 email flowing

Heck it Emacs!

A few months ago I fixed a bug in RFC 2646 handling where the last paragraph wouldn't get reflowed unless I remembered to add a hard newline (that is, a newline with the 'hard text property) after it, at EOT. I needed to hit one extra RET at the end. All other paragraphs would be wrapped, not just the last one.

(I even bugged @jas@fosstodon.org about it.)

But it still didn't always work and today I tried to get to the bottom of why, spending the entire day debugging it, finally realizing that... It's not even being called when there's only one paragraph in the email. I wasted so much time before realizing that! And then getting to the bottom of why that wasn't happening was the opposite of easy but it turnes out that Gnus by design doesn't call the fill-flowed-encode function when there aren't any hard newlines in the buffer. Which there aren't gonna be if it's a single-paragraph letter 🤦🏻‍♀️

Use-hard-newlines is beyond useless since that's always buffer-local and the text-reflowing is being done in a temp buffer. Instead since 2010 we're supposed to set mml-enable-flowed to true. But don't worry, fans of the messages-are-flowing package, I'm gonna send patches there to reflect that. I have a bunch of other changes to that package too since I've been using that a lot this summer.

This is all in bug#71017 (cursed palindrome!) for people who wanna dig in 👩🏻‍🏫

@emacs@lemmy.ml

27
28
29
 
 

I've been using konsole (and iterm2 on my work mac) for most of my working career, but on the linux side, I've recently switched to Kitty, but now I'm wondering if I can finally get used to just using emacs on both.

Does anyone use emacs as their main terminal? Is there one better than ansi-term that supports modern features like libsixel?

I still can't quite get used to the keybindings (like C-c twice for ^C) and some other weirdness.

30
5
submitted 6 months ago* (last edited 6 months ago) by nmtake@lemm.ee to c/emacs@lemmy.ml
 
 

I wrote this script to learn how completing-read's complex arguments works. Compared to other clients it's quite limited; but thanks to packages like Vertico and Orderless, it works quite well for my use cases.

Screenshot

31
32
4
submitted 6 months ago* (last edited 6 months ago) by DrOps@feddit.de to c/emacs@lemmy.ml
 
 

When I needed a taylored function for a problem, I tried if ChatGPT could help me.

33
 
 

Making a Hydra for Denote was not as straightforward as I thought, Therefore I documented it

34
 
 

Hello!

Since I spend most of my day on the bus, I have a lot of time to read. Do you have any book recommendations for learning Emacs? I plan to use Emacs as a text editor for note taking and programming in general.

35
 
 

A close friend of mine was "inspired" to write a song by my series of blog articles called "Emacs Fulfills the Unix Philosophy" (actually I think he is busting my chops a bit for being an annoying Emacs evangelist, but anyway...) I thought it was pretty funny and worth sharing here.

He wrote the lyrics and used one of those Large Language Models like Stable Diffusion (or something like it) to make the actual music, and settled on a few different renditions of the song. You can listen to them on his website: https://www.extrema.is/blog/2024/04/29/emacs-philosophy

36
 
 

... more an annoyance really, and not elfeed's fault at all but ...

[first posted on reddit/r/emacs but probably more interesting here]

lemmy RSS feeds (such as "https://lemmy.ml/feeds/c/emacs.xml") often (but not always) have mis-guided "Link:" elements which target an external link, an image file or other material instead of the lemmy post itself. Consequently, hitting 'b' elfeed-search-browse-url may send one on a surprising if not always useful journey.

eg

Title: Keymacs, a program to generate Emacs keybindings | Plain DrOps
Author: https://feddit.de/u/DrOps
Date: Tue, 23 Apr 2024 23:35:25 AEST
Feed: Lemmy - emacs
Tags: emacs, lemmy
Link: https://plaindrops.de/blog/2024/keymacs/

submitted by DrOps to emacs
8 points | 2 comments
https://plaindrops.de/blog/2024/keymacs/

In this case, the link to lemmy itself is in the "2 comments" => https://lemmy.ml/post/14798221

Here's a little hook to fix it up - it also marks the entry with the tag 'lemmy-fixed' ...

(defun elfeed-fix-lemmy-link (entry)
  "Fix lemmy.ml RSS feed links in elfeed."
  (when-let ((url-base-regexp "https://lemmy\\.ml/")
             (feed (elfeed-entry-feed entry))
             (feed-url (elfeed-feed-url feed))
             ((string-match-p (concat url-base-regexp "feeds/c/") feed-url))
             (entry-link (elfeed-entry-link entry))
             (link-url-regexp (concat url-base-regexp "post/[0-9]+"))
             ((not (string-match-p link-url-regexp entry-link))))
    (when-let ((content (elfeed-deref (elfeed-entry-content entry))))
      (let ((lines (split-string content "\n")))
        (dolist (line lines)
          (when (string-match link-url-regexp line)
            (let ((post-link (substring line (match-beginning 0) (match-end 0))))
              (setf (elfeed-entry-link entry) post-link)
              (elfeed-tag entry 'lemmy-fixed)
              (message "Fixed lemmy link in elfeed: %s" post-link)
              (cl-return))))))))
(add-hook 'elfeed-new-entry-hook #'elfeed-fix-lemmy-link)

Thanks to u/karthik for getting me started with this. The crappy elisp is mine not his (roast me!)

37
 
 

I was working with NPM package.json files a lot lately and I often found myself saving them in an unparseable state. json-ts-mode highlights syntax errors in yellow but it wasn't enough.

I didn't want to use flymake-eslint becuase it requires having the jsonlint binary in the PATH and I just wanted a simple Lisp solution.

The code tries to parse the current buffer on save using Emacs' built-in json-parse-string and moves the cursor to the location of the parsing error if it fails.

The below code naively assumes that the saved buffer is always the current buffer, which may very well not be the case (e.g. (save-some-buffers)).

It also probably won't save JSON5 files which have // comments inside because json-parse-string won't handle that.

(defun rtz/json-parse-pre ()
    (interactive)
    (if (eq major-mode 'json-ts-mode)
        (condition-case err
            (progn 
  	    (json-parse-string
  	     (buffer-substring-no-properties
  	      (point-min)
  	      (point-max)))
              nil)
          (json-parse-error
           (goto-char (nth 3 err)) (error err)))))

  (setq write-file-functions '(rtz/json-parse-pre))
38
 
 

For sure, I’m heading straight to Emacs hell for this.

Apparently, there are a lot of Emacs purists in the world who, over the years, have learned to type such complex key sequences as C-x r t M-. C-c C-p fluently. I'm not one of them. And when I tried to figure out how to customize it for myself, the web forums were full of comments saying it wasn't a good idea.

39
 
 

In vim terminal I use C-[ for ESC to escape from insert mode a lot, but didn't know C-[ works in GUI version of Emacs until recently. Since Meta can be replaced with ESC, we can enter C-M-s, for example, with C-[ C-s.

40
 
 

This release brings a host of user-facing refinements to an already stable base, as well as some impressive new features. There is a lot to cover, so take your time reading these notes.

Special thanks to Jean-Philippe Gagné Guay for the numerous refinements to parts of the code base. Some of these are not directly visible to users, but are critical regardless. In the interest of brevity, I will not be covering the most technical parts here. I mention Jean-Philippe’s contributions at the outset for this reason. Though the Git commit log is there for interested parties to study things further.

41
19
Emacs 29.3 released (lists.gnu.org)
submitted 7 months ago by 4ffy@lemmy.ml to c/emacs@lemmy.ml
 
 

cross-posted from: https://lemm.ee/post/27699104

From the NEWS file: Emacs 29.3 is an emergency bugfix release intended to fix several security vulnerabilities described below.

  • Arbitrary Lisp code is no longer evaluated as part of turning on Org mode. This is for security reasons, to avoid evaluating malicious Lisp code.

  • New buffer-local variable 'untrusted-content'. When this is non-nil, Lisp programs should treat buffer contents with extra caution.

  • Gnus now treats inline MIME contents as untrusted. To get back previous insecure behavior, 'untrusted-content' should be reset to nil in the buffer.

  • LaTeX preview is now by default disabled for email attachments. To get back previous insecure behavior, set the variable 'org--latex-preview-when-risky' to a non-nil value.

  • Org mode now considers contents of remote files to be untrusted. Remote files are recognized by calling 'file-remote-p'.

42
21
submitted 7 months ago* (last edited 7 months ago) by majjo to c/emacs@lemmy.ml
 
 

(Video on Mastodon)

Inspired by a Reddit post some month ago, I wrote two patches:

  1. titlebar-colors.patch for syncing the colors of the titlebar with the rest of the frame. This uses GtkHeaderbar to allow Emacs to control the colors internally. I haven't gotten the foreground color to sync yet. The changes are done to GTK parts of Emacs and should work for both X and Wayland (pgtk) builds.
  2. rounded-corners.patch to make the shape of frames more consistent with other applications. The changes are made to PGTK parts of Emacs, but should be easily applicable to other places. Right now, it forces a 12 px radius. Ideally, it should just respect the shape of the underlying GtkWindow. This would make it more versatile and automatically change to a square shape in fullscreen (which is currently unimplemented).

The Reddit post mentioned got a lot of attention, but the poster did not provide any code. So I thought some people would find at least the first of these patches useful!

They both have their flaws (poor contrast in most dark themes and forcing 12 px radius, also seems to crash Corfu and possibly more), any help to improve them is much appreciated.

43
44
 
 

this update

  • uses dropdown menu widgets everywhere, and
  • fully implements comment folding widgets.

the readme is also updated to explain these features.

holler if you run into any bugs.

45
 
 

I'm still torn on nvim vs Emacs. I have my Emacs config readt and I'm working on finishing my nvim config, but I'm still switching back and forth and can't decide. I thought Emacs' other features would be enough to make me stay but frankly I find myself preferring non-emacs alternatives like cmus over emms and I don't use RSS feeds enough to justify elfeed. I also prefer kitty in zsh over term, vterm and eshell. As an editor, however currently Emacs is superior, but we'll see if that changes when my neovim config is complete. Currently, the only advantage of nvim over Emacs when it comes to being my IDE, is faster load times. I think Neovim has faster load time, and Emacs has org-mode as features that stand out, where Emacs startup, even with the daemon/server, is slower, and orgmode support for neovim is inferior. The thing is, I haven't been able to really get into org-mode and I haven't even finished configuring neovim. For the time being, I'll stick to my approach of switching back and forth, but we'll see where things go in the future.

In terms of any other text editing features, I can't say either reigns supreme, as they're both really good. They have the features one would expect and theming is just amazing!

But I think my choice of editor will come down to org-mode or markdown. Markdown is simpler for me, as I'm more familiar with it and I use it all the time for my uni work, as I'm required to. Org-mode is more powerful and featured, but is also more difficult to learn because of how different it is. My other problem is that I just couldn't get into it. So currently, I'm on markdown, because that way, my mind doesn't have to switch back and forth, which is confusing.

If markdown support in Emacs was as good as Orgmode support (meaning things like making titles larger in-document, essentially giving me a live preview in the document itself as I'm writing it, was available in Emacs), the coice would be obvious. Currently, I use Ghostwriter for Markdown and it feels good, but it feels useless, as in, it's another program for just this one thing (markdown), that's a usecase under another usecase umbrella (text editing). Alternatively, if Emacs supported live markdown preview within itself to the level of ghostwriter (and no, the browser preview doesn't count, it's not good enough to have to have a broswer window opened alongside Emacs) so if I can get Ghostwriter-level of polish for Markdown and specifically Markdown live preview in Emacs, or Orgmode-level of support, where the live preview happens in the document itself as I'm writing it, I would likely switch to Emacs. But currently, I'm quite torn.

Is the above possible? And if so, can you point me in the right direction of how to achieve it? Thanks.

Edit: a massive thank you rhabarba for helping me get markdown set up on Emacs! After doing that, and adding a few other quality-of-life features, I'd say my Emacs configuration feels quite complete.

46
7
lem.el update 0.20 (codeberg.org)
submitted 8 months ago* (last edited 8 months ago) by blawsybogsy@lemmy.ml to c/emacs@lemmy.ml
 
 

added lots of stuff in this update, some of which may be a little green still.

  • commands to navigate comment trees
    • up to top-level comment
    • prev/next same-level comment
  • various commands to selectively fold (hide) comment branches
    • un/fold current comment
    • un/fold current comment + its children
    • un/fold current comment's entire branch
    • un/fold entire buffer
  • added more sorting/listing drop-down widgets to make it easier to see what sorting is in effect (and to change sorting by mouse)
  • fix tab navigation to (hopefully) all links everywhere
  • make default sorting/listing in views better match the web UI
  • fix sorting options in user view
  • various other fixes

one thing to note is that this release switches the S/s bindings, for consistency.

47
48
49
9
lem 0.19 update (codeberg.org)
submitted 8 months ago* (last edited 8 months ago) by blawsybogsy@lemmy.ml to c/emacs@lemmy.ml
 
 
  • implement overview (mixed comments + posts) for user views
  • implement unified inbox (mixed replies, mentions, private messages)
  • add communities moderated to user view
  • add sort/listing widgets to browse communities for nice sorting feedback
  • add search current user command
  • add search current community command

I thought it might be nice to add drop-down sort/listing widgets to the top of all feed-based views, roughly similar to the web client, but it seems that the emacs widget library doesn't allow placing multiple menu widgets on the same line. :/

EDIT: turns out it's possible, so i'll add them to the main views.

50
 
 

Some Emacs Lisp to help me populate random information into my Campaign Status document. This delves into the org-element-map function and some querying of information to pick the right elements.

view more: ‹ prev next ›