From 4ffdf164e8b5c0a70fc8d5859bdec067fa715b86 Mon Sep 17 00:00:00 2001 From: Laurence Warne Date: Sat, 16 Nov 2024 09:20:38 +0000 Subject: [PATCH] Fix links in org mode --- bin/run.py | 15 +- comments.json | 290 +++++++-------- out.md | 936 ++++++++++++++++++++++++------------------------ out.org | 910 +++++++++++++++++++++++----------------------- out_by_year.md | 710 ++++++++++++++++++------------------ out_by_year.org | 682 +++++++++++++++++------------------ 6 files changed, 1776 insertions(+), 1767 deletions(-) diff --git a/bin/run.py b/bin/run.py index a11ab54..2aecc2b 100644 --- a/bin/run.py +++ b/bin/run.py @@ -20,8 +20,8 @@ AUTH_URL = "https://www.reddit.com/api/v1/access_token" BASE_EMACS_SUB_URL = "https://oauth.reddit.com/r/emacs" -MarkdownType = collections.namedtuple("MarkdownType", "header code_start code_end link bold ext single_line_code") -GithubMD = MarkdownType("##", "```", "```", lambda text, link: f"[{text}]({link})", lambda s: f"**{s}**", "md", "`") +MarkdownType = collections.namedtuple("MarkdownType", "header code_start code_end link bold ext single_line_code link_rx link_replacement") +GithubMD = MarkdownType("##", "```", "```", lambda text, link: f"[{text}]({link})", lambda s: f"**{s}**", "md", "`", None, None) OrgMD = MarkdownType( header = "**", code_start = "#+BEGIN_SRC elisp", @@ -30,6 +30,8 @@ bold = lambda s: f"*{s}*", ext = "org", single_line_code = "~", + link_rx = r"\[([^\]]+)\]\(([^)]+)\)", + link_replacement = r"[[\2][\1]]" ) def get_headers(token=None): @@ -121,7 +123,11 @@ def comment_to_md(content, username, post_id, comment_id, upvotes, md_type=Githu md = "".join([a + b for a, b in zip(split[:-1], code_it)] + [split[-1]]) inline_code_converted = re.sub(r"(?\" #'outline-toggle-children\n :m \"\" #'org-agenda-goto\n :m \"S-\" #'org-agenda-switch-to\n :m \"C-\" #'org-agenda-recenter))\n \n(add-hook 'org-agenda-mode-hook 'my/org-agenda-fold)\n#+END_SRC", - "created_datetime": "2024-09-18 13:49:47+00:00" + "created_datetime": "2024-09-18 14:49:47+00:00" }, "t1_ls4kmt1": { "author": "ilemming", - "upvotes": 8, - "body": "** u/ilemming [[https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1][\ud83d\udd17]] \n*Votes* 8\n\nYou know that you can use vars in org source blocks that inject some data, like:\n\n#+BEGIN_SRC elisp\n #+begin_src bash :var token=\"bla-bla-bla\" \n echo ${token}\n #+end_src\n\n #+RESULTS:\n : bla-bla-bla\n\n#+END_SRC\nThat can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block.\n\n#+BEGIN_SRC elisp\n #+name: dirs\n #+begin_src bash :results silent\n ls \n #+end_src\n\n #+begin_src js :var data=dirs \n console.log(data)\n #+end_src\n\n#+END_SRC\nBut did you know, you can also use elisp there?\n\n#+BEGIN_SRC elisp\n #+begin_src js :var data=(if (featurep :system 'macos) \"\ud83c\udf4e\" \"\ud83d\udc27\") \n return data;\n #+end_src\n\n #+RESULTS:\n : \ud83c\udf4e\n\n#+END_SRC\nOr previous-like example with dirs but without needing additional source block:\n\n#+BEGIN_SRC elisp\n#+begin_src clojure :var data=(shell-command-to-string \"ls -a ~\") \n;; all dotfiles\n(require '[clojure.string :as str])\n\n(->> (str/split data #\"\\n\")\n (filter (partial re-find #\"^\\.*\"))\n (sort)\n (str/join \"\\n\"))\n#+end_src\n#+END_SRC", - "created_datetime": "2024-10-16 00:25:20+00:00" + "upvotes": 10, + "body": "** u/ilemming [[https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1][\ud83d\udd17]] \n*Votes* 10\n\nYou know that you can use vars in org source blocks that inject some data, like:\n\n#+BEGIN_SRC elisp\n #+begin_src bash :var token=\"bla-bla-bla\" \n echo ${token}\n #+end_src\n\n #+RESULTS:\n : bla-bla-bla\n\n#+END_SRC\nThat can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block.\n\n#+BEGIN_SRC elisp\n #+name: dirs\n #+begin_src bash :results silent\n ls \n #+end_src\n\n #+begin_src js :var data=dirs \n console.log(data)\n #+end_src\n\n#+END_SRC\nBut did you know, you can also use elisp there?\n\n#+BEGIN_SRC elisp\n #+begin_src js :var data=(if (featurep :system 'macos) \"\ud83c\udf4e\" \"\ud83d\udc27\") \n return data;\n #+end_src\n\n #+RESULTS:\n : \ud83c\udf4e\n\n#+END_SRC\nOr previous-like example with dirs but without needing additional source block:\n\n#+BEGIN_SRC elisp\n#+begin_src clojure :var data=(shell-command-to-string \"ls -a ~\") \n;; all dotfiles\n(require '[clojure.string :as str])\n\n(->> (str/split data #\"\\n\")\n (filter (partial re-find #\"^\\.*\"))\n (sort)\n (str/join \"\\n\"))\n#+end_src\n#+END_SRC", + "created_datetime": "2024-10-16 01:25:20+00:00" }, "t1_lmzbyro": { "author": "meedstrom", "upvotes": 8, "body": "** u/meedstrom [[https://www.reddit.com/r/emacs/comments/t3_1fe504e/comment/t1_lmzbyro][\ud83d\udd17]] \n*Votes* 8\n\nElisp list indentation has been fixed since over two years ago (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21922). A lot of people probably still use an initfile hack, to fix the following problem, that lists would indent like this:\n\n#+BEGIN_SRC elisp\n'(:foo bar\n :baz zab\n :rab oof)\n\n#+END_SRC\nBut now you can just add a space after the opening paren ~'(~. This is the new convention.\n\n#+BEGIN_SRC elisp\n'( :foo bar\n :baz zab\n :rab oof)\n#+END_SRC", - "created_datetime": "2024-09-13 20:04:11+00:00" + "created_datetime": "2024-09-13 21:04:11+00:00" }, "t1_llfyzu6": { "author": "ImJustPassinBy", - "upvotes": 10, - "body": "** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6][\ud83d\udd17]] \n*Votes* 10\n\nI regularly work with different emacs frames on different monitors, and [~framemove~](https://github.com/emacsmirror/framemove) is great for switching between them. It can hook into ~windmove~ (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions:\n\n\\* ~fm-up-frame~: move to the frame over the current frame\n\\* ~fm-down-frame~: move to the frame below the current frame\n\\* ~fm-left-frame~: move to the frame left of the current frame\n\\* ~fm-right-frame~: move to the frame right of the current frame\n\nIt's not on any of the major package repositories, so you have to install it manually. Thanks to [~emacsmirror~](https://github.com/emacsmirror), this can for example be done as follows using ~use-package~ and ~straight~ (adjust bindings to your liking):\n\n#+BEGIN_SRC elisp\n (use-package framemove\n :straight (:host github :repo \"emacsmirror/framemove\")\n :init\n (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom\n :bind\n ((\"C-x 5 \" . fm-up-frame)\n (\"C-x 5 \" . fm-down-frame)\n (\"C-x 5 \" . fm-left-frame)\n (\"C-x 5 \" . fm-right-frame)))\n\n#+END_SRC\nedit: The only thing I don't understand is why setting ~framemove-hook-into-windmove~ to ~t~ doesn't work in via ~:config~ or ~:custom~. The package is loaded, ~C-h f~ confirms that ~fm-up-frame~ exists, but ~C-h v~ doesn't know ~framemove-hook-into-windmove~. ~framemove-hook-into-windmove~ exists after I run ~fm-up-frame~, but then it's set to ~nil~ and not ~t~.", - "created_datetime": "2024-09-04 10:03:14+00:00" + "upvotes": 11, + "body": "** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6][\ud83d\udd17]] \n*Votes* 11\n\nI regularly work with different emacs frames on different monitors, and [[https://github.com/emacsmirror/framemove][~framemove~]] is great for switching between them. It can hook into ~windmove~ (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions:\n\n\\* ~fm-up-frame~: move to the frame over the current frame\n\\* ~fm-down-frame~: move to the frame below the current frame\n\\* ~fm-left-frame~: move to the frame left of the current frame\n\\* ~fm-right-frame~: move to the frame right of the current frame\n\nIt's not on any of the major package repositories, so you have to install it manually. Thanks to [[https://github.com/emacsmirror][~emacsmirror~]], this can for example be done as follows using ~use-package~ and ~straight~ (adjust bindings to your liking):\n\n#+BEGIN_SRC elisp\n (use-package framemove\n :straight (:host github :repo \"emacsmirror/framemove\")\n :init\n (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom\n :bind\n ((\"C-x 5 \" . fm-up-frame)\n (\"C-x 5 \" . fm-down-frame)\n (\"C-x 5 \" . fm-left-frame)\n (\"C-x 5 \" . fm-right-frame)))\n\n#+END_SRC\nedit: The only thing I don't understand is why setting ~framemove-hook-into-windmove~ to ~t~ doesn't work in via ~:config~ or ~:custom~. The package is loaded, ~C-h f~ confirms that ~fm-up-frame~ exists, but ~C-h v~ doesn't know ~framemove-hook-into-windmove~. ~framemove-hook-into-windmove~ exists after I run ~fm-up-frame~, but then it's set to ~nil~ and not ~t~.", + "created_datetime": "2024-09-04 11:03:14+00:00" }, "t1_lkrhqf7": { "author": "fuzzbomb23", - "upvotes": 10, - "body": "** u/fuzzbomb23 [[https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7][\ud83d\udd17]] \n*Votes* 10\n\nOne of my favourite tips for managing my init file is the ~imenu~ support in ~use-package~. It's turned off by default, though:\n\n#+BEGIN_SRC elisp\n(setq use-package-enable-imenu-support t)\n#+END_SRC\n\nCombined with a nice imenu UI (~consult-imenu~ and Vertico, say) you can navigate your init file really quickly.", - "created_datetime": "2024-08-31 00:51:51+00:00" + "upvotes": 9, + "body": "** u/fuzzbomb23 [[https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7][\ud83d\udd17]] \n*Votes* 9\n\nOne of my favourite tips for managing my init file is the ~imenu~ support in ~use-package~. It's turned off by default, though:\n\n#+BEGIN_SRC elisp\n(setq use-package-enable-imenu-support t)\n#+END_SRC\n\nCombined with a nice imenu UI (~consult-imenu~ and Vertico, say) you can navigate your init file really quickly.", + "created_datetime": "2024-08-31 01:51:51+00:00" }, "t1_lfskmro": { "author": "rego_b", - "upvotes": 9, - "body": "** u/rego_b [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro][\ud83d\udd17]] \n*Votes* 9\n\n~C-x C-e~ to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal)", - "created_datetime": "2024-07-31 10:46:29+00:00" + "upvotes": 10, + "body": "** u/rego_b [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro][\ud83d\udd17]] \n*Votes* 10\n\n~C-x C-e~ to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal)", + "created_datetime": "2024-07-31 11:46:29+00:00" }, "t1_lfsffnb": { "author": "525G7bKV", "upvotes": 8, "body": "** u/525G7bKV [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfsffnb][\ud83d\udd17]] \n*Votes* 8\n\nHighlight regexp or strings in your buffer with =M+s h= good for analyzing logfiles", - "created_datetime": "2024-07-31 09:52:36+00:00" + "created_datetime": "2024-07-31 10:52:36+00:00" }, "t1_lg6q2rq": { "author": "Motor_Mouth_", "upvotes": 8, - "body": "** u/Motor_Mouth_ [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lg6q2rq][\ud83d\udd17]] \n*Votes* 8\n\nFor users of [rg.el](https://github.com/dajva/rg.el) (emacs interface to ripgrep) there is [rga](https://github.com/phiresky/ripgrep-all) (ripgrep-all) a wrapper around ripgrep that \"enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc.\" You can set the rg executable in the configuration of rg.el like so: ~(setq rg-executable (executable-find \"rga\")~ to enable search in multiple document types.", - "created_datetime": "2024-08-02 19:11:58+00:00" + "body": "** u/Motor_Mouth_ [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lg6q2rq][\ud83d\udd17]] \n*Votes* 8\n\nFor users of [[https://github.com/dajva/rg.el][rg.el]] (emacs interface to ripgrep) there is [[https://github.com/phiresky/ripgrep-all][rga]] (ripgrep-all) a wrapper around ripgrep that \"enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc.\" You can set the rg executable in the configuration of rg.el like so: ~(setq rg-executable (executable-find \"rga\")~ to enable search in multiple document types.", + "created_datetime": "2024-08-02 20:11:58+00:00" }, "t1_leom8fv": { "author": "winters_here", "upvotes": 10, "body": "** u/winters_here [[https://www.reddit.com/r/emacs/comments/t3_1eaw1ia/comment/t1_leom8fv][\ud83d\udd17]] \n*Votes* 10\n\nSimple hack to add attributes to the ~~ tag of an exported org file by escaping the quote of the language header.\n\n#+BEGIN_SRC elisp\n#+HTML_DOCTYPE: html5\n#+LANGUAGE: en\" data-theme=\"dark\n\n#+END_SRC\nThis when exported to html using ~org-html-export-to-html~ will result in:\n\n#+BEGIN_SRC elisp\n\n\n#+END_SRC\nUseful when you include some classless css libraries which require you to add attributes to directly to ~~ tag.\n\nDon't skip ~HTML_DOCTYPE~ else it will duplicate the attribute because one extra will be added due to ~xml:lang~", - "created_datetime": "2024-07-24 09:42:47+00:00" + "created_datetime": "2024-07-24 10:42:47+00:00" }, "t1_ldsl3vy": { "author": "thetemp_", - "upvotes": 9, - "body": "** u/thetemp_ [[https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy][\ud83d\udd17]] \n*Votes* 9\n\nI recently discovered the [Dimmer](https://github.com/gonewest818/dimmer.el) package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that *is* focused. And of course, you can customize how much it dims and exclude certain buffers.\n\nI love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore.", - "created_datetime": "2024-07-18 16:34:00+00:00" + "upvotes": 10, + "body": "** u/thetemp_ [[https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy][\ud83d\udd17]] \n*Votes* 10\n\nI recently discovered the [[https://github.com/gonewest818/dimmer.el][Dimmer]] package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that *is* focused. And of course, you can customize how much it dims and exclude certain buffers.\n\nI love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore.", + "created_datetime": "2024-07-18 17:34:00+00:00" }, "t1_l9cmdp9": { "author": "sauntcartas", "upvotes": 11, "body": "** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_1djdync/comment/t1_l9cmdp9][\ud83d\udd17]] \n*Votes* 11\n\nI started using org-capture when I started my current job several years ago. I recorded my daily activities using this template:\n\n#+BEGIN_SRC elisp\n(setq org-capture-templates\n '((\"d\" \"Done\" entry (file+olp+datetree \"~/org/done.org\"))))\n\n#+END_SRC\nA minor annoyance was that an unwanted link to whatever file location I happened to be in when I invoked org-capture was stored along with my log entry. I made occasional desultory efforts over the years to remove it, but I just couldn't figure it out. I recently made a more concerted effort and _finally_ was able to work it out after poring over the documentation for the ~org-capture-templates~ variable. It turns out the default \"template\" for the ~entry~ capture type is ~\"* %?\\n%a\"~, where the code ~%a~ means \"annotation,\" ie, a link to the file location. So I just had to change my definition to this:\n\n#+BEGIN_SRC elisp\n(setq org-capture-templates\n '((\"d\" \"Done\" entry (file+olp+datetree \"~/org/done.org\") \"* %?\")))\n#+END_SRC", - "created_datetime": "2024-06-19 19:02:38+00:00" + "created_datetime": "2024-06-19 20:02:38+00:00" }, "t1_l8d30q3": { "author": "JDRiverRun", - "upvotes": 9, - "body": "** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3][\ud83d\udd17]] \n*Votes* 9\n\nA few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [this gist](https://gist.github.com/jdtsmith/a169362879388bc1bdf2bbb977782d4f) for the details.", - "created_datetime": "2024-06-13 01:47:13+00:00" + "upvotes": 8, + "body": "** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3][\ud83d\udd17]] \n*Votes* 8\n\nA few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [[https://gist.github.com/jdtsmith/a169362879388bc1bdf2bbb977782d4f][this gist]] for the details.", + "created_datetime": "2024-06-13 02:47:13+00:00" }, "t1_l687lg9": { "author": "Usual_Office_1740", - "upvotes": 10, - "body": "** u/Usual_Office_1740 [[https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9][\ud83d\udd17]] \n*Votes* 10\n\nI've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again.", - "created_datetime": "2024-05-29 20:34:14+00:00" + "upvotes": 12, + "body": "** u/Usual_Office_1740 [[https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9][\ud83d\udd17]] \n*Votes* 12\n\nI've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again.", + "created_datetime": "2024-05-29 21:34:14+00:00" }, "t1_l33y04q": { "author": "ImJustPassinBy", - "upvotes": 10, - "body": "** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q][\ud83d\udd17]] \n*Votes* 10\n\nNot from me, but I just wanted to share /u/arthurno1 one-line tip to get ~which-key~ to work with ~dired~ (see screenshot in linked post):\n\nhttps://www.reddit.com/r/emacs/comments/1clvkfe/announcing_casual_dired_an_opinionated_porcelain/l2yi5tn/\n\nI assume the same trick applies to other mode-maps as well.", - "created_datetime": "2024-05-08 10:04:15+00:00" + "upvotes": 11, + "body": "** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q][\ud83d\udd17]] \n*Votes* 11\n\nNot from me, but I just wanted to share /u/arthurno1 one-line tip to get ~which-key~ to work with ~dired~ (see screenshot in linked post):\n\nhttps://www.reddit.com/r/emacs/comments/1clvkfe/announcing_casual_dired_an_opinionated_porcelain/l2yi5tn/\n\nI assume the same trick applies to other mode-maps as well.", + "created_datetime": "2024-05-08 11:04:15+00:00" }, "t1_l359pqx": { "author": "AdjointFunctor", @@ -115,44 +115,44 @@ }, "t1_l2cv5cx": { "author": "pt-guzzardo", - "upvotes": 8, - "body": "** u/pt-guzzardo [[https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx][\ud83d\udd17]] \n*Votes* 8\n\n#+BEGIN_SRC elisp\n(defun copy-source-for-reddit ()\n (interactive)\n (let ((contents (buffer-substring (point) (mark))))\n (with-temp-buffer\n (insert contents)\n (mark-whole-buffer)\n (indent-rigidly (point) (mark) 4 t)\n (mark-whole-buffer)\n (kill-ring-save 0 0 t))))\n\n#+END_SRC\nA handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer.", - "created_datetime": "2024-05-03 05:14:49+00:00" + "upvotes": 9, + "body": "** u/pt-guzzardo [[https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx][\ud83d\udd17]] \n*Votes* 9\n\n#+BEGIN_SRC elisp\n(defun copy-source-for-reddit ()\n (interactive)\n (let ((contents (buffer-substring (point) (mark))))\n (with-temp-buffer\n (insert contents)\n (mark-whole-buffer)\n (indent-rigidly (point) (mark) 4 t)\n (mark-whole-buffer)\n (kill-ring-save 0 0 t))))\n\n#+END_SRC\nA handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer.", + "created_datetime": "2024-05-03 06:14:49+00:00" }, "t1_l11l7he": { "author": "remillard", "upvotes": 12, "body": "** u/remillard [[https://www.reddit.com/r/emacs/comments/t3_1cbsvxd/comment/t1_l11l7he][\ud83d\udd17]] \n*Votes* 12\n\nI thought about making a whole post about this, but it's mostly ancillary appreciation so maybe this is a better place. Anyhow, for anyone working with code projects, I'm finding that project.el is completely supplanting my previously heavy use of Treemacs. I liked Treemacs because it's a very similar feel to the file/project sidebar in Sublime Text and VSCode (and others I'm sure). It was kind of reassuring. And dired is nice for many things, but navigating a lot of directories does get a little tedious compared to just opening nested directories in Treemacs. \n\nWell, I don't even remember why I started tinkering with project.el. I think I read a post where someone described switching projects, so I set it up, figured couldn't hurt. Man, definitely a good idea. The \"project goto file\" (~C-x p f~) is insanely convenient. I also have ctags support setup so a quick keybind will let me switch files based on definition, and between the two, I get through files across the project seamlessly. The project find directory is a faster way to direct dired to a place where I do want to see where things are stored.\n\nI suspect completion is doing a lot of heavy lifting here though too, so a perfectly pristine project.el use might have a different experience, but those are quite common anymore.\n\nAnyway, I haven't popped open the Treemacs sidebar in weeks now, and just felt like I should write something in case someone was curious about how handy it was.", - "created_datetime": "2024-04-24 13:46:10+00:00" + "created_datetime": "2024-04-24 14:46:10+00:00" }, "t1_kywimnf": { "author": "geza42", "upvotes": 21, "body": "** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_1c0gg7n/comment/t1_kywimnf][\ud83d\udd17]] \n*Votes* 21\n\nYasnippet has the capability of surrounding. For example, if you have this C++ namespace snippet:\n\n#+BEGIN_SRC elisp\n# -*- mode: snippet -*-\n# name: namespace-surround\n# key: ns\n# --\nnamespace ${1}${1:$(if (> (length yas-text) 0) \" {\" \"{\")}\n~yas-selected-text~$0\n} // namespace${1:$(if (> (length yas-text) 0) (concat \" \" (substring-no-properties yas-text)) \"\")}\n\n#+END_SRC\nThen if you bind ~(yas-expand-snippet (yas-lookup-snippet \"namespace-surround\"))~ to some key, then you can select some code, press your keybinding, and the selected code will be surrounded by \"namespace NAME {\" and \"} // namespace NAME\".\n\nhttps://i.redd.it/fbsbbr98smtc1.gif", - "created_datetime": "2024-04-10 10:43:05+00:00" + "created_datetime": "2024-04-10 11:43:05+00:00" }, "t1_kxur0j8": { "author": "saltwaterflyguy", - "upvotes": 11, - "body": "** u/saltwaterflyguy [[https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8][\ud83d\udd17]] \n*Votes* 11\n\ndescribe-\\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v.\n\nIf you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions.", - "created_datetime": "2024-04-03 13:59:07+00:00" + "upvotes": 10, + "body": "** u/saltwaterflyguy [[https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8][\ud83d\udd17]] \n*Votes* 10\n\ndescribe-\\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v.\n\nIf you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions.", + "created_datetime": "2024-04-03 14:59:07+00:00" }, "t1_kuo1f9y": { "author": "vkazanov", - "upvotes": 17, - "body": "** u/vkazanov [[https://www.reddit.com/r/emacs/comments/t3_1bdm6mc/comment/t1_kuo1f9y][\ud83d\udd17]] \n*Votes* 17\n\nA dump of my Emacs-related principles after 18 years of tinkering:\n\n1. Don't try to replicate a static IDE setup, Emacs is fluid. \n2. Emacs Lisp is inevitable for Emacser to make this fluidity possible.\n3. Language-agnostic is better than language-specific. \n4. Embrace display-alist, fast window manipulation, winner-mode. \n5. .emacs.el reset every couple of years to accomodate innovation. \n6. Org-mode/org-roam for all documentation, projects, tips. The agenda is not set in stone. Use queries, filters, tweak, evolve things. \n7. A contextual dwim is always better than many keybindings. \n8. Use completion everywhere on everything (vertico is magic). \n9. Contribute to the core and favourite packages.\n\nI am a beginner though, things might change.", + "upvotes": 18, + "body": "** u/vkazanov [[https://www.reddit.com/r/emacs/comments/t3_1bdm6mc/comment/t1_kuo1f9y][\ud83d\udd17]] \n*Votes* 18\n\nA dump of my Emacs-related principles after 18 years of tinkering:\n\n1. Don't try to replicate a static IDE setup, Emacs is fluid. \n2. Emacs Lisp is inevitable for Emacser to make this fluidity possible.\n3. Language-agnostic is better than language-specific. \n4. Embrace display-alist, fast window manipulation, winner-mode. \n5. .emacs.el reset every couple of years to accomodate innovation. \n6. Org-mode/org-roam for all documentation, projects, tips. The agenda is not set in stone. Use queries, filters, tweak, evolve things. \n7. A contextual dwim is always better than many keybindings. \n8. Use completion everywhere on everything (vertico is magic). \n9. Contribute to the core and favourite packages.\n\nI am a beginner though, things might change.", "created_datetime": "2024-03-13 12:33:07+00:00" }, "t1_ktogga6": { "author": "demosthenex", - "upvotes": 9, - "body": "** u/demosthenex [[https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6][\ud83d\udd17]] \n*Votes* 9\n\nM-x ielm Use the repl while learning elisp coding. I had no idea!", + "upvotes": 8, + "body": "** u/demosthenex [[https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6][\ud83d\udd17]] \n*Votes* 8\n\nM-x ielm Use the repl while learning elisp coding. I had no idea!", "created_datetime": "2024-03-06 22:30:32+00:00" }, "t1_ksifwh1": { "author": "geza42", - "upvotes": 11, - "body": "** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1][\ud83d\udd17]] \n*Votes* 11\n\nIf you use an LSP server with semantic highlighting, it's worth checking out the value of ~font-lock-maximum-decoration~. For example, I use ~c++-mode~ with ~lsp-mode~ (with clangd), I decreased ~font-lock-maximum-decoration~ to ~2~, and I didn't notice any highlighting difference (because the lost highlighting by ~c++-mode~ gets highlighted by ~lsp-mode~), while ~c++-mode~ font-locking become faster (~c++-mode~ 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone).\n\nI use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~", + "upvotes": 12, + "body": "** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1][\ud83d\udd17]] \n*Votes* 12\n\nIf you use an LSP server with semantic highlighting, it's worth checking out the value of ~font-lock-maximum-decoration~. For example, I use ~c++-mode~ with ~lsp-mode~ (with clangd), I decreased ~font-lock-maximum-decoration~ to ~2~, and I didn't notice any highlighting difference (because the lost highlighting by ~c++-mode~ gets highlighted by ~lsp-mode~), while ~c++-mode~ font-locking become faster (~c++-mode~ 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone).\n\nI use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~", "created_datetime": "2024-02-28 09:17:26+00:00" }, "t1_kphrvz3": { @@ -163,32 +163,32 @@ }, "t1_kpct4cp": { "author": "[deleted]", - "upvotes": 9, - "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp][\ud83d\udd17]] \n*Votes* 9\n\nMany of you probably know of this, but I found \"indirect buffers\" useful.\n\nWhen I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the \"folding\" and \"narrow\" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow ~C-x n s~ into different headings of the file in different windows.\n\nIndirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that ~C-x 4 c C-x n s~ did what I wanted.", + "upvotes": 10, + "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp][\ud83d\udd17]] \n*Votes* 10\n\nMany of you probably know of this, but I found \"indirect buffers\" useful.\n\nWhen I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the \"folding\" and \"narrow\" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow ~C-x n s~ into different headings of the file in different windows.\n\nIndirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that ~C-x 4 c C-x n s~ did what I wanted.", "created_datetime": "2024-02-07 17:14:26+00:00" }, "t1_kjcu7vp": { "author": "badmaxton", - "upvotes": 9, - "body": "** u/badmaxton [[https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp][\ud83d\udd17]] \n*Votes* 9\n\nJust added this to the ~:init~ section of my embark configuration:\n\n#+BEGIN_SRC elisp\n(define-key minibuffer-local-map [C-tab] 'embark-select)\n\n#+END_SRC\nThis allows super-convenient marking of entries for later ~embark-all~ using control-tab, instead of having to go first through the ~embark~ menu. (By default, this key binding is mapped to ~file-cache-minibuffer-complete~, which I never use.)", + "upvotes": 10, + "body": "** u/badmaxton [[https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp][\ud83d\udd17]] \n*Votes* 10\n\nJust added this to the ~:init~ section of my embark configuration:\n\n#+BEGIN_SRC elisp\n(define-key minibuffer-local-map [C-tab] 'embark-select)\n\n#+END_SRC\nThis allows super-convenient marking of entries for later ~embark-all~ using control-tab, instead of having to go first through the ~embark~ menu. (By default, this key binding is mapped to ~file-cache-minibuffer-complete~, which I never use.)", "created_datetime": "2024-01-24 14:54:35+00:00" }, "t1_kibmgv2": { "author": "lesliesrussell", "upvotes": 9, - "body": "** u/lesliesrussell [[https://www.reddit.com/r/emacs/comments/t3_198rnkj/comment/t1_kibmgv2][\ud83d\udd17]] \n*Votes* 9\n\n[transient map for movement](https://gist.github.com/lesliesrussell/46302d413fcf49e9717eeea57fdadcbf)\n\nDefines a transient keymap for movement controls and sets up a global key binding to activate this transient map. This transient map, \\~my-movement-transient-map\\~, includes bindings for various movement commands like moving forward or backward by a word or character and moving to the next or previous line. The \\~activate-my-movement-map\\~ function is defined to activate this transient map, and it is globally bound to \\~C-f\\~.\n\n​\n\nThis setup allows you to press \\~C-f\\~ followed by one of the specified keys (\\~f\\~, \\~b\\~, \\~c\\~, \\~l\\~, \\~n\\~, \\~p\\~) to perform the corresponding movement operation. The \\~set-transient-map\\~ call with a second argument of \\~t\\~ ensures that the transient map stays active until one of its keys is pressed.\n\n​\n\nThis is a neat way to create a custom, modal-like interface for movement within Emacs, leveraging your Emacs Lisp skills to tailor your editing environment to your preferences. If you have any specific modifications or additional features you'd like to implement, feel free to ask!\n\nI didn't want to drop code in the thread so i put it in a gist", + "body": "** u/lesliesrussell [[https://www.reddit.com/r/emacs/comments/t3_198rnkj/comment/t1_kibmgv2][\ud83d\udd17]] \n*Votes* 9\n\n[[https://gist.github.com/lesliesrussell/46302d413fcf49e9717eeea57fdadcbf][transient map for movement]]\n\nDefines a transient keymap for movement controls and sets up a global key binding to activate this transient map. This transient map, \\~my-movement-transient-map\\~, includes bindings for various movement commands like moving forward or backward by a word or character and moving to the next or previous line. The \\~activate-my-movement-map\\~ function is defined to activate this transient map, and it is globally bound to \\~C-f\\~.\n\n​\n\nThis setup allows you to press \\~C-f\\~ followed by one of the specified keys (\\~f\\~, \\~b\\~, \\~c\\~, \\~l\\~, \\~n\\~, \\~p\\~) to perform the corresponding movement operation. The \\~set-transient-map\\~ call with a second argument of \\~t\\~ ensures that the transient map stays active until one of its keys is pressed.\n\n​\n\nThis is a neat way to create a custom, modal-like interface for movement within Emacs, leveraging your Emacs Lisp skills to tailor your editing environment to your preferences. If you have any specific modifications or additional features you'd like to implement, feel free to ask!\n\nI didn't want to drop code in the thread so i put it in a gist", "created_datetime": "2024-01-17 19:20:18+00:00" }, "t1_khe4dq6": { "author": "JDRiverRun", - "upvotes": 11, - "body": "** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6][\ud83d\udd17]] \n*Votes* 11\n\nI have long had convenience bindings for ~org-emphasize~ like ~super-i~ for /italic/, that match system bindings. But I always wanted these to *be smarter*, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not.\n\n[Check out my solution](https://gist.github.com/jdtsmith/55e6a660dd4c0779a600ac81bf9bfc23) (scroll down to see how it acts). Will miss this behavior in other apps!", + "upvotes": 12, + "body": "** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6][\ud83d\udd17]] \n*Votes* 12\n\nI have long had convenience bindings for ~org-emphasize~ like ~super-i~ for /italic/, that match system bindings. But I always wanted these to *be smarter*, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not.\n\n[[https://gist.github.com/jdtsmith/55e6a660dd4c0779a600ac81bf9bfc23][Check out my solution]] (scroll down to see how it acts). Will miss this behavior in other apps!", "created_datetime": "2024-01-11 17:47:10+00:00" }, "t1_kg4ni5d": { "author": "algor512", - "upvotes": 12, - "body": "** u/algor512 [[https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d][\ud83d\udd17]] \n*Votes* 12\n\nRecently I discovered that ~C-h C-q~ (or ~M-x help-quick~) opens a small window showing \\*Quick Help\\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable ~help-quick-sections~.\n\nI intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of ~help-quick-sections~.", + "upvotes": 11, + "body": "** u/algor512 [[https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d][\ud83d\udd17]] \n*Votes* 11\n\nRecently I discovered that ~C-h C-q~ (or ~M-x help-quick~) opens a small window showing \\*Quick Help\\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable ~help-quick-sections~.\n\nI intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of ~help-quick-sections~.", "created_datetime": "2024-01-03 14:24:47+00:00" }, "t1_kgce54q": { @@ -205,8 +205,8 @@ }, "t1_kdobd72": { "author": "ayy_ess", - "upvotes": 13, - "body": "** u/ayy_ess [[https://www.reddit.com/r/emacs/comments/t3_18hc301/comment/t1_kdobd72][\ud83d\udd17]] \n*Votes* 13\n\nI recently discovered ~(setq read-minibuffer-restore-windows nil)~ which resolves my frustration that quitting the minibuffer would discard any changes to the window layout while the minibuffer was open. For example, by default, ~M-x C-h k k C-g~ quits the just opened help buffer. I'm sure to have missed many more QOL improvements from NEWS.", + "upvotes": 12, + "body": "** u/ayy_ess [[https://www.reddit.com/r/emacs/comments/t3_18hc301/comment/t1_kdobd72][\ud83d\udd17]] \n*Votes* 12\n\nI recently discovered ~(setq read-minibuffer-restore-windows nil)~ which resolves my frustration that quitting the minibuffer would discard any changes to the window layout while the minibuffer was open. For example, by default, ~M-x C-h k k C-g~ quits the just opened help buffer. I'm sure to have missed many more QOL improvements from NEWS.", "created_datetime": "2023-12-16 22:15:37+00:00" }, "t1_kahspwz": { @@ -223,21 +223,21 @@ }, "t1_k8c4mz7": { "author": "Netherus", - "upvotes": 9, - "body": "** u/Netherus [[https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7][\ud83d\udd17]] \n*Votes* 9\n\nJust recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me.", + "upvotes": 8, + "body": "** u/Netherus [[https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7][\ud83d\udd17]] \n*Votes* 8\n\nJust recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me.", "created_datetime": "2023-11-08 09:29:31+00:00" }, "t1_k4g09iw": { "author": "WorldsEndless", "upvotes": 16, "body": "** u/WorldsEndless [[https://www.reddit.com/r/emacs/comments/t3_1758wua/comment/t1_k4g09iw][\ud83d\udd17]] \n*Votes* 16\n\n~(delete-blank-lines)~ ~(C-x C-o)~ is massively useful; I use it every day for text cleanup. Press it once and it deletes all but one blank line. Press it twice and it deletes that one, too.", - "created_datetime": "2023-10-11 17:29:26+00:00" + "created_datetime": "2023-10-11 18:29:26+00:00" }, "t1_k2gb81l": { "author": "alvarogonzalezs", "upvotes": 14, "body": "** u/alvarogonzalezs [[https://www.reddit.com/r/emacs/comments/t3_16tes2a/comment/t1_k2gb81l][\ud83d\udd17]] \n*Votes* 14\n\nIf you need to find all the occurrences of a string in the project files, but only **on some specific type of files**, you can use ~consult-ripgrep~ with ~-- -t~ in the search pattern.\n\nFor example, If you need occurrences of ~fancystr~ in files of type ~html~, the search pattern should be ~fancystr -- -t html~\n\nFrom ~consult-grep~ documentation, command line options can be passed to grep, specified behind ~--.~ The overall prompt input has the form:\n\n#+BEGIN_SRC elisp\n#async-input -- rg-opts#filter-string\n\n#+END_SRC\nI have just discovered this, and it made my day.", - "created_datetime": "2023-09-27 16:43:12+00:00" + "created_datetime": "2023-09-27 17:43:12+00:00" }, "t1_k1803gl": { "author": "AP145", @@ -247,74 +247,74 @@ }, "t1_jxekm3a": { "author": "frosch03", - "upvotes": 10, - "body": "** u/frosch03 [[https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a][\ud83d\udd17]] \n*Votes* 10\n\nVery useful, but I keep forgetting it:\n\nIf you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: ~C-x -~\n\nAnd if you want to balance these two buffers again just use ~C-x +~", - "created_datetime": "2023-08-23 12:37:15+00:00" + "upvotes": 8, + "body": "** u/frosch03 [[https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a][\ud83d\udd17]] \n*Votes* 8\n\nVery useful, but I keep forgetting it:\n\nIf you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: ~C-x -~\n\nAnd if you want to balance these two buffers again just use ~C-x +~", + "created_datetime": "2023-08-23 13:37:15+00:00" }, "t1_jwff8bw": { "author": "PriorOutcome", - "upvotes": 11, - "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_15sjm3k/comment/t1_jwff8bw][\ud83d\udd17]] \n*Votes* 11\n\nI've been slowly accumulating cases for \"flexing\" the thing at point as a more general ~capitalize-word~ replacement:\n\n#+BEGIN_SRC elisp\n;; Stolen from the wiki somewhere\n(defun increment-number-at-point ()\n \"Increment the number at point.\"\n (interactive)\n (skip-chars-backward \"0-9\")\n (or (looking-at \"[0-9]+\")\n (error \"No number at point\"))\n (replace-match (number-to-string (1+ (string-to-number (match-string 0))))))\n \n(defun lw-flex ()\n \"Perform smart flexing at point.\n \nE.g. capitalize or decapitalize the next word, increment number at point.\"\n (interactive)\n (let ((case-fold-search nil))\n (call-interactively\n (cond ((looking-at \"[0-9]+\") #'increment-number-at-point)\n ((looking-at \"[[:lower:]]\") #'capitalize-word)\n ((looking-at \"==\") (delete-char 1) (insert \"!\") (forward-char 2))\n ((looking-at \"!=\") (delete-char 1) (insert \"=\") (forward-char 2))\n ((looking-at \"+\") (delete-char 1) (insert \"-\") (forward-char 1))\n ((looking-at \"-\") (delete-char 1) (insert \"+\") (forward-char 1))\n ((looking-at \"<=\") (delete-char 2) (insert \">=\") (forward-char 2))\n ((looking-at \">=\") (delete-char 2) (insert \"<=\") (forward-char 2))\n ((looking-at \"<\") (delete-char 1) (insert \">\") (forward-char 1))\n ((looking-at \">\") (delete-char 1) (insert \"<\") (forward-char 1))\n (t #'downcase-word)))))\n\n#+END_SRC\nI bind it to ~M-c~.", - "created_datetime": "2023-08-16 13:29:50+00:00" + "upvotes": 10, + "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_15sjm3k/comment/t1_jwff8bw][\ud83d\udd17]] \n*Votes* 10\n\nI've been slowly accumulating cases for \"flexing\" the thing at point as a more general ~capitalize-word~ replacement:\n\n#+BEGIN_SRC elisp\n;; Stolen from the wiki somewhere\n(defun increment-number-at-point ()\n \"Increment the number at point.\"\n (interactive)\n (skip-chars-backward \"0-9\")\n (or (looking-at \"[0-9]+\")\n (error \"No number at point\"))\n (replace-match (number-to-string (1+ (string-to-number (match-string 0))))))\n \n(defun lw-flex ()\n \"Perform smart flexing at point.\n \nE.g. capitalize or decapitalize the next word, increment number at point.\"\n (interactive)\n (let ((case-fold-search nil))\n (call-interactively\n (cond ((looking-at \"[0-9]+\") #'increment-number-at-point)\n ((looking-at \"[[:lower:]]\") #'capitalize-word)\n ((looking-at \"==\") (delete-char 1) (insert \"!\") (forward-char 2))\n ((looking-at \"!=\") (delete-char 1) (insert \"=\") (forward-char 2))\n ((looking-at \"+\") (delete-char 1) (insert \"-\") (forward-char 1))\n ((looking-at \"-\") (delete-char 1) (insert \"+\") (forward-char 1))\n ((looking-at \"<=\") (delete-char 2) (insert \">=\") (forward-char 2))\n ((looking-at \">=\") (delete-char 2) (insert \"<=\") (forward-char 2))\n ((looking-at \"<\") (delete-char 1) (insert \">\") (forward-char 1))\n ((looking-at \">\") (delete-char 1) (insert \"<\") (forward-char 1))\n (t #'downcase-word)))))\n\n#+END_SRC\nI bind it to ~M-c~.", + "created_datetime": "2023-08-16 14:29:50+00:00" }, "t1_jpwn2ts": { "author": "gusbrs", - "upvotes": 9, - "body": "** u/gusbrs [[https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts][\ud83d\udd17]] \n*Votes* 9\n\nI was converting some old ~.odt~ notes files to ~.org~ today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: ~repunctuate-sentences~. I have no idea if this is new or has always been there. It is new to me. It uses ~query-replace-regexp~, so it's the same experience. And also can be configured for exclusions with ~repunctuate-sentences-filter~. Neat!", - "created_datetime": "2023-06-28 20:43:42+00:00" + "upvotes": 10, + "body": "** u/gusbrs [[https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts][\ud83d\udd17]] \n*Votes* 10\n\nI was converting some old ~.odt~ notes files to ~.org~ today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: ~repunctuate-sentences~. I have no idea if this is new or has always been there. It is new to me. It uses ~query-replace-regexp~, so it's the same experience. And also can be configured for exclusions with ~repunctuate-sentences-filter~. Neat!", + "created_datetime": "2023-06-28 21:43:42+00:00" }, "t1_jl5zu6z": { "author": "leothrix", - "upvotes": 14, - "body": "** u/leothrix [[https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z][\ud83d\udd17]] \n*Votes* 14\n\nFor ~use-package~ users (which I assume is many of us), did you know that profiling is easy to do? I'm not talking about ~esup~, but a built-in capability that makes it very straightforward to find places to optimize your ~init.el~ for significantly faster start times.\n\nEnable ~use-package-compute-statistics~ right after you load ~use-package~:\n\n#+BEGIN_SRC elisp\n(setq use-package-compute-statistics t)\n\n#+END_SRC\nRestart emacs, and then invoke ~use-package-report~. You'll get a table of the load times for each package that ~use-package~ manages. I discovered this and found an immediate way to cut my startup time in half by fixing a few packages that weren't deferred properly by adding the right ~:hook~ keyword.", - "created_datetime": "2023-05-22 15:23:11+00:00" + "upvotes": 13, + "body": "** u/leothrix [[https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z][\ud83d\udd17]] \n*Votes* 13\n\nFor ~use-package~ users (which I assume is many of us), did you know that profiling is easy to do? I'm not talking about ~esup~, but a built-in capability that makes it very straightforward to find places to optimize your ~init.el~ for significantly faster start times.\n\nEnable ~use-package-compute-statistics~ right after you load ~use-package~:\n\n#+BEGIN_SRC elisp\n(setq use-package-compute-statistics t)\n\n#+END_SRC\nRestart emacs, and then invoke ~use-package-report~. You'll get a table of the load times for each package that ~use-package~ manages. I discovered this and found an immediate way to cut my startup time in half by fixing a few packages that weren't deferred properly by adding the right ~:hook~ keyword.", + "created_datetime": "2023-05-22 16:23:11+00:00" }, "t1_jhrzybp": { "author": "BunnyLushington", "upvotes": 9, - "body": "** u/BunnyLushington [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhrzybp][\ud83d\udd17]] \n*Votes* 9\n\nI found myself debugging [JWTs](https://jwt.io) earlier this week and whomped up a little function to decode them from a region into a help buffer.\n\n#+BEGIN_SRC elisp\n(defun ii/decode-jwt (start end &optional jwt)\n \"Decode JWT in region and print to help buffer.\"\n (interactive \"r\")\n (let* ((tok (if jwt jwt\n (buffer-substring start end)))\n (data (s-split \"\\\\.\" tok))\n (header (car data))\n (claims (cadr data)))\n(with-temp-buffer\n (insert (format \"%s\\n\\n%s\"\n (base64-decode-string header t)\n (base64-decode-string claims t)))\n (json-pretty-print-buffer)\n (with-output-to-temp-buffer \"*JWT*\"\n (princ (buffer-string)))))\n t)\n#+END_SRC\n\nI'd forgotten about ~with-output-to-temp-buffer~ which is pretty handy. The ~t~ at the end is there just to suppress an overly large echo area message.\n\n(This should be obvious but note that the JWT is not validated or verified. This is intended for debugging only and the JWT should not be trusted.)", - "created_datetime": "2023-04-26 12:36:06+00:00" + "body": "** u/BunnyLushington [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhrzybp][\ud83d\udd17]] \n*Votes* 9\n\nI found myself debugging [[https://jwt.io][JWTs]] earlier this week and whomped up a little function to decode them from a region into a help buffer.\n\n#+BEGIN_SRC elisp\n(defun ii/decode-jwt (start end &optional jwt)\n \"Decode JWT in region and print to help buffer.\"\n (interactive \"r\")\n (let* ((tok (if jwt jwt\n (buffer-substring start end)))\n (data (s-split \"\\\\.\" tok))\n (header (car data))\n (claims (cadr data)))\n(with-temp-buffer\n (insert (format \"%s\\n\\n%s\"\n (base64-decode-string header t)\n (base64-decode-string claims t)))\n (json-pretty-print-buffer)\n (with-output-to-temp-buffer \"*JWT*\"\n (princ (buffer-string)))))\n t)\n#+END_SRC\n\nI'd forgotten about ~with-output-to-temp-buffer~ which is pretty handy. The ~t~ at the end is there just to suppress an overly large echo area message.\n\n(This should be obvious but note that the JWT is not validated or verified. This is intended for debugging only and the JWT should not be trusted.)", + "created_datetime": "2023-04-26 13:36:06+00:00" }, "t1_jgwlxuw": { "author": "WorldsEndless", "upvotes": 18, "body": "** u/WorldsEndless [[https://www.reddit.com/r/emacs/comments/t3_12rlq4a/comment/t1_jgwlxuw][\ud83d\udd17]] \n*Votes* 18\n\nOften when literate programming I want to split up a code block, maybe copy-pasted with multiple functions in it, into separate blocks so I can put some text in between them. The command, with cursor within a ~BEGIN_SRC~ block, is ~org-babel-demarcate-block~ ~(C-c C-v d)~.", - "created_datetime": "2023-04-19 17:32:30+00:00" + "created_datetime": "2023-04-19 18:32:30+00:00" }, "t1_jg34ody": { "author": "alvarogonzalezs", "upvotes": 18, "body": "** u/alvarogonzalezs [[https://www.reddit.com/r/emacs/comments/t3_12jexep/comment/t1_jg34ody][\ud83d\udd17]] \n*Votes* 18\n\nI'm a big user of ~ffap~. I use this function with ~M-x~ each time I want to open a file whose name is under the cursor.\n\nBut this week I discovered ~ffap-bindings~. This function replaces some key bindings to use ~ffap~ when it makes sense. For example, it replaces ~find-file~ with ~find-file-at-point~, so the usual keybindings are enriched at no cost.", - "created_datetime": "2023-04-13 12:41:30+00:00" + "created_datetime": "2023-04-13 13:41:30+00:00" }, "t1_jf167qh": { "author": "AndreaSomePostfix", - "upvotes": 19, - "body": "** u/AndreaSomePostfix [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh][\ud83d\udd17]] \n*Votes* 19\n\norg-mode is amazing!\n\nI discovered \\~org-copy-visible\\~ the other day, when I wanted to send somebody only the outline of my notes.\n\nThat function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful!", - "created_datetime": "2023-04-05 09:56:21+00:00" + "upvotes": 18, + "body": "** u/AndreaSomePostfix [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh][\ud83d\udd17]] \n*Votes* 18\n\norg-mode is amazing!\n\nI discovered \\~org-copy-visible\\~ the other day, when I wanted to send somebody only the outline of my notes.\n\nThat function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful!", + "created_datetime": "2023-04-05 10:56:21+00:00" }, "t1_jf3ohpv": { "author": "sauntcartas", - "upvotes": 9, - "body": "** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv][\ud83d\udd17]] \n*Votes* 9\n\nI work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice:\n\n#+BEGIN_SRC elisp\n(defun default-to-main-project (dir)\n (or dir *main-project-dir*))\n\n(advice-add 'projectile-ensure-project :override #'default-to-main-project)\n\n#+END_SRC\nI lose some of the functionality of ~projectile-ensure-project~, but I never used it anyway.", - "created_datetime": "2023-04-05 20:53:04+00:00" + "upvotes": 10, + "body": "** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv][\ud83d\udd17]] \n*Votes* 10\n\nI work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice:\n\n#+BEGIN_SRC elisp\n(defun default-to-main-project (dir)\n (or dir *main-project-dir*))\n\n(advice-add 'projectile-ensure-project :override #'default-to-main-project)\n\n#+END_SRC\nI lose some of the functionality of ~projectile-ensure-project~, but I never used it anyway.", + "created_datetime": "2023-04-05 21:53:04+00:00" }, "t1_jc9t4tc": { "author": "PriorOutcome", - "upvotes": 13, - "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc][\ud83d\udd17]] \n*Votes* 13\n\nPlain old ~query-replace~ has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain ~y~/~n~:\n\n~!~: replaces all remaning matches\n\n~u~: undo last replacement\n\n~E~: changes replacement string on the fly\n\nAnd many more you can see using ~?~.", + "upvotes": 14, + "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc][\ud83d\udd17]] \n*Votes* 14\n\nPlain old ~query-replace~ has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain ~y~/~n~:\n\n~!~: replaces all remaning matches\n\n~u~: undo last replacement\n\n~E~: changes replacement string on the fly\n\nAnd many more you can see using ~?~.", "created_datetime": "2023-03-15 09:20:08+00:00" }, "t1_jca66k0": { "author": "slinchisl", - "upvotes": 9, - "body": "** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jca66k0][\ud83d\udd17]] \n*Votes* 9\n\nI'm once again reminded of the utility of ~read-key~ for small functions where one wants a nicer interface for choosing an alternative than universal arguments; taking an optional prompt, it simply reads a key from the keyboard and returns it.\n\nFor example, I recently wanted a function that prints a set of predefined dates for me into the current buffer, and it was as easy as\n\n#+BEGIN_SRC elisp\n(defun slot/insert-time ()\n (interactive)\n (let* ((formats '((?i \"ISO 8601\" \"%Y-%m-%d\")\n (?l \"DDmmmYYYY\" \"%d%b%Y\")\n (?t \"Time\" \"%H:%M\")))\n (key (read-key\n (cl-loop for (key label _) in formats\n concat (format \"[%s] %s \"\n (propertize (single-key-description key) 'face 'bold)\n label)))))\n (->> (alist-get key formats)\n cl-second\n format-time-string\n downcase ; Jan -> jan\n insert)))\n#+END_SRC", + "upvotes": 8, + "body": "** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jca66k0][\ud83d\udd17]] \n*Votes* 8\n\nI'm once again reminded of the utility of ~read-key~ for small functions where one wants a nicer interface for choosing an alternative than universal arguments; taking an optional prompt, it simply reads a key from the keyboard and returns it.\n\nFor example, I recently wanted a function that prints a set of predefined dates for me into the current buffer, and it was as easy as\n\n#+BEGIN_SRC elisp\n(defun slot/insert-time ()\n (interactive)\n (let* ((formats '((?i \"ISO 8601\" \"%Y-%m-%d\")\n (?l \"DDmmmYYYY\" \"%d%b%Y\")\n (?t \"Time\" \"%H:%M\")))\n (key (read-key\n (cl-loop for (key label _) in formats\n concat (format \"[%s] %s \"\n (propertize (single-key-description key) 'face 'bold)\n label)))))\n (->> (alist-get key formats)\n cl-second\n format-time-string\n downcase ; Jan -> jan\n insert)))\n#+END_SRC", "created_datetime": "2023-03-15 11:56:11+00:00" }, "t1_jbe06qv": { "author": "geza42", - "upvotes": 14, - "body": "** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_11lqkbo/comment/t1_jbe06qv][\ud83d\udd17]] \n*Votes* 14\n\nYou can toggle vertico's height between 15 and \"almost full frame\" with this. When vertico is invoked, it will always have a height of 15. But if you have a lot of matches, and like to have a better overview, press the binding, and vertico will show a full frame of matches. This is useful for example when ~consult-buffer~ presents a lot of buffers.\n\n#+BEGIN_SRC elisp\n(advice-add 'vertico--setup :before (lambda () (setq vertico-count 15)))\n(define-key minibuffer-local-map (kbd \"s-'\") (lambda ()\n (interactive)\n (let ((vertico-resize t))\n (setq vertico-count (if (= vertico-count 15) (- (frame-height) 5) 15))\n (vertico--exhibit))))\n\n#+END_SRC\nAnother useful feature is to kill buffers in ~consult-buffer~ without manually invoking ~embark-act~. I miss this feature from Helm, where you can do actions using only one binding (no need to press an intermediate binding which invokes ~embark-act~). Note, I just blindly copied some of the logic from ~embark~, maybe there are some unnecessary things here.\n\n#+BEGIN_SRC elisp\n(defun my-embark-M-k (&optional arg)\n (interactive \"P\")\n (require 'embark)\n (if-let ((targets (embark--targets)))\n (let* ((target\n (or (nth\n (if (or (null arg) (minibufferp))\n 0\n (mod (prefix-numeric-value arg) (length targets)))\n targets)))\n (type (plist-get target :type)))\n (cond\n ((eq type 'buffer)\n (let ((embark-pre-action-hooks))\n (embark--act 'kill-buffer target)))))))\n\n(define-key minibuffer-local-map (kbd \"M-k\") 'my-embark-M-k)\n\n#+END_SRC\nI'm not sure whether these two can be achieved out-of-the box, but I didn't find these functionalities, so I created them.", + "upvotes": 13, + "body": "** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_11lqkbo/comment/t1_jbe06qv][\ud83d\udd17]] \n*Votes* 13\n\nYou can toggle vertico's height between 15 and \"almost full frame\" with this. When vertico is invoked, it will always have a height of 15. But if you have a lot of matches, and like to have a better overview, press the binding, and vertico will show a full frame of matches. This is useful for example when ~consult-buffer~ presents a lot of buffers.\n\n#+BEGIN_SRC elisp\n(advice-add 'vertico--setup :before (lambda () (setq vertico-count 15)))\n(define-key minibuffer-local-map (kbd \"s-'\") (lambda ()\n (interactive)\n (let ((vertico-resize t))\n (setq vertico-count (if (= vertico-count 15) (- (frame-height) 5) 15))\n (vertico--exhibit))))\n\n#+END_SRC\nAnother useful feature is to kill buffers in ~consult-buffer~ without manually invoking ~embark-act~. I miss this feature from Helm, where you can do actions using only one binding (no need to press an intermediate binding which invokes ~embark-act~). Note, I just blindly copied some of the logic from ~embark~, maybe there are some unnecessary things here.\n\n#+BEGIN_SRC elisp\n(defun my-embark-M-k (&optional arg)\n (interactive \"P\")\n (require 'embark)\n (if-let ((targets (embark--targets)))\n (let* ((target\n (or (nth\n (if (or (null arg) (minibufferp))\n 0\n (mod (prefix-numeric-value arg) (length targets)))\n targets)))\n (type (plist-get target :type)))\n (cond\n ((eq type 'buffer)\n (let ((embark-pre-action-hooks))\n (embark--act 'kill-buffer target)))))))\n\n(define-key minibuffer-local-map (kbd \"M-k\") 'my-embark-M-k)\n\n#+END_SRC\nI'm not sure whether these two can be achieved out-of-the box, but I didn't find these functionalities, so I created them.", "created_datetime": "2023-03-08 10:59:31+00:00" }, "t1_jajfxc9": { @@ -331,8 +331,8 @@ }, "t1_j8mo1bz": { "author": "[deleted]", - "upvotes": 10, - "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz][\ud83d\udd17]] \n*Votes* 10\n\nPut the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press)\n\nWin - Alt - Ctrl - Space - Ctrl - Alt - Win", + "upvotes": 9, + "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz][\ud83d\udd17]] \n*Votes* 9\n\nPut the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press)\n\nWin - Alt - Ctrl - Space - Ctrl - Alt - Win", "created_datetime": "2023-02-15 13:05:13+00:00" }, "t1_j8mpo5y": { @@ -343,26 +343,26 @@ }, "t1_j8u1ebf": { "author": "SlowValue", - "upvotes": 9, - "body": "** u/SlowValue [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8u1ebf][\ud83d\udd17]] \n*Votes* 9\n\nI put a couple of similar functions on my ~~ key (with all combinations of modifier keys) and tend to forget the meanings of those combinations.\n\nSo I made a small function to give some help for a list of keybindings.:\n\n#+BEGIN_SRC elisp\n(defun my-generate-keybind-doc-on-keys (&rest keys)\n \"generate help on some given keybindings (kbd style).\"\n (substring\n (apply #'concat\n (mapcar #'(lambda (key)\n (let* ((fun (key-binding (kbd key)))\n (fun-name (symbol-name fun))\n (doc (documentation fun 'raw))\n (oneline (substring doc 0 (string-match \"\\n\" doc))))\n (put-text-property 0 (length key) 'face 'font-lock-keyword-face key)\n (put-text-property 0 (length fun-name) 'face 'font-lock-function-name-face fun-name)\n (put-text-property 0 (length oneline) 'face 'font-lock-doc-face oneline)\n (format \"%10s : %-30s \u2192 %s\\n\" key fun-name oneline)))\n keys))\n 0 -1))\n\n#+END_SRC\nTo show that help in the echo buffer, one needs to define a command, which can be bound to a key:\n\n#+BEGIN_SRC elisp\n(defun my-show-help-on-some-keys ()\n \"demo generate help on 3 keys\"\n (interactive)\n (message (my-generate-keybind-doc-on-keys \"C-s\"\n \" k\"\n \"C-c !\")))\n\n#+END_SRC\nThen calling the command ~my-show-help-on-some-keys~, shows following message in the echo buffer:\n\n#+BEGIN_SRC elisp\n C-s : isearch-forward \u2192 Do incremental search forward.\n k : helpful-key \u2192 Show help for interactive command bound to KEY-SEQUENCE.\n C-c ! : shell-here \u2192 Open a shell relative to default-directory.\n\n\n#+END_SRC\nRemark: I know that ~which-key~ exists, but I'm already above that level of knowledge and don't need ~which-key~ anymore.", + "upvotes": 8, + "body": "** u/SlowValue [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8u1ebf][\ud83d\udd17]] \n*Votes* 8\n\nI put a couple of similar functions on my ~~ key (with all combinations of modifier keys) and tend to forget the meanings of those combinations.\n\nSo I made a small function to give some help for a list of keybindings.:\n\n#+BEGIN_SRC elisp\n(defun my-generate-keybind-doc-on-keys (&rest keys)\n \"generate help on some given keybindings (kbd style).\"\n (substring\n (apply #'concat\n (mapcar #'(lambda (key)\n (let* ((fun (key-binding (kbd key)))\n (fun-name (symbol-name fun))\n (doc (documentation fun 'raw))\n (oneline (substring doc 0 (string-match \"\\n\" doc))))\n (put-text-property 0 (length key) 'face 'font-lock-keyword-face key)\n (put-text-property 0 (length fun-name) 'face 'font-lock-function-name-face fun-name)\n (put-text-property 0 (length oneline) 'face 'font-lock-doc-face oneline)\n (format \"%10s : %-30s \u2192 %s\\n\" key fun-name oneline)))\n keys))\n 0 -1))\n\n#+END_SRC\nTo show that help in the echo buffer, one needs to define a command, which can be bound to a key:\n\n#+BEGIN_SRC elisp\n(defun my-show-help-on-some-keys ()\n \"demo generate help on 3 keys\"\n (interactive)\n (message (my-generate-keybind-doc-on-keys \"C-s\"\n \" k\"\n \"C-c !\")))\n\n#+END_SRC\nThen calling the command ~my-show-help-on-some-keys~, shows following message in the echo buffer:\n\n#+BEGIN_SRC elisp\n C-s : isearch-forward \u2192 Do incremental search forward.\n k : helpful-key \u2192 Show help for interactive command bound to KEY-SEQUENCE.\n C-c ! : shell-here \u2192 Open a shell relative to default-directory.\n\n\n#+END_SRC\nRemark: I know that ~which-key~ exists, but I'm already above that level of knowledge and don't need ~which-key~ anymore.", "created_datetime": "2023-02-16 23:05:11+00:00" }, "t1_ja41lso": { "author": "AnugNef4", "upvotes": 10, - "body": "** u/AnugNef4 [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_ja41lso][\ud83d\udd17]] \n*Votes* 10\n\nHow I got my Info Directory node ~C-h i~ to display all my installed .info files living under ~/opt/homebrew~ on an M1 Mac. I run emacs-plus@29 from [d12frosted on github](https://github.com/d12frosted/homebrew-emacs-plus).\n\ninit.el snippet\n\n#+BEGIN_SRC elisp\n(require 'info)\n(info-initialize)\n(push \"/opt/homebrew/share/info\" Info-directory-list)\n\n#+END_SRC\nrun this shell script to update the Directory node.\n\n#+BEGIN_SRC elisp\n#!/usr/bin/env bash\n \nINFO_DIR=\"/opt/homebrew/share/info\"\nwhile read -r f; do\n install-info --debug --keep-old \"$f\" \"$INFO_DIR\"/dir\ndone <<< $(find /opt/homebrew/Cellar -name \\*.info)\n#+END_SRC", + "body": "** u/AnugNef4 [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_ja41lso][\ud83d\udd17]] \n*Votes* 10\n\nHow I got my Info Directory node ~C-h i~ to display all my installed .info files living under ~/opt/homebrew~ on an M1 Mac. I run emacs-plus@29 from [[https://github.com/d12frosted/homebrew-emacs-plus][d12frosted on github]].\n\ninit.el snippet\n\n#+BEGIN_SRC elisp\n(require 'info)\n(info-initialize)\n(push \"/opt/homebrew/share/info\" Info-directory-list)\n\n#+END_SRC\nrun this shell script to update the Directory node.\n\n#+BEGIN_SRC elisp\n#!/usr/bin/env bash\n \nINFO_DIR=\"/opt/homebrew/share/info\"\nwhile read -r f; do\n install-info --debug --keep-old \"$f\" \"$INFO_DIR\"/dir\ndone <<< $(find /opt/homebrew/Cellar -name \\*.info)\n#+END_SRC", "created_datetime": "2023-02-26 18:09:57+00:00" }, "t1_j6rmvvf": { "author": "PriorOutcome", - "upvotes": 32, - "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_10qo7vb/comment/t1_j6rmvvf][\ud83d\udd17]] \n*Votes* 32\n\nWhen you have an active region, ~undo~ will only undo changes in that region instead of the whole file.", + "upvotes": 31, + "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_10qo7vb/comment/t1_j6rmvvf][\ud83d\udd17]] \n*Votes* 31\n\nWhen you have an active region, ~undo~ will only undo changes in that region instead of the whole file.", "created_datetime": "2023-02-01 12:19:16+00:00" }, "t1_j5umed8": { "author": "eleven_cupfuls", "upvotes": 12, - "body": "** u/eleven_cupfuls [[https://www.reddit.com/r/emacs/comments/t3_10ktqj0/comment/t1_j5umed8][\ud83d\udd17]] \n*Votes* 12\n\nI jump into the built-in Elisp files a lot to see how things work. The indentation there is GNU standard, which uses a mix of tabs and spaces for alignment. The tabs have to be rendered as 8 spaces wide for the alignment to work, and I don't actually want that setting anywhere else. Since the files on Mac are inside the application bundle, I don't want to just add a .dir-locals.el file next to them, either.\n\n[Directory classes](https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html) to the rescue! My config makes a new directory variable class, ~builtin-elisp~, with a list saying that ~emacs-lisp-mode~ should use a ~tab-width~ of 8. Then it applies that class to the Elisp files in the application bundle:\n\n#+BEGIN_SRC elisp\n(use-package elisp-mode\n :config\n (dir-locals-set-class-variables\n 'builtin-elisp\n '((emacs-lisp-mode . ((tab-width . 8)))))\n (dir-locals-set-directory-class\n (file-name-directory (directory-file-name (invocation-directory)))\n 'builtin-elisp))\n\n#+END_SRC\nAnd now when I visit one of those files, the alignment is always correct.", + "body": "** u/eleven_cupfuls [[https://www.reddit.com/r/emacs/comments/t3_10ktqj0/comment/t1_j5umed8][\ud83d\udd17]] \n*Votes* 12\n\nI jump into the built-in Elisp files a lot to see how things work. The indentation there is GNU standard, which uses a mix of tabs and spaces for alignment. The tabs have to be rendered as 8 spaces wide for the alignment to work, and I don't actually want that setting anywhere else. Since the files on Mac are inside the application bundle, I don't want to just add a .dir-locals.el file next to them, either.\n\n[[https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html][Directory classes]] to the rescue! My config makes a new directory variable class, ~builtin-elisp~, with a list saying that ~emacs-lisp-mode~ should use a ~tab-width~ of 8. Then it applies that class to the Elisp files in the application bundle:\n\n#+BEGIN_SRC elisp\n(use-package elisp-mode\n :config\n (dir-locals-set-class-variables\n 'builtin-elisp\n '((emacs-lisp-mode . ((tab-width . 8)))))\n (dir-locals-set-directory-class\n (file-name-directory (directory-file-name (invocation-directory)))\n 'builtin-elisp))\n\n#+END_SRC\nAnd now when I visit one of those files, the alignment is always correct.", "created_datetime": "2023-01-25 18:04:19+00:00" }, "t1_j420ea0": { @@ -392,7 +392,7 @@ "t1_iw00xhx": { "author": "andyjda", "upvotes": 10, - "body": "** u/andyjda [[https://www.reddit.com/r/emacs/comments/t3_yqciht/comment/t1_iw00xhx][\ud83d\udd17]] \n*Votes* 10\n\nI started using ~god-mode~, but I found it hard to get used to it at first: there was no easy way to check what command would be triggered by what key-sequence. \n\nI wrote up a ~god-mode~\\-specific ~describe-key~, which translates ~god-mode~ key-sequences into commands and shows their usual description. I think it's a great way to get familiar with how the package handles keys, and it allows users to invoke ~describe-key~ without leaving god-mode (previously, most keys would just show information about the generic ~god-mode-self-insert-command~)\n\nI also reached out to the package's maintainers, and this feature (after some tweaking) [just got added to the master branch](https://github.com/emacsorphanage/god-mode). It was a great way to get familiar with ~god-mode~ code and its behavior, and I'm happy to have made my first contribution to an Emacs package.", + "body": "** u/andyjda [[https://www.reddit.com/r/emacs/comments/t3_yqciht/comment/t1_iw00xhx][\ud83d\udd17]] \n*Votes* 10\n\nI started using ~god-mode~, but I found it hard to get used to it at first: there was no easy way to check what command would be triggered by what key-sequence. \n\nI wrote up a ~god-mode~\\-specific ~describe-key~, which translates ~god-mode~ key-sequences into commands and shows their usual description. I think it's a great way to get familiar with how the package handles keys, and it allows users to invoke ~describe-key~ without leaving god-mode (previously, most keys would just show information about the generic ~god-mode-self-insert-command~)\n\nI also reached out to the package's maintainers, and this feature (after some tweaking) [[https://github.com/emacsorphanage/god-mode][just got added to the master branch]]. It was a great way to get familiar with ~god-mode~ code and its behavior, and I'm happy to have made my first contribution to an Emacs package.", "created_datetime": "2022-11-11 21:53:51+00:00" }, "t1_itw7yp2": { @@ -422,7 +422,7 @@ "t1_iqb2fci": { "author": "com4", "upvotes": 14, - "body": "** u/com4 [[https://www.reddit.com/r/emacs/comments/t3_xq6rpa/comment/t1_iqb2fci][\ud83d\udd17]] \n*Votes* 14\n\nIn preparation for the inclusion of eglot into Emacs core I've switched away from lsp-mode. As a result I've also switched from flycheck and to flymake. One nice thing about flycheck is that it allowed for stacking checkers. When coding Python I liked to stack flake8 for styles and mypy for types (plus the LSP's since it's already there).\n\nFlymake allows for stacking checkers but it turns out eglot clobbers these checkers when \"adding\" the LSP's checker. To get stacked Flymake checkers with Eglot you can simply add them back after Eglot has done it's thing.\n\nFor example, here is a simple setup for Python which includes Pyright's type checking and flake8 style checking\n\n#+BEGIN_SRC elisp\n;; Use flake8 as the python style checker by default\n(setq python-flymake-command '(\"flake8\" \"-\"))\n \n(use-package eglot\n :hook ((python-mode . eglot-ensure)\n (eglot-managed-mode\n\t . (lambda ()\n\t ;; re-enable flymake checkers because eglot clobbers\n\t ;; them when starting\n\t (when (derived-mode-p 'python-mode)\n\t\t(add-hook 'flymake-diagnostic-functions \n 'python-flymake nil t)))))\n \n :custom\n ;; shutdown server after killing last managed buffer\n (eglot-autoshutdown t)\n :bind\n ((\"C-c l r\" . eglot-rename))\n :config\n (add-to-list 'eglot-server-programs\n ~(python-mode \"pyright-langserver\" \"-w\" \"--stdio\")))\n\n#+END_SRC\nNow all that's left is mypy. Flymake originally used a [\"Proc\"](https://www.gnu.org/software/emacs/manual/html_mono/flymake.html#The-legacy-Proc-backend) method for creating checkers which existing mypy ones use. So for a bonus tip & trick [I've written a mypy checker in the new style](http://github.com/com4/flymake-mypy). It can be enabled when using eglot like this:\n\n#+BEGIN_SRC elisp\n(use-package flymake-mypy\n :straight (flymake-mypy\n :type git\n :host github\n :repo \"com4/flymake-mypy\")\n :hook ((eglot-managed-mode . (lambda ()\n\t\t\t\t (when (derived-mode-p 'python-mode)\n\t\t\t\t (flymake-mypy-enable))))))\n\n#+END_SRC\nAfter opening a Python buffer and executing ~M-x flymake-running-backends~ we are greeted with a list of stacked checkers: ~Running backends: eglot-flymake-backend, flymake-mypy--run, python-flymake~.", + "body": "** u/com4 [[https://www.reddit.com/r/emacs/comments/t3_xq6rpa/comment/t1_iqb2fci][\ud83d\udd17]] \n*Votes* 14\n\nIn preparation for the inclusion of eglot into Emacs core I've switched away from lsp-mode. As a result I've also switched from flycheck and to flymake. One nice thing about flycheck is that it allowed for stacking checkers. When coding Python I liked to stack flake8 for styles and mypy for types (plus the LSP's since it's already there).\n\nFlymake allows for stacking checkers but it turns out eglot clobbers these checkers when \"adding\" the LSP's checker. To get stacked Flymake checkers with Eglot you can simply add them back after Eglot has done it's thing.\n\nFor example, here is a simple setup for Python which includes Pyright's type checking and flake8 style checking\n\n#+BEGIN_SRC elisp\n;; Use flake8 as the python style checker by default\n(setq python-flymake-command '(\"flake8\" \"-\"))\n \n(use-package eglot\n :hook ((python-mode . eglot-ensure)\n (eglot-managed-mode\n\t . (lambda ()\n\t ;; re-enable flymake checkers because eglot clobbers\n\t ;; them when starting\n\t (when (derived-mode-p 'python-mode)\n\t\t(add-hook 'flymake-diagnostic-functions \n 'python-flymake nil t)))))\n \n :custom\n ;; shutdown server after killing last managed buffer\n (eglot-autoshutdown t)\n :bind\n ((\"C-c l r\" . eglot-rename))\n :config\n (add-to-list 'eglot-server-programs\n ~(python-mode \"pyright-langserver\" \"-w\" \"--stdio\")))\n\n#+END_SRC\nNow all that's left is mypy. Flymake originally used a [[https://www.gnu.org/software/emacs/manual/html_mono/flymake.html#The-legacy-Proc-backend][\"Proc\"]] method for creating checkers which existing mypy ones use. So for a bonus tip & trick [[http://github.com/com4/flymake-mypy][I've written a mypy checker in the new style]]. It can be enabled when using eglot like this:\n\n#+BEGIN_SRC elisp\n(use-package flymake-mypy\n :straight (flymake-mypy\n :type git\n :host github\n :repo \"com4/flymake-mypy\")\n :hook ((eglot-managed-mode . (lambda ()\n\t\t\t\t (when (derived-mode-p 'python-mode)\n\t\t\t\t (flymake-mypy-enable))))))\n\n#+END_SRC\nAfter opening a Python buffer and executing ~M-x flymake-running-backends~ we are greeted with a list of stacked checkers: ~Running backends: eglot-flymake-backend, flymake-mypy--run, python-flymake~.", "created_datetime": "2022-09-29 01:27:25+00:00" }, "t1_ioeh1ly": { @@ -446,7 +446,7 @@ "t1_iof00tz": { "author": "trae", "upvotes": 8, - "body": "\\** u/trae [[https://www.reddit.com/r/emacs/comments/t3_xdw6ok/comment/t1_iof00tz][\ud83d\udd17]] \n\\*Votes* 8\n\nHey folks,\n\nIs there a package/piece of code out there to:\n1. pop up a frame \n2. execute arbitrary code \n3. close frame on completion\n\nKind of like [emacs-everywhere](https://github.com/tecosaur/emacs-everywhere/) but for arbitrary code.", + "body": "\\** u/trae [[https://www.reddit.com/r/emacs/comments/t3_xdw6ok/comment/t1_iof00tz][\ud83d\udd17]] \n\\*Votes* 8\n\nHey folks,\n\nIs there a package/piece of code out there to:\n1. pop up a frame \n2. execute arbitrary code \n3. close frame on completion\n\nKind of like [[https://github.com/tecosaur/emacs-everywhere/][emacs-everywhere]] but for arbitrary code.", "created_datetime": "2022-09-14 17:38:59+00:00" }, "t1_innk62a": { @@ -464,7 +464,7 @@ "t1_imi3kzz": { "author": "PriorOutcome", "upvotes": 20, - "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imi3kzz][\ud83d\udd17]] \n*Votes* 20\n\nUpdate from a couple of weeks ago: after some grinding, I've set the parsing of past comments from this thread to auto update on a weekly basis here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md)\n\nI've also fixed the broken highlighting of some code snippets, and hopefully parsed all past threads. There's 200+ comments there (sorted by upvotes), so ctrl-f ing e.g. \\~magit\\~ may help you if you're looking for something specific", + "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imi3kzz][\ud83d\udd17]] \n*Votes* 20\n\nUpdate from a couple of weeks ago: after some grinding, I've set the parsing of past comments from this thread to auto update on a weekly basis here: [[https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md][https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md]]\n\nI've also fixed the broken highlighting of some code snippets, and hopefully parsed all past threads. There's 200+ comments there (sorted by upvotes), so ctrl-f ing e.g. \\~magit\\~ may help you if you're looking for something specific", "created_datetime": "2022-08-31 10:59:48+00:00" }, "t1_ilotsc5": { @@ -494,7 +494,7 @@ "t1_ikrx30z": { "author": "PriorOutcome", "upvotes": 9, - "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_ikrx30z][\ud83d\udd17]] \n*Votes* 9\n\nI've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md)\n\nIf you fancy procrastinating for a bit today...", + "body": "** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_ikrx30z][\ud83d\udd17]] \n*Votes* 9\n\nI've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: [[https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md][https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md]]\n\nIf you fancy procrastinating for a bit today...", "created_datetime": "2022-08-18 10:47:40+00:00" }, "t1_iirl0ea": { @@ -536,7 +536,7 @@ "t1_iauyzbl": { "author": "tryptych", "upvotes": 17, - "body": "** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_v2by7z/comment/t1_iauyzbl][\ud83d\udd17]] \n*Votes* 17\n\nIt's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [post about it](https://blog.markhepburn.com/posts/understanding-use-package-optimisations/). There's a few posts around suggesting features of ~use-package~ to optimise startup, but none of them really explained how they tied back to ~autoload~, ~eval-after-load~, etc so I was trying to encourage people to dig out ~macroexpand~ and find out.", + "body": "** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_v2by7z/comment/t1_iauyzbl][\ud83d\udd17]] \n*Votes* 17\n\nIt's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [[https://blog.markhepburn.com/posts/understanding-use-package-optimisations/][post about it]]. There's a few posts around suggesting features of ~use-package~ to optimise startup, but none of them really explained how they tied back to ~autoload~, ~eval-after-load~, etc so I was trying to encourage people to dig out ~macroexpand~ and find out.", "created_datetime": "2022-06-02 02:27:48+00:00" }, "t1_iarzi1s": { @@ -554,7 +554,7 @@ "t1_i9xcaoa": { "author": "slinchisl", "upvotes": 8, - "body": "\\** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_uxcm6i/comment/t1_i9xcaoa][\ud83d\udd17]] \n\\*Votes* 8\n\n[arxiv-citation](https://github.com/slotthe/arxiv-citation) from my [last post](https://old.reddit.com/r/emacs/comments/ufvg93/my_phd_research_workflowemacs_inside/) is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)!\n\nOn that note, I've written a little bit about [calling Emacs from XMonad](https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html). The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful.", + "body": "\\** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_uxcm6i/comment/t1_i9xcaoa][\ud83d\udd17]] \n\\*Votes* 8\n\n[[https://github.com/slotthe/arxiv-citation][arxiv-citation]] from my [[https://old.reddit.com/r/emacs/comments/ufvg93/my_phd_research_workflowemacs_inside/][last post]] is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)!\n\nOn that note, I've written a little bit about [[https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html][calling Emacs from XMonad]]. The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful.", "created_datetime": "2022-05-25 13:11:34+00:00" }, "t1_i92mn8w": { @@ -566,7 +566,7 @@ "t1_i928gaj": { "author": "diamondnbond", "upvotes": 8, - "body": "** u/diamondnbond [[https://www.reddit.com/r/emacs/comments/t3_us7zae/comment/t1_i928gaj][\ud83d\udd17]] \n*Votes* 8\n\n[I Recently discovered engine-mode.](https://github.com/DiamondBond/emacs/blob/master/config.org#initialize-engine-mode)", + "body": "** u/diamondnbond [[https://www.reddit.com/r/emacs/comments/t3_us7zae/comment/t1_i928gaj][\ud83d\udd17]] \n*Votes* 8\n\n[[https://github.com/DiamondBond/emacs/blob/master/config.org#initialize-engine-mode][I Recently discovered engine-mode.]]", "created_datetime": "2022-05-18 12:38:59+00:00" }, "t1_i86hwzi": { @@ -578,7 +578,7 @@ "t1_i88sp07": { "author": "mmarshall540", "upvotes": 8, - "body": "\\** u/mmarshall540 [[https://www.reddit.com/r/emacs/comments/t3_un4wf8/comment/t1_i88sp07][\ud83d\udd17]] \n\\*Votes* 8\n\nHere's a little solution to a minor complaint about `isearch` that I think is fairly common.\n\n# The Problem\n\nTLDR: See [this old StackExchange question](https://emacs.stackexchange.com/questions/32373/go-to-start-of-search-string-after-ret)\n\nOften, I'll want to go to a precise location in a buffer to correct a typo. If that location is behind point (as it usually is if I notice the typo shortly after entering it), then `isearch-backward` works great. You press \"C-r\" and type some characters starting with your target until the location becomes the current result. As soon as the cursor jumps to your target location, you can use an editing command like \"C-t\", which exits isearch automatically for you. Or you can press \"C-m\" to exit isearch-mode and then start inserting text at that location. Wonderful!\n\nBut it's a little less perfect when your target is *after* point. This is because with `isearch-forward`, point lands at the end of your search result, instead of the beginning as it does with `isearch-backward`.\n\nYou could type your search starting with some arbitrary number of characters in front of the target. But then you have to decide in advance how many characters to use, and if you don't use enough, there might be too many results. And then if you have to keep typing past your target character to sufficiently narrow the results, point won't land where you want it.\n\nAnother strategy would be to do the same thing as when searching backwards, start with the target character and just type characters until your target location is selected. But now point is at the other end of the result, instead of where you want it. \"M-b\" would exit and move point to the beginning of the word, but that assumes there are no word boundaries in your search result, and besides, your actual target won't always be the beginning of a word. Often it will be somewhere in the middle of a word.\n\nOr you could use C-r to move point to the beginning of the result. But then you still have to press C-m to exit the search and start inserting text at that location. And that's 2 key-presses just to finish your search, not to mention all the key-presses you did to start.\n\nSo we can fix this.\n\n# My Solution\n\n#+BEGIN_SRC elisp\n(defun my/isearch-bor-exit ()\n \"Ensure point is at beginning of isearch result, then exit.\"\n (interactive)\n (when (< isearch-other-end (point))\n (goto-char isearch-other-end))\n (call-interactively 'isearch-exit))\n \n(define-key isearch-mode-map ?\\M-m 'my/isearch-bor-exit)\n\n#+END_SRC\nSo now if I'm using isearch to get to a precise location (as opposed to just searching for a word), I can type beginning with the character at the target location, stop typing after it becomes part of the result, and press \"M-m\" to exit the search and make my correction. No more having to stop and think about whether I'm going backwards or forwards and whether I'll have to move point back before exiting isearch.\n\n# The Conclusion\n\nA minor problem with a fairly simple solution, but it made me happy to stop and solve it.\n\nI think I'll be using isearch now for a lot of things that I used to use Avy for. But Avy is still great for a bunch of reasons. Not the least of which is the `avy-isearch` command which comes in handy when there are a lot of isearch results that would require too much typing to narrow down. (And it always puts point at the beginning of the result, never at the end).", + "body": "\\** u/mmarshall540 [[https://www.reddit.com/r/emacs/comments/t3_un4wf8/comment/t1_i88sp07][\ud83d\udd17]] \n\\*Votes* 8\n\nHere's a little solution to a minor complaint about `isearch` that I think is fairly common.\n\n# The Problem\n\nTLDR: See [[https://emacs.stackexchange.com/questions/32373/go-to-start-of-search-string-after-ret][this old StackExchange question]]\n\nOften, I'll want to go to a precise location in a buffer to correct a typo. If that location is behind point (as it usually is if I notice the typo shortly after entering it), then `isearch-backward` works great. You press \"C-r\" and type some characters starting with your target until the location becomes the current result. As soon as the cursor jumps to your target location, you can use an editing command like \"C-t\", which exits isearch automatically for you. Or you can press \"C-m\" to exit isearch-mode and then start inserting text at that location. Wonderful!\n\nBut it's a little less perfect when your target is *after* point. This is because with `isearch-forward`, point lands at the end of your search result, instead of the beginning as it does with `isearch-backward`.\n\nYou could type your search starting with some arbitrary number of characters in front of the target. But then you have to decide in advance how many characters to use, and if you don't use enough, there might be too many results. And then if you have to keep typing past your target character to sufficiently narrow the results, point won't land where you want it.\n\nAnother strategy would be to do the same thing as when searching backwards, start with the target character and just type characters until your target location is selected. But now point is at the other end of the result, instead of where you want it. \"M-b\" would exit and move point to the beginning of the word, but that assumes there are no word boundaries in your search result, and besides, your actual target won't always be the beginning of a word. Often it will be somewhere in the middle of a word.\n\nOr you could use C-r to move point to the beginning of the result. But then you still have to press C-m to exit the search and start inserting text at that location. And that's 2 key-presses just to finish your search, not to mention all the key-presses you did to start.\n\nSo we can fix this.\n\n# My Solution\n\n#+BEGIN_SRC elisp\n(defun my/isearch-bor-exit ()\n \"Ensure point is at beginning of isearch result, then exit.\"\n (interactive)\n (when (< isearch-other-end (point))\n (goto-char isearch-other-end))\n (call-interactively 'isearch-exit))\n \n(define-key isearch-mode-map ?\\M-m 'my/isearch-bor-exit)\n\n#+END_SRC\nSo now if I'm using isearch to get to a precise location (as opposed to just searching for a word), I can type beginning with the character at the target location, stop typing after it becomes part of the result, and press \"M-m\" to exit the search and make my correction. No more having to stop and think about whether I'm going backwards or forwards and whether I'll have to move point back before exiting isearch.\n\n# The Conclusion\n\nA minor problem with a fairly simple solution, but it made me happy to stop and solve it.\n\nI think I'll be using isearch now for a lot of things that I used to use Avy for. But Avy is still great for a bunch of reasons. Not the least of which is the `avy-isearch` command which comes in handy when there are a lot of isearch results that would require too much typing to narrow down. (And it always puts point at the beginning of the result, never at the end).", "created_datetime": "2022-05-11 23:24:24+00:00" }, "t1_i3m1liu": { @@ -668,7 +668,7 @@ "t1_hmryv5o": { "author": "rucci99", "upvotes": 16, - "body": "** u/rucci99 [[https://www.reddit.com/r/emacs/comments/t3_r69w7i/comment/t1_hmryv5o][\ud83d\udd17]] \n*Votes* 16\n\nI just found out that Magit can backup changes of uncommitted files automatically. Here's the link to online manual:\n[Magit Wip Modes](https://magit.vc/manual/magit/Wip-Modes.html#Wip-Modes).", + "body": "** u/rucci99 [[https://www.reddit.com/r/emacs/comments/t3_r69w7i/comment/t1_hmryv5o][\ud83d\udd17]] \n*Votes* 16\n\nI just found out that Magit can backup changes of uncommitted files automatically. Here's the link to online manual:\n[[https://magit.vc/manual/magit/Wip-Modes.html#Wip-Modes][Magit Wip Modes]].", "created_datetime": "2021-12-01 09:04:15+00:00" }, "t1_hmst3ih": { @@ -686,7 +686,7 @@ "t1_hicheof": { "author": "tryptych", "upvotes": 8, - "body": "** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_qgrpte/comment/t1_hicheof][\ud83d\udd17]] \n*Votes* 8\n\nA colleague just showed me Intellij's \"[compare with clipboard](https://www.jetbrains.com/help/idea/comparing-files-and-folders.html#clipboard)\" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections.\n\nIt didn't take me long to implement something similar:\n\n#+BEGIN_SRC elisp\n(defun ediff-compare-region-clipboard (begin end)\n (interactive \"r\")\n (save-excursion\n (let ((selected-region (buffer-substring begin end))\n (clipboard-buffer (get-buffer-create \"*ediff-clipboard*\"))\n (region-buffer (get-buffer-create \"*ediff-region*\")))\n (with-current-buffer clipboard-buffer\n (insert (car kill-ring)))\n (with-current-buffer region-buffer\n (insert selected-region))\n (ediff-buffers clipboard-buffer region-buffer))))\n\n#+END_SRC\nIt's not ideal though. In particular, is there a better way to insert the \"clipboard\"? One thing I quickly found was that you might copy the region to compare but then so many editing commands will add to the kill-ring, so I might want to make that part of the process interactive.", + "body": "** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_qgrpte/comment/t1_hicheof][\ud83d\udd17]] \n*Votes* 8\n\nA colleague just showed me Intellij's \"[[https://www.jetbrains.com/help/idea/comparing-files-and-folders.html#clipboard][compare with clipboard]]\" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections.\n\nIt didn't take me long to implement something similar:\n\n#+BEGIN_SRC elisp\n(defun ediff-compare-region-clipboard (begin end)\n (interactive \"r\")\n (save-excursion\n (let ((selected-region (buffer-substring begin end))\n (clipboard-buffer (get-buffer-create \"*ediff-clipboard*\"))\n (region-buffer (get-buffer-create \"*ediff-region*\")))\n (with-current-buffer clipboard-buffer\n (insert (car kill-ring)))\n (with-current-buffer region-buffer\n (insert selected-region))\n (ediff-buffers clipboard-buffer region-buffer))))\n\n#+END_SRC\nIt's not ideal though. In particular, is there a better way to insert the \"clipboard\"? One thing I quickly found was that you might copy the region to compare but then so many editing commands will add to the kill-ring, so I might want to make that part of the process interactive.", "created_datetime": "2021-10-28 06:17:21+00:00" }, "t1_hi8crmc": { @@ -716,7 +716,7 @@ "t1_hghp1e4": { "author": "[deleted]", "upvotes": 9, - "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_q76kok/comment/t1_hghp1e4][\ud83d\udd17]] \n*Votes* 9\n\nCheckout [Topsy Mode](https://github.com/alphapapa/topsy.el), it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup.", + "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_q76kok/comment/t1_hghp1e4][\ud83d\udd17]] \n*Votes* 9\n\nCheckout [[https://github.com/alphapapa/topsy.el][Topsy Mode]], it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup.", "created_datetime": "2021-10-13 16:08:24+00:00" }, "t1_hfldw8n": { @@ -734,7 +734,7 @@ "t1_hf1gzs2": { "author": "Stefan-Kangas", "upvotes": 10, - "body": "** u/Stefan-Kangas [[https://www.reddit.com/r/emacs/comments/t3_pxqvtm/comment/t1_hf1gzs2][\ud83d\udd17]] \n*Votes* 10\n\nRead [SICP](https://mitpress.mit.edu/sites/default/files/sicp/index.html). Preferably in Info, installable through MELPA or: [https://github.com/webframp/sicp-info](https://github.com/webframp/sicp-info)", + "body": "** u/Stefan-Kangas [[https://www.reddit.com/r/emacs/comments/t3_pxqvtm/comment/t1_hf1gzs2][\ud83d\udd17]] \n*Votes* 10\n\nRead [[https://mitpress.mit.edu/sites/default/files/sicp/index.html][SICP]]. Preferably in Info, installable through MELPA or: [[https://github.com/webframp/sicp-info][https://github.com/webframp/sicp-info]]", "created_datetime": "2021-10-02 01:33:53+00:00" }, "t1_hexdfiq": { @@ -752,7 +752,7 @@ "t1_hc3bikc": { "author": "[deleted]", "upvotes": 8, - "body": "\\** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_pk6akd/comment/t1_hc3bikc][\ud83d\udd17]] \n\\*Votes* 8\n\nI'm using [orderless](https://github.com/oantolin/orderless) for completion but I also want to walk through files with initials only, to do something like [like this](https://imgur.com/a/CJg8MGw) for example. It only requires to ignore the case and ask the minibuffer to use initials. \n\n#+BEGIN_SRC elisp\n(use-package orderless\n :ensure t\n :custom\n (completion-styles '(orderless))\n (completion-category-defaults nil)\n (read-file-name-completion-ignore-case t)\n (completion-category-overrides '((file (styles partial-completion))\n \t\t\t\t (minibuffer (initials)))))\n#+END_SRC", + "body": "\\** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_pk6akd/comment/t1_hc3bikc][\ud83d\udd17]] \n\\*Votes* 8\n\nI'm using [[https://github.com/oantolin/orderless][orderless]] for completion but I also want to walk through files with initials only, to do something like [[https://imgur.com/a/CJg8MGw][like this]] for example. It only requires to ignore the case and ask the minibuffer to use initials. \n\n#+BEGIN_SRC elisp\n(use-package orderless\n :ensure t\n :custom\n (completion-styles '(orderless))\n (completion-category-defaults nil)\n (read-file-name-completion-ignore-case t)\n (completion-category-overrides '((file (styles partial-completion))\n \t\t\t\t (minibuffer (initials)))))\n#+END_SRC", "created_datetime": "2021-09-08 19:53:06+00:00" }, "t1_hb765zp": { @@ -848,13 +848,13 @@ "t1_gxpeh9v": { "author": "Tatrics", "upvotes": 14, - "body": "** u/Tatrics [[https://www.reddit.com/r/emacs/comments/t3_n9q662/comment/t1_gxpeh9v][\ud83d\udd17]] \n*Votes* 14\n\nI'm slowly working on an alternative shell: [https://github.com/TatriX/tshell](https://github.com/TatriX/tshell)\n\nInstead of using repl-like interface, all the commands go to one buffer (and file if you want) and output goes to another buffer. Like if you put your elisp code in \\*scratch\\* buffer and then evaluate it with \\~C-x C-e\\~.\n\nIt's in a very early stage, but it already allows me to solve most tasks I usually do with more traditional shells.\n\nLet me know what is your first impression, what can be improved and what do you think in general!", + "body": "** u/Tatrics [[https://www.reddit.com/r/emacs/comments/t3_n9q662/comment/t1_gxpeh9v][\ud83d\udd17]] \n*Votes* 14\n\nI'm slowly working on an alternative shell: [[https://github.com/TatriX/tshell][https://github.com/TatriX/tshell]]\n\nInstead of using repl-like interface, all the commands go to one buffer (and file if you want) and output goes to another buffer. Like if you put your elisp code in \\*scratch\\* buffer and then evaluate it with \\~C-x C-e\\~.\n\nIt's in a very early stage, but it already allows me to solve most tasks I usually do with more traditional shells.\n\nLet me know what is your first impression, what can be improved and what do you think in general!", "created_datetime": "2021-05-11 08:43:17+00:00" }, "t1_gv8jxz5": { "author": "[deleted]", "upvotes": 16, - "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_mujxm7/comment/t1_gv8jxz5][\ud83d\udd17]] \n*Votes* 16\n\nI use, and love, [transient](https://github.com/magit/transient). I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to ~s-w~. I use [buffer-move](https://github.com/lukhas/buffer-move) for rearranging windows in a frame.\n\n#+BEGIN_SRC elisp\n(define-transient-command transient-window ()\n \"Most commonly used window commands\"\n [[\"Splits\"\n (\"s\" \"Horizontal\" split-window-below)\n (\"v\" \"Vertical\" split-window-right)\n (\"b\" \"Balance\" balance-windows)\n (\"f\" \"Fit\" fit-window-to-buffer)\n [\"Window\"\n (\"c\" \"Clone Indirect\" clone-indirect-buffer)\n (\"t\" \"Tear Off\" tear-off-window)\n (\"k\" \"Kill\" delete-window)\n (\"K\" \"Kill Buffer+Win\" kill-buffer-and-window)\n (\"o\" \"Kill Others\" delete-other-windows)\n (\"m\" \"Maximize\" maximize-window)]\n [\"Navigate\"\n (\"\" \"\u2190\" windmove-left :transient t)\n (\"\" \"\u2192\" windmove-right :transient t)\n (\"\" \"\u2191\" windmove-up :transient t)\n (\"\" \"\u2193\" windmove-down :transient t)]\n [\"Move\"\n (\"S-\" \"S-\u2190\" buf-move-left :transient t)\n (\"S-\" \"S-\u2192\" buf-move-right :transient t)\n (\"S-\" \"S-\u2191\" buf-move-up :transient t)\n (\"S-\" \"S-\u2193\" buf-move-down :transient t)]\n [\"Undo/Redo\"\n (\"s-z\" \"Winner Undo\" winner-undo :transient t)\n (\"s-Z\" \"Winner Redo\" winner-redo :transient t)]])\n#+END_SRC", + "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_mujxm7/comment/t1_gv8jxz5][\ud83d\udd17]] \n*Votes* 16\n\nI use, and love, [[https://github.com/magit/transient][transient]]. I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to ~s-w~. I use [[https://github.com/lukhas/buffer-move][buffer-move]] for rearranging windows in a frame.\n\n#+BEGIN_SRC elisp\n(define-transient-command transient-window ()\n \"Most commonly used window commands\"\n [[\"Splits\"\n (\"s\" \"Horizontal\" split-window-below)\n (\"v\" \"Vertical\" split-window-right)\n (\"b\" \"Balance\" balance-windows)\n (\"f\" \"Fit\" fit-window-to-buffer)\n [\"Window\"\n (\"c\" \"Clone Indirect\" clone-indirect-buffer)\n (\"t\" \"Tear Off\" tear-off-window)\n (\"k\" \"Kill\" delete-window)\n (\"K\" \"Kill Buffer+Win\" kill-buffer-and-window)\n (\"o\" \"Kill Others\" delete-other-windows)\n (\"m\" \"Maximize\" maximize-window)]\n [\"Navigate\"\n (\"\" \"\u2190\" windmove-left :transient t)\n (\"\" \"\u2192\" windmove-right :transient t)\n (\"\" \"\u2191\" windmove-up :transient t)\n (\"\" \"\u2193\" windmove-down :transient t)]\n [\"Move\"\n (\"S-\" \"S-\u2190\" buf-move-left :transient t)\n (\"S-\" \"S-\u2192\" buf-move-right :transient t)\n (\"S-\" \"S-\u2191\" buf-move-up :transient t)\n (\"S-\" \"S-\u2193\" buf-move-down :transient t)]\n [\"Undo/Redo\"\n (\"s-z\" \"Winner Undo\" winner-undo :transient t)\n (\"s-Z\" \"Winner Redo\" winner-redo :transient t)]])\n#+END_SRC", "created_datetime": "2021-04-20 20:17:23+00:00" }, "t1_gufsfeu": { @@ -878,7 +878,7 @@ "t1_gstteeo": { "author": "[deleted]", "upvotes": 14, - "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_mg98ki/comment/t1_gstteeo][\ud83d\udd17]] \n*Votes* 14\n\nI just discovered the [selected](https://github.com/Kungsgeten/selected.el) package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode.", + "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_mg98ki/comment/t1_gstteeo][\ud83d\udd17]] \n*Votes* 14\n\nI just discovered the [[https://github.com/Kungsgeten/selected.el][selected]] package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode.", "created_datetime": "2021-03-30 19:24:51+00:00" }, "t1_gry6bfs": { @@ -920,7 +920,7 @@ "t1_gj33uht": { "author": "jumpUpHigh", "upvotes": 11, - "body": "** u/jumpUpHigh [[https://www.reddit.com/r/emacs/comments/t3_kvmmq3/comment/t1_gj33uht][\ud83d\udd17]] \n*Votes* 11\n\nAucTeX\n\nWhen you compile your TeX file and there are errors, the message asks you to see error messages using\n\n#+BEGIN_SRC elisp\n C-c ~\n\n#+END_SRC\nThis leads to the last error which is sometimes incomprehensible and you are left to yourself to figure out what went wrong.\n\nInstead of getting the last error, you can get an overview of all the errors by setting below variable to ~t~:\n\n#+BEGIN_SRC elisp\n (setq TeX-error-overview-open-after-TeX-run t)\n\n#+END_SRC\nYou can pop this up in a separate frame using:\n\n#+BEGIN_SRC elisp\n (setq TeX-error-overview-setup 'separate-frame)\n\n#+END_SRC\nRelated docs are [here](https://www.gnu.org/software/auctex/manual/auctex/Error-overview.html).\n\nThis totally changes the way you can handle errors messages.", + "body": "** u/jumpUpHigh [[https://www.reddit.com/r/emacs/comments/t3_kvmmq3/comment/t1_gj33uht][\ud83d\udd17]] \n*Votes* 11\n\nAucTeX\n\nWhen you compile your TeX file and there are errors, the message asks you to see error messages using\n\n#+BEGIN_SRC elisp\n C-c ~\n\n#+END_SRC\nThis leads to the last error which is sometimes incomprehensible and you are left to yourself to figure out what went wrong.\n\nInstead of getting the last error, you can get an overview of all the errors by setting below variable to ~t~:\n\n#+BEGIN_SRC elisp\n (setq TeX-error-overview-open-after-TeX-run t)\n\n#+END_SRC\nYou can pop this up in a separate frame using:\n\n#+BEGIN_SRC elisp\n (setq TeX-error-overview-setup 'separate-frame)\n\n#+END_SRC\nRelated docs are [[https://www.gnu.org/software/auctex/manual/auctex/Error-overview.html][here]].\n\nThis totally changes the way you can handle errors messages.", "created_datetime": "2021-01-13 05:44:51+00:00" }, "t1_gj1kn9i": { @@ -944,7 +944,7 @@ "t1_gfxbwgy": { "author": "[deleted]", "upvotes": 8, - "body": "\\** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfxbwgy][\ud83d\udd17]] \n\\*Votes* 8\n\nI tried [marginalia](https://github.com/minad/marginalia) with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings.", + "body": "\\** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfxbwgy][\ud83d\udd17]] \n\\*Votes* 8\n\nI tried [[https://github.com/minad/marginalia][marginalia]] with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings.", "created_datetime": "2020-12-15 14:54:55+00:00" }, "t1_gfwlm9q": { @@ -998,7 +998,7 @@ "t1_g69no38": { "author": "[deleted]", "upvotes": 9, - "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_ixjcau/comment/t1_g69no38][\ud83d\udd17]] \n*Votes* 9\n\norg-variable-pitch.el users might want to give [~valign~](https://github.com/casouri/valign) a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add ~org-link~ to ~org-variable-pitch-fixed-faces~ because valign-mode handles variable pitch links neatly in tables.\n\nIf you don't use OVP but use e.g. latex fragments in tables or just pictures, this one is still very helpful.\n\nKudos to the author, great little package.", + "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_ixjcau/comment/t1_g69no38][\ud83d\udd17]] \n*Votes* 9\n\norg-variable-pitch.el users might want to give [[https://github.com/casouri/valign][~valign~]] a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add ~org-link~ to ~org-variable-pitch-fixed-faces~ because valign-mode handles variable pitch links neatly in tables.\n\nIf you don't use OVP but use e.g. latex fragments in tables or just pictures, this one is still very helpful.\n\nKudos to the author, great little package.", "created_datetime": "2020-09-23 00:54:54+00:00" }, "t1_g3zeprg": { @@ -1010,7 +1010,7 @@ "t1_g1zlh2t": { "author": "kastauyra", "upvotes": 11, - "body": "** u/kastauyra [[https://www.reddit.com/r/emacs/comments/t3_ibwzcu/comment/t1_g1zlh2t][\ud83d\udd17]] \n*Votes* 11\n\n# 27.1 do GC if no frame has focus\n\nI am porting my [config](https://github.com/laurynas-biveinis/dotfiles) from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [MatthewZMD's config](https://github.com/MatthewZMD/.emacs.d) I think:\n#+BEGIN_SRC elispelisp\n(add-hook 'focus-out-hook #'garbage-collect)\n#+END_SRC\n27.1 NEWS say more generic (and more correct) ~after-focus-change-function~ should be used instead. Which pointed out that I do not want to GC on just any frame going out of focus, if another frame is being focused instead. It might be a better idea to GC if no frames at all are focused. Somewhat surprisingly I was not able to find any public dotfiles repo implementing this to copy paste from, so I tried to write my own:\n#+BEGIN_SRC elispelisp\n(defun dotfiles--gc-on-last-frame-out-of-focus ()\n \"GC if all frames are inactive.\"\n (if (seq-every-p #'null (mapcar #'frame-focus-state (frame-list)))\n (garbage-collect)))\n\n(add-function :after after-focus-change-function\n #'dotfiles--gc-on-last-frame-out-of-focus)\n#+END_SRC", + "body": "** u/kastauyra [[https://www.reddit.com/r/emacs/comments/t3_ibwzcu/comment/t1_g1zlh2t][\ud83d\udd17]] \n*Votes* 11\n\n# 27.1 do GC if no frame has focus\n\nI am porting my [[https://github.com/laurynas-biveinis/dotfiles][config]] from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [[https://github.com/MatthewZMD/.emacs.d][MatthewZMD's config]] I think:\n#+BEGIN_SRC elispelisp\n(add-hook 'focus-out-hook #'garbage-collect)\n#+END_SRC\n27.1 NEWS say more generic (and more correct) ~after-focus-change-function~ should be used instead. Which pointed out that I do not want to GC on just any frame going out of focus, if another frame is being focused instead. It might be a better idea to GC if no frames at all are focused. Somewhat surprisingly I was not able to find any public dotfiles repo implementing this to copy paste from, so I tried to write my own:\n#+BEGIN_SRC elispelisp\n(defun dotfiles--gc-on-last-frame-out-of-focus ()\n \"GC if all frames are inactive.\"\n (if (seq-every-p #'null (mapcar #'frame-focus-state (frame-list)))\n (garbage-collect)))\n\n(add-function :after after-focus-change-function\n #'dotfiles--gc-on-last-frame-out-of-focus)\n#+END_SRC", "created_datetime": "2020-08-18 16:02:25+00:00" }, "t1_fyrgnk7": { @@ -1028,7 +1028,7 @@ "t1_fy0xduj": { "author": "ji99", "upvotes": 8, - "body": "** u/ji99 [[https://www.reddit.com/r/emacs/comments/t3_hqxm5v/comment/t1_fy0xduj][\ud83d\udd17]] \n*Votes* 8\n\nHippie-expand google search suggestions. Completely inspired from [shell-parse.el](https://github.com/malloc47/shell-parse.el/blob/master/shell-parse.el).\n\nI've added ~try-expand-google-completion~ to the bottom of my ~hippie-expand-try-functions-list~\n\n#+BEGIN_SRC elisp\n(defun google-suggest--request (query)\n (with-current-buffer\n (url-retrieve-synchronously\n (format \"http://suggestqueries.google.com/complete/search?client=firefox&q=%s\" query) t t 1)\n (goto-char (point-min))\n (re-search-forward \"^$\")\n (delete-region (point)(point-min))(buffer-string)))\n \n(defun google-suggest--list (result)\n (let* ((q (progn\n (string-match \",\\\\[\\\\(.*?\\\\)\\\\]\" result)\n (match-string 1 result)))\n (r (replace-regexp-in-string \"\\\\\\\"\" \"\" q))\n (l (split-string r \",\" t)))\n (when (> (length (car (cdr l))) 0)\n (remove\n (car l)\n (cdr l)))))\n \n(defun try-expand-google-completion (old)\n (unless old\n (he-init-string (hippie-word-bg) (point))\n (setq he-expand-list (sort\n (all-completions\n he-search-string\n (lambda (s y n) (google-suggest--list (google-suggest--request s))))\n 'string-lessp)))\n (if (null he-expand-list)\n (progn\n (when old (he-reset-string))\n ())\n (he-substitute-string (car he-expand-list) t)\n (setq he-tried-table (cons (car he-expand-list) (cdr he-tried-table)))\n (setq he-expand-list (cdr he-expand-list))\n t))\n#+END_SRC", + "body": "** u/ji99 [[https://www.reddit.com/r/emacs/comments/t3_hqxm5v/comment/t1_fy0xduj][\ud83d\udd17]] \n*Votes* 8\n\nHippie-expand google search suggestions. Completely inspired from [[https://github.com/malloc47/shell-parse.el/blob/master/shell-parse.el][shell-parse.el]].\n\nI've added ~try-expand-google-completion~ to the bottom of my ~hippie-expand-try-functions-list~\n\n#+BEGIN_SRC elisp\n(defun google-suggest--request (query)\n (with-current-buffer\n (url-retrieve-synchronously\n (format \"http://suggestqueries.google.com/complete/search?client=firefox&q=%s\" query) t t 1)\n (goto-char (point-min))\n (re-search-forward \"^$\")\n (delete-region (point)(point-min))(buffer-string)))\n \n(defun google-suggest--list (result)\n (let* ((q (progn\n (string-match \",\\\\[\\\\(.*?\\\\)\\\\]\" result)\n (match-string 1 result)))\n (r (replace-regexp-in-string \"\\\\\\\"\" \"\" q))\n (l (split-string r \",\" t)))\n (when (> (length (car (cdr l))) 0)\n (remove\n (car l)\n (cdr l)))))\n \n(defun try-expand-google-completion (old)\n (unless old\n (he-init-string (hippie-word-bg) (point))\n (setq he-expand-list (sort\n (all-completions\n he-search-string\n (lambda (s y n) (google-suggest--list (google-suggest--request s))))\n 'string-lessp)))\n (if (null he-expand-list)\n (progn\n (when old (he-reset-string))\n ())\n (he-substitute-string (car he-expand-list) t)\n (setq he-tried-table (cons (car he-expand-list) (cdr he-tried-table)))\n (setq he-expand-list (cdr he-expand-list))\n t))\n#+END_SRC", "created_datetime": "2020-07-14 12:08:32+00:00" }, "t1_fwt1k27": { @@ -1106,7 +1106,7 @@ "t1_fqfc1wi": { "author": "karthink", "upvotes": 8, - "body": "** u/karthink [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqfc1wi][\ud83d\udd17]] \n*Votes* 8\n\nAucTex users: You're missing out if you don't use [CDLatex](https://github.com/cdominik/cdlatex). It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is _always available_, not just during snippet entry. It's difficult to explain, so here are some demos:\n\n1. [Fast input with cdlatex and preview.el](https://gfycat.com/heavenlynegligiblehoiho)\n2. [Fast input with keys displayed](https://gfycat.com/safeidolizedlangur)\n\nI wrote a longer post explaining [how I set up AucTex](https://www.reddit.com/r/emacs/comments/g8ecpj/advice_for_auclatex_what_keybinds_do_you_find/foo64ge/) recently.\n\nCDLaTeX was written by Carsten Dominik, the author of Org-mode and reftex. Thus Org ships with an ~org-cdlatex~ minor-mode that makes these features available in org-mode.", + "body": "** u/karthink [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqfc1wi][\ud83d\udd17]] \n*Votes* 8\n\nAucTex users: You're missing out if you don't use [[https://github.com/cdominik/cdlatex][CDLatex]]. It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is _always available_, not just during snippet entry. It's difficult to explain, so here are some demos:\n\n1. [[https://gfycat.com/heavenlynegligiblehoiho][Fast input with cdlatex and preview.el]]\n2. [[https://gfycat.com/safeidolizedlangur][Fast input with keys displayed]]\n\nI wrote a longer post explaining [[https://www.reddit.com/r/emacs/comments/g8ecpj/advice_for_auclatex_what_keybinds_do_you_find/foo64ge/][how I set up AucTex]] recently.\n\nCDLaTeX was written by Carsten Dominik, the author of Org-mode and reftex. Thus Org ships with an ~org-cdlatex~ minor-mode that makes these features available in org-mode.", "created_datetime": "2020-05-12 23:24:05+00:00" }, "t1_fqdnyhk": { @@ -1118,13 +1118,13 @@ "t1_fqczes1": { "author": "[deleted]", "upvotes": 8, - "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqczes1][\ud83d\udd17]] \n*Votes* 8\n\n[A beginers guide to emacs 24 or later by sasha chua](https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png) this helped me tremendously to get started with emacs.", + "body": "** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqczes1][\ud83d\udd17]] \n*Votes* 8\n\n[[https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png][A beginers guide to emacs 24 or later by sasha chua]] this helped me tremendously to get started with emacs.", "created_datetime": "2020-05-12 10:03:56+00:00" }, "t1_fqcycvb": { "author": "ji99", "upvotes": 8, - "body": "** u/ji99 [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqcycvb][\ud83d\udd17]] \n*Votes* 8\n\nA rudimentary interface for the fabulous [Links web browser](http://links.twibright.com/user_en.html):\n\n#+BEGIN_SRC elisp\n(defun links-browser (&optional link new-window)\n (interactive)\n (unless link\n (setq link (read-from-minibuffer \"url: \")))\n (make-process\n :name \"links-browser\"\n :connection-type 'pipe\n :command (list \"links\" \"-g\" link)))\n \n(defun links-search (&optional query)\n (interactive)\n (unless query\n (setq query (read-from-minibuffer \"search query: \")))\n (pcase query\n ((pred (string-match \"\\\\~d .*\"))\n (links-search--launch \"dict\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~b .*\"))\n (links-search--launch \"book\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~w .*\"))\n (links-search--launch \"wiki\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~m .*\"))\n (links-search--launch \"imdb\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~y .*\"))\n (links-search--launch \"yout\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~t .*\"))\n (links-search--launch \"thes\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~s .*\"))\n (links-search--launch \"syno\" (substring query 2 nil)))\n (_ (links-search--launch \"seax\" query))))\n \n(defun links-search--launch (engine query)\n (pcase engine\n (\"dict\" (links-browser (format \"https://en.wiktionary.org/wiki/Special:Search?search=%s\" query)))\n (\"wiki\" (links-browser (format \"https://en.wikipedia.org/w/index.php?title=Special:Search&search=%s&go=Go\" query)))\n (\"imdb\" (links-browser (format \"https://www.imdb.com/find?s=all&q=%s\" query)))\n (\"yout\" (links-browser (format \"https://www.youtube.com/results?search_query=%s\" query)))\n (\"book\" (links-browser (format \"http://gen.lib.rus.ec/search.php?req=%s&res=100&sort=id&sortmode=DESC\" query)))\n (\"thes\" (links-browser (format \"https://www.powerthesaurus.org/%s\" query)))\n (\"syno\" (links-browser (format \"https://duckduckgo.com/lite/?q=%s site:macmillandictionary.com\" query)))\n (\"seax\" (links-browser (format \"https://search.snopyta.org/?q=%s\" query)))))\n#+END_SRC", + "body": "** u/ji99 [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqcycvb][\ud83d\udd17]] \n*Votes* 8\n\nA rudimentary interface for the fabulous [[http://links.twibright.com/user_en.html][Links web browser]]:\n\n#+BEGIN_SRC elisp\n(defun links-browser (&optional link new-window)\n (interactive)\n (unless link\n (setq link (read-from-minibuffer \"url: \")))\n (make-process\n :name \"links-browser\"\n :connection-type 'pipe\n :command (list \"links\" \"-g\" link)))\n \n(defun links-search (&optional query)\n (interactive)\n (unless query\n (setq query (read-from-minibuffer \"search query: \")))\n (pcase query\n ((pred (string-match \"\\\\~d .*\"))\n (links-search--launch \"dict\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~b .*\"))\n (links-search--launch \"book\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~w .*\"))\n (links-search--launch \"wiki\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~m .*\"))\n (links-search--launch \"imdb\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~y .*\"))\n (links-search--launch \"yout\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~t .*\"))\n (links-search--launch \"thes\" (substring query 2 nil)))\n ((pred (string-match \"\\\\~s .*\"))\n (links-search--launch \"syno\" (substring query 2 nil)))\n (_ (links-search--launch \"seax\" query))))\n \n(defun links-search--launch (engine query)\n (pcase engine\n (\"dict\" (links-browser (format \"https://en.wiktionary.org/wiki/Special:Search?search=%s\" query)))\n (\"wiki\" (links-browser (format \"https://en.wikipedia.org/w/index.php?title=Special:Search&search=%s&go=Go\" query)))\n (\"imdb\" (links-browser (format \"https://www.imdb.com/find?s=all&q=%s\" query)))\n (\"yout\" (links-browser (format \"https://www.youtube.com/results?search_query=%s\" query)))\n (\"book\" (links-browser (format \"http://gen.lib.rus.ec/search.php?req=%s&res=100&sort=id&sortmode=DESC\" query)))\n (\"thes\" (links-browser (format \"https://www.powerthesaurus.org/%s\" query)))\n (\"syno\" (links-browser (format \"https://duckduckgo.com/lite/?q=%s site:macmillandictionary.com\" query)))\n (\"seax\" (links-browser (format \"https://search.snopyta.org/?q=%s\" query)))))\n#+END_SRC", "created_datetime": "2020-05-12 09:46:21+00:00" }, "t1_fq9186h": { @@ -1136,7 +1136,7 @@ "t1_kriu3ye": { "author": "Icy_Thought", "upvotes": 8, - "body": "** u/Icy_Thought [[https://www.reddit.com/r/emacs/comments/t3_1aw6xkc/comment/t1_kriu3ye][\ud83d\udd17]] \n*Votes* 8\n\nTwo tricks that helped me make my workflow a lot better:\n\n1. ~(setq process-adaptive-read-buffering nil)~ makes [EAT](https://codeberg.org/akib/emacs-eat) a lot quicker!\n2. ~(setq eglot-events-buffer-size 0)~, ~(fset #'jsonrpc--log-event #'ignore)~ and [eglot-booster](https://github.com/jdtsmith/eglot-booster) makes eglot A LOT quicker!", + "body": "** u/Icy_Thought [[https://www.reddit.com/r/emacs/comments/t3_1aw6xkc/comment/t1_kriu3ye][\ud83d\udd17]] \n*Votes* 8\n\nTwo tricks that helped me make my workflow a lot better:\n\n1. ~(setq process-adaptive-read-buffering nil)~ makes [[https://codeberg.org/akib/emacs-eat][EAT]] a lot quicker!\n2. ~(setq eglot-events-buffer-size 0)~, ~(fset #'jsonrpc--log-event #'ignore)~ and [[https://github.com/jdtsmith/eglot-booster][eglot-booster]] makes eglot A LOT quicker!", "created_datetime": "2024-02-21 22:50:25+00:00" }, "t1_kob6a5m": { @@ -1149,7 +1149,7 @@ "author": "hunajakettu", "upvotes": 8, "body": "** u/hunajakettu [[https://www.reddit.com/r/emacs/comments/t3_16tes2a/comment/t1_k2f683f][\ud83d\udd17]] \n*Votes* 8\n\nIt is the only thing that keeps me sane in a Windows shop.", - "created_datetime": "2023-09-27 12:21:05+00:00" + "created_datetime": "2023-09-27 13:21:05+00:00" }, "t1_jli02ld": { "author": "habamax", @@ -1160,7 +1160,7 @@ "t1_jhtis87": { "author": "swhalemwo", "upvotes": 8, - "body": "** u/swhalemwo [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhtis87][\ud83d\udd17]] \n*Votes* 8\n\nrecently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [generate org macros from my ~R~ script](https://emacs.stackexchange.com/questions/14647/use-code-variable-in-org-mode-continuous-text), [display their values rather than the macro text](https://notes.alexkehayias.com/emacs-inline-macro-in-the-buffer/), and pass ~org-macro-templates~ to ~consult--read~ to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on!", + "body": "** u/swhalemwo [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhtis87][\ud83d\udd17]] \n*Votes* 8\n\nrecently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [[https://emacs.stackexchange.com/questions/14647/use-code-variable-in-org-mode-continuous-text][generate org macros from my ~R~ script]], [[https://notes.alexkehayias.com/emacs-inline-macro-in-the-buffer/][display their values rather than the macro text]], and pass ~org-macro-templates~ to ~consult--read~ to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on!", "created_datetime": "2023-04-26 19:49:00+00:00" }, "t1_jhwipv8": { @@ -1184,19 +1184,19 @@ "t1_imjs86m": { "author": "slinchisl", "upvotes": 8, - "body": "\\** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imjs86m][\ud83d\udd17]] \n\\*Votes* 8\n\nI don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [rapidly capture ideas](https://tony-zorman.com/posts/orgmode-prompt/2022-08-27-xmonad-and-org-mode.html) by using XMonad's org-mode integration!", + "body": "\\** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imjs86m][\ud83d\udd17]] \n\\*Votes* 8\n\nI don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [[https://tony-zorman.com/posts/orgmode-prompt/2022-08-27-xmonad-and-org-mode.html][rapidly capture ideas]] by using XMonad's org-mode integration!", "created_datetime": "2022-08-31 18:42:31+00:00" }, "t1_iku77h0": { "author": "attento_redaz", "upvotes": 9, - "body": "\\** u/attento_redaz [[https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_iku77h0][\ud83d\udd17]] \n\\*Votes* 9\n\nUsing [zotra](https://github.com/mpedramfar/zotra), [citar](https://github.com/emacs-citar/citar) and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with \"org-biblatex bibliographies\" which are basically like [org-bibtex](http://gewhere.github.io/org-bibtex) but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable ~#+bibliography: my-org-biblatex-file.org~ declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp.", + "body": "\\** u/attento_redaz [[https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_iku77h0][\ud83d\udd17]] \n\\*Votes* 9\n\nUsing [[https://github.com/mpedramfar/zotra][zotra]], [[https://github.com/emacs-citar/citar][citar]] and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with \"org-biblatex bibliographies\" which are basically like [[http://gewhere.github.io/org-bibtex][org-bibtex]] but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable ~#+bibliography: my-org-biblatex-file.org~ declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp.", "created_datetime": "2022-08-18 20:55:50+00:00" }, "t1_h8rdjx9": { "author": "poinkalum", "upvotes": 8, - "body": "\\** u/poinkalum [[https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8rdjx9][\ud83d\udd17]] \n\\*Votes* 8\n\nIf you follow master, you can use the very useful command ~execute-extended-command-for-buffer~ by using ~M-X~ (with a capital \"X\"), that implements the behaviour described in [this blog post by Lars](https://lars.ingebrigtsen.no/2021/02/16/command-discovery-in-emacs/). It will only show commands that are relevant to the current major mode.", + "body": "\\** u/poinkalum [[https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8rdjx9][\ud83d\udd17]] \n\\*Votes* 8\n\nIf you follow master, you can use the very useful command ~execute-extended-command-for-buffer~ by using ~M-X~ (with a capital \"X\"), that implements the behaviour described in [[https://lars.ingebrigtsen.no/2021/02/16/command-discovery-in-emacs/][this blog post by Lars]]. It will only show commands that are relevant to the current major mode.", "created_datetime": "2021-08-13 09:03:49+00:00" }, "t1_h85cv7f": { @@ -1214,7 +1214,7 @@ "t1_ggoehoo": { "author": "zackallison", "upvotes": 9, - "body": "** u/zackallison [[https://www.reddit.com/r/emacs/comments/t3_ki09cm/comment/t1_ggoehoo][\ud83d\udd17]] \n*Votes* 9\n\nI posted this in the emacsclient thread, but I think it deserves to live here as well:\n\n\nThe emacsclient / server system is great. If you have it listening on tcp and port forward that when connecting to remote machine it adds another level of power.\n\nI use [emacs-vterm](https://github.com/akermu/emacs-libvterm) for a terminal inside emacs, so I've got a lot of commands remapped. Like ~man~ runs ~emacsclient ... man ..~, which opens the man page in the \"other\" buffer, so it doesn't interrupt my flow. I use \"scroll-other-window\" to navigate the man page while I still have my prompt. ~magit~, ~dired~, and others map to their ~emacsclient~ equivalents.\n\nI've written wrapper script for e/emacs client that I've come to call ~e~, because it saves keystrokes\n\n#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/)\n\nIt does the standard things you would expect, starts emacs if it's not already started, open a file in a new buffer / window / terminal and optionally wait for you to finish or have the shell continue.\n\nThen I added some functions that I found useful, starting with piping results from a command into an emacs buffer, such as ~find . -name foo\\* | e~. Naturally after that was piping from a buffer to a command: ~e [file] | rot13~ super secure encryption. And of course piping into and out of a buffer works as well ~find . -name incriminating-evidence\\* | e | xargs rm~, so you can verify / tweak the results before passing them through. Maybe you want to leave the evidence on Two Time Tommy. Who knows.\n\nThe other nice feature is the ability to use templates. For example to edit a HTTP request and then send it to a server you can do that: ~e -t header_template.txt | nc www.example.com 80~ The template file is copied to a temp file which is the one that is edited.\n\nOr the poor man's blog system: ~e -t header_template.html body_template.html footer.html > new_page.html~\n\nSee the repo for more examples and to download. The notes of getting it working on remote machines aren't the cleanest. If you have any suggestions or features that would make your life easier let me know; submit an issue or comment here.\n\n#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/)\n\n~~I really should post this on one of the share your stuff posts. But I get distracted.~~ There, I did it.\n\nIn case you can't tell I *really* like emacs and it's client server model.", + "body": "** u/zackallison [[https://www.reddit.com/r/emacs/comments/t3_ki09cm/comment/t1_ggoehoo][\ud83d\udd17]] \n*Votes* 9\n\nI posted this in the emacsclient thread, but I think it deserves to live here as well:\n\n\nThe emacsclient / server system is great. If you have it listening on tcp and port forward that when connecting to remote machine it adds another level of power.\n\nI use [[https://github.com/akermu/emacs-libvterm][emacs-vterm]] for a terminal inside emacs, so I've got a lot of commands remapped. Like ~man~ runs ~emacsclient ... man ..~, which opens the man page in the \"other\" buffer, so it doesn't interrupt my flow. I use \"scroll-other-window\" to navigate the man page while I still have my prompt. ~magit~, ~dired~, and others map to their ~emacsclient~ equivalents.\n\nI've written wrapper script for e/emacs client that I've come to call ~e~, because it saves keystrokes\n\n#### [[https://gitlab.com/zackallison/e-emacs/][The full repo is here e-emacs.sh]]\n\nIt does the standard things you would expect, starts emacs if it's not already started, open a file in a new buffer / window / terminal and optionally wait for you to finish or have the shell continue.\n\nThen I added some functions that I found useful, starting with piping results from a command into an emacs buffer, such as ~find . -name foo\\* | e~. Naturally after that was piping from a buffer to a command: ~e [file] | rot13~ super secure encryption. And of course piping into and out of a buffer works as well ~find . -name incriminating-evidence\\* | e | xargs rm~, so you can verify / tweak the results before passing them through. Maybe you want to leave the evidence on Two Time Tommy. Who knows.\n\nThe other nice feature is the ability to use templates. For example to edit a HTTP request and then send it to a server you can do that: ~e -t header_template.txt | nc www.example.com 80~ The template file is copied to a temp file which is the one that is edited.\n\nOr the poor man's blog system: ~e -t header_template.html body_template.html footer.html > new_page.html~\n\nSee the repo for more examples and to download. The notes of getting it working on remote machines aren't the cleanest. If you have any suggestions or features that would make your life easier let me know; submit an issue or comment here.\n\n#### [[https://gitlab.com/zackallison/e-emacs/][The full repo is here e-emacs.sh]]\n\n~~I really should post this on one of the share your stuff posts. But I get distracted.~~ There, I did it.\n\nIn case you can't tell I *really* like emacs and it's client server model.", "created_datetime": "2020-12-22 09:18:52+00:00" }, "t1_ge8si78": { @@ -1244,7 +1244,7 @@ "t1_kslwb72": { "author": "LionyxML", "upvotes": 9, - "body": "** u/LionyxML [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_kslwb72][\ud83d\udd17]] \n*Votes* 9\n\nA blog post regarding my own Emacs config aiming to get the same user experience on both TUI and GUI. \n[https://www.rahuljuliato.com/posts/lemacs](https://www.rahuljuliato.com/posts/lemacs)", + "body": "** u/LionyxML [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_kslwb72][\ud83d\udd17]] \n*Votes* 9\n\nA blog post regarding my own Emacs config aiming to get the same user experience on both TUI and GUI. \n[[https://www.rahuljuliato.com/posts/lemacs][https://www.rahuljuliato.com/posts/lemacs]]", "created_datetime": "2024-02-28 22:39:26+00:00" }, "t1_ih3s9fl": { @@ -1256,7 +1256,7 @@ "t1_hdtoivy": { "author": "slinchisl", "upvotes": 8, - "body": "\\** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_pt2xws/comment/t1_hdtoivy][\ud83d\udd17]] \n\\*Votes* 8\n\nI've been playing around with Emacs 28's [repeat-mode](https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp?id=12409c9064c386a496dcbdca76b790108f6c1cad) a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function:\n\n#+BEGIN_SRC elisp\n(defmacro defrepeatmap (symbol &optional pairs docstring)\n \"A macro for defining ~repeat-map's.\nDefines a new repeat-map called SYMBOL with the given DOCSTRING.\nThe keys are derived via the list PAIRS, whose elements are cons\ncells of the form (KEY . DEF), where KEY and DEF must fulfill the\nsame requirements as if given to ~define-key'.\"\n ~(progn\n (defvar ,symbol\n (let ((map (make-sparse-keymap)))\n (--each ,pairs (define-key map (car it) (cdr it)))\n map)\n ,docstring)\n ;; Tell the keys they are in a repeat map.\n (--each (mapcar 'cdr (cdr ,symbol))\n (put it 'repeat-map ',symbol))))\n \n#+END_SRC\nIt can be used like \n\n#+BEGIN_SRC elisp\n(defrepeatmap window-repeat-map\n '((\"}\" . enlarge-window-horizontally)\n (\"{\" . shrink-window-horizontally )\n (\"+\" . balance-windows )\n (\"o\" . other-window )\n (\"1\" . delete-other-windows )\n (\"2\" . split-window-below )\n (\"3\" . split-window-right )\n (\"0\" . delete-window )\n (\"s\" . window-swap-states )\n (\"f\" . project-find-file ))\n \"Keymap to repeat window key sequences. Used in ~repeat-mode'.\")\n#+END_SRC", + "body": "\\** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_pt2xws/comment/t1_hdtoivy][\ud83d\udd17]] \n\\*Votes* 8\n\nI've been playing around with Emacs 28's [[https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp?id=12409c9064c386a496dcbdca76b790108f6c1cad][repeat-mode]] a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function:\n\n#+BEGIN_SRC elisp\n(defmacro defrepeatmap (symbol &optional pairs docstring)\n \"A macro for defining ~repeat-map's.\nDefines a new repeat-map called SYMBOL with the given DOCSTRING.\nThe keys are derived via the list PAIRS, whose elements are cons\ncells of the form (KEY . DEF), where KEY and DEF must fulfill the\nsame requirements as if given to ~define-key'.\"\n ~(progn\n (defvar ,symbol\n (let ((map (make-sparse-keymap)))\n (--each ,pairs (define-key map (car it) (cdr it)))\n map)\n ,docstring)\n ;; Tell the keys they are in a repeat map.\n (--each (mapcar 'cdr (cdr ,symbol))\n (put it 'repeat-map ',symbol))))\n \n#+END_SRC\nIt can be used like \n\n#+BEGIN_SRC elisp\n(defrepeatmap window-repeat-map\n '((\"}\" . enlarge-window-horizontally)\n (\"{\" . shrink-window-horizontally )\n (\"+\" . balance-windows )\n (\"o\" . other-window )\n (\"1\" . delete-other-windows )\n (\"2\" . split-window-below )\n (\"3\" . split-window-right )\n (\"0\" . delete-window )\n (\"s\" . window-swap-states )\n (\"f\" . project-find-file ))\n \"Keymap to repeat window key sequences. Used in ~repeat-mode'.\")\n#+END_SRC", "created_datetime": "2021-09-22 10:10:10+00:00" }, "t1_h88ph29": { @@ -1273,14 +1273,14 @@ }, "t1_lvojz57": { "author": "ImJustPassinBy", - "upvotes": 17, - "body": "** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57][\ud83d\udd17]] \n*Votes* 17\n\n~use-package~ has an inbuilt feature that roughly reports the loading times of each package on startup ([~esup~](https://github.com/jschaf/esup) most likely does a better job, if you can get it to run; there are [known issues](https://github.com/alexmurray/emacs-snap/issues/71) on Emacs snap):\n\n1. put ~(setq use-package-compute-statistics t)~ at the beginning of your ~init.el~\n2. restart Emacs\n3. do ~M-x use-package-report~\n\nWhich package is your biggest time sink and why is it worth it? Mine is [~pdf-tools~](https://github.com/vedang/pdf-tools), but to my knowledge there is simply no better alternative for working with pdfs in emacs.", + "upvotes": 19, + "body": "** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57][\ud83d\udd17]] \n*Votes* 19\n\n~use-package~ has an inbuilt feature that roughly reports the loading times of each package on startup ([[https://github.com/jschaf/esup][~esup~]] most likely does a better job, if you can get it to run; there are [[https://github.com/alexmurray/emacs-snap/issues/71][known issues]] on Emacs snap):\n\n1. put ~(setq use-package-compute-statistics t)~ at the beginning of your ~init.el~\n2. restart Emacs\n3. do ~M-x use-package-report~\n\nWhich package is your biggest time sink and why is it worth it? Mine is [[https://github.com/vedang/pdf-tools][~pdf-tools~]], but to my knowledge there is simply no better alternative for working with pdfs in emacs.", "created_datetime": "2024-11-06 09:43:57+00:00" }, "t1_ksoij65": { "author": "jcubic", "upvotes": 8, - "body": "** u/jcubic [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksoij65][\ud83d\udd17]] \n*Votes* 8\n\nI use this often when working on large files. You can bookmark up to 9 places inside a file and jump to that position. The limitations is that if you add somehing above the bookmark the position is shifted a bit but it's not that hard to find the right place.\n\nIt works like this: ~C-c 0~ creates a bookmark and ~C-c <1-9>~ jumps into a bookmark. I've written about this on my old blog. I still use this from time to time.\n\n[Faster buffer bookmarking in Emacs](https://jcubic.wordpress.com/2012/01/25/faster-buffer-bookmarking-in-emacs/).", + "body": "** u/jcubic [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksoij65][\ud83d\udd17]] \n*Votes* 8\n\nI use this often when working on large files. You can bookmark up to 9 places inside a file and jump to that position. The limitations is that if you add somehing above the bookmark the position is shifted a bit but it's not that hard to find the right place.\n\nIt works like this: ~C-c 0~ creates a bookmark and ~C-c <1-9>~ jumps into a bookmark. I've written about this on my old blog. I still use this from time to time.\n\n[[https://jcubic.wordpress.com/2012/01/25/faster-buffer-bookmarking-in-emacs/][Faster buffer bookmarking in Emacs]].", "created_datetime": "2024-02-29 11:27:23+00:00" }, "t1_izxi6ie": { @@ -1304,13 +1304,13 @@ "t1_itwo67r": { "author": "meedstrom", "upvotes": 8, - "body": "** u/meedstrom [[https://www.reddit.com/r/emacs/comments/t3_ydsjfy/comment/t1_itwo67r][\ud83d\udd17]] \n*Votes* 8\n\nI had the [defrepeater](https://github.com/alphapapa/defrepeater.el) package for a while, but didn't realize you could use it this elegantly!\n\n#+BEGIN_SRC elisp\n(global-set-key [remap transpose-lines] (defrepeater #'transpose-lines))\n\n#+END_SRC\nSomething similar is actually in the readme, but I guess I glossed over it back then.", + "body": "** u/meedstrom [[https://www.reddit.com/r/emacs/comments/t3_ydsjfy/comment/t1_itwo67r][\ud83d\udd17]] \n*Votes* 8\n\nI had the [[https://github.com/alphapapa/defrepeater.el][defrepeater]] package for a while, but didn't realize you could use it this elegantly!\n\n#+BEGIN_SRC elisp\n(global-set-key [remap transpose-lines] (defrepeater #'transpose-lines))\n\n#+END_SRC\nSomething similar is actually in the readme, but I guess I glossed over it back then.", "created_datetime": "2022-10-26 22:10:32+00:00" }, "t1_inp54pm": { "author": "khourhin", "upvotes": 8, - "body": "** u/khourhin [[https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_inp54pm][\ud83d\udd17]] \n*Votes* 8\n\nJust discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. [https://github.com/DamienCassou/desktop-environment](https://github.com/DamienCassou/desktop-environment)\n\nThanks Damien !", + "body": "** u/khourhin [[https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_inp54pm][\ud83d\udd17]] \n*Votes* 8\n\nJust discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. [[https://github.com/DamienCassou/desktop-environment][https://github.com/DamienCassou/desktop-environment]]\n\nThanks Damien !", "created_datetime": "2022-09-09 08:11:09+00:00" }, "t1_idb3m43": { @@ -1328,7 +1328,7 @@ "t1_k9g3i9s": { "author": "AffectionateAd8985", "upvotes": 8, - "body": "** u/AffectionateAd8985 [[https://www.reddit.com/r/emacs/comments/t3_17vp0o1/comment/t1_k9g3i9s][\ud83d\udd17]] \n*Votes* 8\n\nIn eshell, ~cd =xxx~ behaves like ~z xxx~ in [zoxide](https://github.com/ajeetdsouza/zoxide), jump to recent directory matching ~xxx~ pattern.", + "body": "** u/AffectionateAd8985 [[https://www.reddit.com/r/emacs/comments/t3_17vp0o1/comment/t1_k9g3i9s][\ud83d\udd17]] \n*Votes* 8\n\nIn eshell, ~cd =xxx~ behaves like ~z xxx~ in [[https://github.com/ajeetdsouza/zoxide][zoxide]], jump to recent directory matching ~xxx~ pattern.", "created_datetime": "2023-11-16 02:16:29+00:00" }, "t1_janipaz": { @@ -1346,7 +1346,7 @@ "t1_hqlp0en": { "author": "nicholas_hubbard", "upvotes": 8, - "body": "\\** u/nicholas_hubbard [[https://www.reddit.com/r/emacs/comments/t3_rr330u/comment/t1_hqlp0en][\ud83d\udd17]] \n\\*Votes* 8\n\nHere is a consult source for [perspective.el](https://github.com/nex3/perspective-el)\n\n#+BEGIN_SRC elisp\n(defvar consult--source-perspective\n `(:name \"Perspective\"\n :narrow ?p\n :category buffer\n :face consult-buffer\n :history buffer-name-history\n :state ,#'consult--buffer-state\n :default t\n :items ,#'persp-get-buffer-names)\n \"Perspective candidate source for `consult-buffer'.\")\n#+END_SRC", + "body": "\\** u/nicholas_hubbard [[https://www.reddit.com/r/emacs/comments/t3_rr330u/comment/t1_hqlp0en][\ud83d\udd17]] \n\\*Votes* 8\n\nHere is a consult source for [[https://github.com/nex3/perspective-el][perspective.el]]\n\n#+BEGIN_SRC elisp\n(defvar consult--source-perspective\n `(:name \"Perspective\"\n :narrow ?p\n :category buffer\n :face consult-buffer\n :history buffer-name-history\n :state ,#'consult--buffer-state\n :default t\n :items ,#'persp-get-buffer-names)\n \"Perspective candidate source for `consult-buffer'.\")\n#+END_SRC", "created_datetime": "2021-12-30 22:04:44+00:00" }, "t1_fvy3geb": { @@ -1358,7 +1358,7 @@ "t1_j9jgfhg": { "author": "elimik31", "upvotes": 8, - "body": "** u/elimik31 [[https://www.reddit.com/r/emacs/comments/t3_118sowc/comment/t1_j9jgfhg][\ud83d\udd17]] \n*Votes* 8\n\nThe [texdoc](https://github.com/TeX-Live/texdoc/wiki/Tab-completion) CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the ~TeX-documentation-texdoc~ command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [tab-completion](https://github.com/TeX-Live/texdoc/wiki/Tab-completion), which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with ~completing-read~ and ~call-process~ to call the terminal command I created my own ~my-texdoc~ command with interactive candidate selection. It's available as [github gist here](https://gist.github.com/meliache/e645bf50c6aeac8e6e58b92c6bddac20), but I can also paste the code:\n\n#+BEGIN_SRC elisp\n(defun my-texdoc--get-package-list ()\n (let ((tlpdb-fpath (file-name-concat\n (string-trim-right\n (shell-command-to-string \"kpsewhich -var-value TEXMFROOT\"))\n \"tlpkg/texlive.tlpdb\"))\n (name-regex \"^name \\\\([^ \\n.]+\\\\)$\"))\n (with-current-buffer (find-file-noselect tlpdb-fpath 'nowarn 'rawfile)\n (save-excursion\n (goto-char (point-min))\n (cl-loop\n while (re-search-forward name-regex nil 'noerror)\n collect (match-string-no-properties 1))))))\n \n(defun my-texdoc (pkg)\n \"Show TeX documentation for package PKG.\nIf called interactively, select package from TexLive with interactive completion.\"\n (interactive\n (list (completing-read\n \"texdoc: \"\n (my-texdoc--get-package-list)\n nil nil nil\n 'my-texdoc-history)))\n (call-process \"texdoc\" nil \" *texdoc*\" nil \"--view\" pkg))\n\n#+END_SRC\nMy biggest problem is that I'm not sure how to share it with the emacs community, it doesn't seem like it's big enough to be its own package, I might post it on some wiki or in some aggregating package like ~consult~, but I thought I would start with this reddit thread. I also might try to merge this into ~AUCTeX~, however I'm not sure if that's actively developed anymore and the ~TeX-documentation-texdoc~ source code is much more complex than what I have, that I'm a bit worried to break something.\n\nAnd to make this post a real tip: If you know some CLI program and can somehow get a list of possible arguments for that program, try writing your own emacs lisp command wrapper with ~completing-read~ support, it's fun and not that hard.", + "body": "** u/elimik31 [[https://www.reddit.com/r/emacs/comments/t3_118sowc/comment/t1_j9jgfhg][\ud83d\udd17]] \n*Votes* 8\n\nThe [[https://github.com/TeX-Live/texdoc/wiki/Tab-completion][texdoc]] CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the ~TeX-documentation-texdoc~ command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [[https://github.com/TeX-Live/texdoc/wiki/Tab-completion][tab-completion]], which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with ~completing-read~ and ~call-process~ to call the terminal command I created my own ~my-texdoc~ command with interactive candidate selection. It's available as [[https://gist.github.com/meliache/e645bf50c6aeac8e6e58b92c6bddac20][github gist here]], but I can also paste the code:\n\n#+BEGIN_SRC elisp\n(defun my-texdoc--get-package-list ()\n (let ((tlpdb-fpath (file-name-concat\n (string-trim-right\n (shell-command-to-string \"kpsewhich -var-value TEXMFROOT\"))\n \"tlpkg/texlive.tlpdb\"))\n (name-regex \"^name \\\\([^ \\n.]+\\\\)$\"))\n (with-current-buffer (find-file-noselect tlpdb-fpath 'nowarn 'rawfile)\n (save-excursion\n (goto-char (point-min))\n (cl-loop\n while (re-search-forward name-regex nil 'noerror)\n collect (match-string-no-properties 1))))))\n \n(defun my-texdoc (pkg)\n \"Show TeX documentation for package PKG.\nIf called interactively, select package from TexLive with interactive completion.\"\n (interactive\n (list (completing-read\n \"texdoc: \"\n (my-texdoc--get-package-list)\n nil nil nil\n 'my-texdoc-history)))\n (call-process \"texdoc\" nil \" *texdoc*\" nil \"--view\" pkg))\n\n#+END_SRC\nMy biggest problem is that I'm not sure how to share it with the emacs community, it doesn't seem like it's big enough to be its own package, I might post it on some wiki or in some aggregating package like ~consult~, but I thought I would start with this reddit thread. I also might try to merge this into ~AUCTeX~, however I'm not sure if that's actively developed anymore and the ~TeX-documentation-texdoc~ source code is much more complex than what I have, that I'm a bit worried to break something.\n\nAnd to make this post a real tip: If you know some CLI program and can somehow get a list of possible arguments for that program, try writing your own emacs lisp command wrapper with ~completing-read~ support, it's fun and not that hard.", "created_datetime": "2023-02-22 12:19:40+00:00" }, "t1_l01n03t": { diff --git a/out.md b/out.md index 764e453..dd85045 100644 --- a/out.md +++ b/out.md @@ -1,15 +1,6 @@ -# u/TheDrownedKraken [🔗](https://www.reddit.com/r/emacs/comments/t3_o68i0v/comment/t1_h2rdkkz) - -**Votes** 37 - -Do you think it might be good to make this a little less frequently refreshed? There are usually some great tips that get lost to Reddit’s ephemerality pretty quickly. - -I think monthly would be better, given the modest size of this subreddit. - - # u/SlowMovingTarget [🔗](https://www.reddit.com/r/emacs/comments/t3_1fzmgwb/comment/t1_lr35bm5) -**Votes** 36 +**Votes** 39 Nothing revolutionary (and veterans will already know this), but a nice little function for splitting out text to a separate file: @@ -21,9 +12,18 @@ It's in the manual, and a basic little feature, but really handy. ]() +Update from a couple of weeks ago: after some grinding, I've set the parsing of past comments from this thread to auto update on a weekly basis here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md) I've also fixed the broken highlighting of some code snippets, and hopefully parsed all past threads. There's 200+ comments there (sorted by upvotes), so ctrl-f ing e.g. \\~magit\\~ may help you if you're looking for something specific @@ -168,15 +168,36 @@ In flyspell, I was annoyed I had to use mouse-2 when I wanted to correct a word, But the fact you can attach keymaps to overlays just seems so useful, will definitely use in the future. -# u/AndreaSomePostfix [🔗](https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh) +# u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57) **Votes** 19 -org-mode is amazing! +`use-package` has an inbuilt feature that roughly reports the loading times of each package on startup ([`esup`](https://github.com/jschaf/esup) most likely does a better job, if you can get it to run; there are [known issues](https://github.com/alexmurray/emacs-snap/issues/71) on Emacs snap): -I discovered \\~org-copy-visible\\~ the other day, when I wanted to send somebody only the outline of my notes. +1. put `(setq use-package-compute-statistics t)` at the beginning of your `init.el` +2. restart Emacs +3. do `M-x use-package-report` -That function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful! +Which package is your biggest time sink and why is it worth it? Mine is [`pdf-tools`](https://github.com/vedang/pdf-tools), but to my knowledge there is simply no better alternative for working with pdfs in emacs. + + +# u/vkazanov [🔗](https://www.reddit.com/r/emacs/comments/t3_1bdm6mc/comment/t1_kuo1f9y) + +**Votes** 18 + +A dump of my Emacs-related principles after 18 years of tinkering: + +1. Don't try to replicate a static IDE setup, Emacs is fluid. +2. Emacs Lisp is inevitable for Emacser to make this fluidity possible. +3. Language-agnostic is better than language-specific. +4. Embrace display-alist, fast window manipulation, winner-mode. +5. .emacs.el reset every couple of years to accomodate innovation. +6. Org-mode/org-roam for all documentation, projects, tips. The agenda is not set in stone. Use queries, filters, tweak, evolve things. +7. A contextual dwim is always better than many keybindings. +8. Use completion everywhere on everything (vertico is magic). +9. Contribute to the core and favourite packages. + +I am a beginner though, things might change. # u/WorldsEndless [🔗](https://www.reddit.com/r/emacs/comments/t3_12rlq4a/comment/t1_jgwlxuw) @@ -195,30 +216,22 @@ I'm a big user of `ffap`. I use this function with `M-x` each time I want to ope But this week I discovered `ffap-bindings`. This function replaces some key bindings to use `ffap` when it makes sense. For example, it replaces `find-file` with `find-file-at-point`, so the usual keybindings are enriched at no cost. -# u/github-alphapapa [🔗](https://www.reddit.com/r/emacs/comments/t3_p6mwx2/comment/t1_h9e6uqq) +# u/AndreaSomePostfix [🔗](https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh) **Votes** 18 -Here's a popular Emacs config I just rediscovered. Some cool stuff here. +org-mode is amazing! +I discovered \\~org-copy-visible\\~ the other day, when I wanted to send somebody only the outline of my notes. -# u/vkazanov [🔗](https://www.reddit.com/r/emacs/comments/t3_1bdm6mc/comment/t1_kuo1f9y) +That function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful! -**Votes** 17 -A dump of my Emacs-related principles after 18 years of tinkering: +# u/github-alphapapa [🔗](https://www.reddit.com/r/emacs/comments/t3_p6mwx2/comment/t1_h9e6uqq) -1. Don't try to replicate a static IDE setup, Emacs is fluid. -2. Emacs Lisp is inevitable for Emacser to make this fluidity possible. -3. Language-agnostic is better than language-specific. -4. Embrace display-alist, fast window manipulation, winner-mode. -5. .emacs.el reset every couple of years to accomodate innovation. -6. Org-mode/org-roam for all documentation, projects, tips. The agenda is not set in stone. Use queries, filters, tweak, evolve things. -7. A contextual dwim is always better than many keybindings. -8. Use completion everywhere on everything (vertico is magic). -9. Contribute to the core and favourite packages. +**Votes** 18 -I am a beginner though, things might change. +Here's a popular Emacs config I just rediscovered. Some cool stuff here. # u/sauntcartas [🔗](https://www.reddit.com/r/emacs/comments/t3_vnals8/comment/t1_ie7p6ja) @@ -245,7 +258,7 @@ Easy peasy! **Votes** 17 -It's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [post about it](). There's a few posts around suggesting features of `use-package` to optimise startup, but none of them really explained how they tied back to `autoload`, `eval-after-load`, etc so I was trying to encourage people to dig out `macroexpand` and find out. +It's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [post about it](https://blog.markhepburn.com/posts/understanding-use-package-optimisations/). There's a few posts around suggesting features of `use-package` to optimise startup, but none of them really explained how they tied back to `autoload`, `eval-after-load`, etc so I was trying to encourage people to dig out `macroexpand` and find out. # u/AffectionateAd8985 [🔗](https://www.reddit.com/r/emacs/comments/t3_sd10q9/comment/t1_hu9xfed) @@ -296,19 +309,6 @@ Now, these `help-at-pt` variables aren't specifically for org links, they contro ``` -# u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57) - -**Votes** 17 - -`use-package` has an inbuilt feature that roughly reports the loading times of each package on startup ([~esup~]() most likely does a better job, if you can get it to run; there are [known issues]() on Emacs snap): - -1. put `(setq use-package-compute-statistics t)` at the beginning of your `init.el` -2. restart Emacs -3. do `M-x use-package-report` - -Which package is your biggest time sink and why is it worth it? Mine is [~pdf-tools~](), but to my knowledge there is simply no better alternative for working with pdfs in emacs. - - # u/WorldsEndless [🔗](https://www.reddit.com/r/emacs/comments/t3_1758wua/comment/t1_k4g09iw) **Votes** 16 @@ -362,14 +362,14 @@ Combined, this allows to extend the day past midnight, with things like agenda v **Votes** 16 -I just found out that Magit can backup changes of uncommitted files automatically. Here's the link to online manual: [Magit Wip Modes](). +I just found out that Magit can backup changes of uncommitted files automatically. Here's the link to online manual: [Magit Wip Modes](https://magit.vc/manual/magit/Wip-Modes.html#Wip-Modes). # u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_mujxm7/comment/t1_gv8jxz5) **Votes** 16 -I use, and love, [transient](). I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to `s-w`. I use [buffer-move]() for rearranging windows in a frame. +I use, and love, [transient](https://github.com/magit/transient). I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to `s-w`. I use [buffer-move](https://github.com/lukhas/buffer-move) for rearranging windows in a frame. ```elisp (define-transient-command transient-window () @@ -524,62 +524,19 @@ From `consult-grep` documentation, command line options can be passed to grep, s I have just discovered this, and it made my day. -# u/leothrix [🔗](https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z) - -**Votes** 14 - -For `use-package` users (which I assume is many of us), did you know that profiling is easy to do? I'm not talking about `esup`, but a built-in capability that makes it very straightforward to find places to optimize your `init.el` for significantly faster start times. - -Enable `use-package-compute-statistics` right after you load `use-package`: - -```elisp -(setq use-package-compute-statistics t) - -``` - -Restart emacs, and then invoke `use-package-report`. You'll get a table of the load times for each package that `use-package` manages. I discovered this and found an immediate way to cut my startup time in half by fixing a few packages that weren't deferred properly by adding the right `:hook` keyword. - - -# u/geza42 [🔗](https://www.reddit.com/r/emacs/comments/t3_11lqkbo/comment/t1_jbe06qv) +# u/PriorOutcome [🔗](https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc) **Votes** 14 -You can toggle vertico's height between 15 and "almost full frame" with this. When vertico is invoked, it will always have a height of 15. But if you have a lot of matches, and like to have a better overview, press the binding, and vertico will show a full frame of matches. This is useful for example when `consult-buffer` presents a lot of buffers. - -```elisp -(advice-add 'vertico--setup :before (lambda () (setq vertico-count 15))) -(define-key minibuffer-local-map (kbd "s-'") (lambda () - (interactive) - (let ((vertico-resize t)) - (setq vertico-count (if (= vertico-count 15) (- (frame-height) 5) 15)) - (vertico--exhibit)))) - -``` - -Another useful feature is to kill buffers in `consult-buffer` without manually invoking `embark-act`. I miss this feature from Helm, where you can do actions using only one binding (no need to press an intermediate binding which invokes `embark-act`). Note, I just blindly copied some of the logic from `embark`, maybe there are some unnecessary things here. +Plain old `query-replace` has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain `y~/~n`: -```elisp -(defun my-embark-M-k (&optional arg) - (interactive "P") - (require 'embark) - (if-let ((targets (embark--targets))) - (let* ((target - (or (nth - (if (or (null arg) (minibufferp)) - 0 - (mod (prefix-numeric-value arg) (length targets))) - targets))) - (type (plist-get target :type))) - (cond - ((eq type 'buffer) - (let ((embark-pre-action-hooks)) - (embark--act 'kill-buffer target))))))) +`!`: replaces all remaning matches -(define-key minibuffer-local-map (kbd "M-k") 'my-embark-M-k) +`u`: undo last replacement -``` +`E`: changes replacement string on the fly -I'm not sure whether these two can be achieved out-of-the box, but I didn't find these functionalities, so I created them. +And many more you can see using `?`. # u/com4 [🔗](https://www.reddit.com/r/emacs/comments/t3_xq6rpa/comment/t1_iqb2fci) @@ -617,7 +574,7 @@ For example, here is a simple setup for Python which includes Pyright's type che ``` -Now all that's left is mypy. Flymake originally used a ["Proc"]() method for creating checkers which existing mypy ones use. So for a bonus tip & trick [I've written a mypy checker in the new style](). It can be enabled when using eglot like this: +Now all that's left is mypy. Flymake originally used a ["Proc"](https://www.gnu.org/software/emacs/manual/html_mono/flymake.html#The-legacy-Proc-backend) method for creating checkers which existing mypy ones use. So for a bonus tip & trick [I've written a mypy checker in the new style](http://github.com/com4/flymake-mypy). It can be enabled when using eglot like this: ```elisp (use-package flymake-mypy @@ -680,7 +637,7 @@ From: **Votes** 14 -I'm slowly working on an alternative shell: []() +I'm slowly working on an alternative shell: [https://github.com/TatriX/tshell](https://github.com/TatriX/tshell) Instead of using repl-like interface, all the commands go to one buffer (and file if you want) and output goes to another buffer. Like if you put your elisp code in \\\*scratch\\\* buffer and then evaluate it with \\~C-x C-e\\~. @@ -693,16 +650,16 @@ Let me know what is your first impression, what can be improved and what do you **Votes** 14 -I just discovered the [selected]() package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode. +I just discovered the [selected](https://github.com/Kungsgeten/selected.el) package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode. # u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1fozctm/comment/t1_lpbqo0e) **Votes** 13 -I recently got tired of constantly having to move my eyes to the bottom of Emacs, so I switched to posframes, [which moves the information in a central pop-up instead](![img](https://blog.costan.ro/img/emacs-completion-system/switch-to.png)). For me, this meant using the packages: +I recently got tired of constantly having to move my eyes to the bottom of Emacs, so I switched to posframes, [which moves the information in a central pop-up instead](https://blog.costan.ro/img/emacs-completion-system/switch-to.png). For me, this meant using the packages: -\\\* [~vertico-posframe~]() - for [~vertico~]() \\\* [~which-key-posframe~]() - for [~which-key~]() \\\* [~transient-posframe~]() - for all transient commands, e.g., in [~magit~]() or in [~casual-suite~]() +\\\* [`vertico-posframe`](https://github.com/tumashu/vertico-posframe) - for [`vertico`](https://github.com/minad/vertico) \\\* [`which-key-posframe`](https://github.com/yanghaoxie/which-key-posframe) - for [`which-key`](https://github.com/justbur/emacs-which-key) \\\* [`transient-posframe`](https://github.com/yanghaoxie/transient-posframe) - for all transient commands, e.g., in [`magit`](https://github.com/magit/magit) or in [`casual-suite`](https://github.com/kickingvegas/casual-suite) But regardless what you are using, chances are there already is a suitable `*-posframe` package for it. Installing these packages is easy: @@ -719,26 +676,62 @@ But regardless what you are using, chances are there already is a suitable `*-po ``` -# u/ayyess [🔗](https://www.reddit.com/r/emacs/comments/t3_18hc301/comment/t1_kdobd72) +# u/leothrix [🔗](https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z) **Votes** 13 -I recently discovered `(setq read-minibuffer-restore-windows nil)` which resolves my frustration that quitting the minibuffer would discard any changes to the window layout while the minibuffer was open. For example, by default, `M-x C-h k k C-g` quits the just opened help buffer. I'm sure to have missed many more QOL improvements from NEWS. +For `use-package` users (which I assume is many of us), did you know that profiling is easy to do? I'm not talking about `esup`, but a built-in capability that makes it very straightforward to find places to optimize your `init.el` for significantly faster start times. +Enable `use-package-compute-statistics` right after you load `use-package`: -# u/PriorOutcome [🔗](https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc) +```elisp +(setq use-package-compute-statistics t) + +``` + +Restart emacs, and then invoke `use-package-report`. You'll get a table of the load times for each package that `use-package` manages. I discovered this and found an immediate way to cut my startup time in half by fixing a few packages that weren't deferred properly by adding the right `:hook` keyword. + + +# u/geza42 [🔗](https://www.reddit.com/r/emacs/comments/t3_11lqkbo/comment/t1_jbe06qv) **Votes** 13 -Plain old `query-replace` has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain `y~/~n`: +You can toggle vertico's height between 15 and "almost full frame" with this. When vertico is invoked, it will always have a height of 15. But if you have a lot of matches, and like to have a better overview, press the binding, and vertico will show a full frame of matches. This is useful for example when `consult-buffer` presents a lot of buffers. -`!`: replaces all remaning matches +```elisp +(advice-add 'vertico--setup :before (lambda () (setq vertico-count 15))) +(define-key minibuffer-local-map (kbd "s-'") (lambda () + (interactive) + (let ((vertico-resize t)) + (setq vertico-count (if (= vertico-count 15) (- (frame-height) 5) 15)) + (vertico--exhibit)))) -`u`: undo last replacement +``` -`E`: changes replacement string on the fly +Another useful feature is to kill buffers in `consult-buffer` without manually invoking `embark-act`. I miss this feature from Helm, where you can do actions using only one binding (no need to press an intermediate binding which invokes `embark-act`). Note, I just blindly copied some of the logic from `embark`, maybe there are some unnecessary things here. -And many more you can see using `?`. +```elisp +(defun my-embark-M-k (&optional arg) + (interactive "P") + (require 'embark) + (if-let ((targets (embark--targets))) + (let* ((target + (or (nth + (if (or (null arg) (minibufferp)) + 0 + (mod (prefix-numeric-value arg) (length targets))) + targets))) + (type (plist-get target :type))) + (cond + ((eq type 'buffer) + (let ((embark-pre-action-hooks)) + (embark--act 'kill-buffer target))))))) + +(define-key minibuffer-local-map (kbd "M-k") 'my-embark-M-k) + +``` + +I'm not sure whether these two can be achieved out-of-the box, but I didn't find these functionalities, so I created them. # u/gusbrs [🔗](https://www.reddit.com/r/emacs/comments/t3_y1y0kq/comment/t1_is1ygyw) @@ -1167,6 +1160,13 @@ Here is how I bind it in `bibtex-mode` (plus my other bindings for good measure) Shells in emacs like `shell-mode` and `eshell` can write multi line input using `comint-accumulate`. Normally bound to `C-c SPC`. +# u/UsualOffice1740 [🔗](https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9) + +**Votes** 12 + +I've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again. + + # u/remillard [🔗](https://www.reddit.com/r/emacs/comments/t3_1cbsvxd/comment/t1_l11l7he) **Votes** 12 @@ -1180,13 +1180,29 @@ I suspect completion is doing a lot of heavy lifting here though too, so a perfe Anyway, I haven't popped open the Treemacs sidebar in weeks now, and just felt like I should write something in case someone was curious about how handy it was. -# u/algor512 [🔗](https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d) +# u/geza42 [🔗](https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1) **Votes** 12 -Recently I discovered that `C-h C-q` (or `M-x help-quick`) opens a small window showing \\\*Quick Help\\\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable `help-quick-sections`. +If you use an LSP server with semantic highlighting, it's worth checking out the value of `font-lock-maximum-decoration`. For example, I use `c++-mode` with `lsp-mode` (with clangd), I decreased `font-lock-maximum-decoration` to `2`, and I didn't notice any highlighting difference (because the lost highlighting by `c++-mode` gets highlighted by `lsp-mode`), while `c++-mode` font-locking become faster (`c++-mode` 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone). -I intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of `help-quick-sections`. +I use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~ + + +# u/JDRiverRun [🔗](https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6) + +**Votes** 12 + +I have long had convenience bindings for `org-emphasize` like `super-i` for *italic*, that match system bindings. But I always wanted these to **be smarter**, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not. + +[Check out my solution](https://gist.github.com/jdtsmith/55e6a660dd4c0779a600ac81bf9bfc23) (scroll down to see how it acts). Will miss this behavior in other apps! + + +# u/ayyess [🔗](https://www.reddit.com/r/emacs/comments/t3_18hc301/comment/t1_kdobd72) + +**Votes** 12 + +I recently discovered `(setq read-minibuffer-restore-windows nil)` which resolves my frustration that quitting the minibuffer would discard any changes to the window layout while the minibuffer was open. For example, by default, `M-x C-h k k C-g` quits the just opened help buffer. I'm sure to have missed many more QOL improvements from NEWS. # u/elevencupfuls [🔗](https://www.reddit.com/r/emacs/comments/t3_10ktqj0/comment/t1_j5umed8) @@ -1195,7 +1211,7 @@ I intend to use it as a cheatsheet, reminding me about rare keybindings I always I jump into the built-in Elisp files a lot to see how things work. The indentation there is GNU standard, which uses a mix of tabs and spaces for alignment. The tabs have to be rendered as 8 spaces wide for the alignment to work, and I don't actually want that setting anywhere else. Since the files on Mac are inside the application bundle, I don't want to just add a .dir-locals.el file next to them, either. -[Directory classes]() to the rescue! My config makes a new directory variable class, `builtin-elisp`, with a list saying that `emacs-lisp-mode` should use a `tab-width` of 8. Then it applies that class to the Elisp files in the application bundle: +[Directory classes](https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html) to the rescue! My config makes a new directory variable class, `builtin-elisp`, with a list saying that `emacs-lisp-mode` should use a `tab-width` of 8. Then it applies that class to the Elisp files in the application bundle: ```elisp (use-package elisp-mode @@ -1353,6 +1369,32 @@ I made my agenda collapsible (like org headings) by using outline-minor-mode. To ``` +# u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6) + +**Votes** 11 + +I regularly work with different emacs frames on different monitors, and [`framemove`](https://github.com/emacsmirror/framemove) is great for switching between them. It can hook into `windmove` (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions: + +\\\* `fm-up-frame`: move to the frame over the current frame \\\* `fm-down-frame`: move to the frame below the current frame \\\* `fm-left-frame`: move to the frame left of the current frame \\\* `fm-right-frame`: move to the frame right of the current frame + +It's not on any of the major package repositories, so you have to install it manually. Thanks to [`emacsmirror`](https://github.com/emacsmirror), this can for example be done as follows using `use-package` and `straight` (adjust bindings to your liking): + +```elisp +(use-package framemove + :straight (:host github :repo "emacsmirror/framemove") + :init + (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom + :bind + (("C-x 5 " . fm-up-frame) + ("C-x 5 " . fm-down-frame) + ("C-x 5 " . fm-left-frame) + ("C-x 5 " . fm-right-frame))) + +``` + +edit: The only thing I don't understand is why setting `framemove-hook-into-windmove` to `t` doesn't work in via `:config` or `:custom`. The package is loaded, `C-h f` confirms that `fm-up-frame` exists, but `C-h v` doesn't know `framemove-hook-into-windmove`. `framemove-hook-into-windmove` exists after I run `fm-up-frame`, but then it's set to `nil` and not `t`. + + # u/sauntcartas [🔗](https://www.reddit.com/r/emacs/comments/t3_1djdync/comment/t1_l9cmdp9) **Votes** 11 @@ -1373,80 +1415,33 @@ A minor annoyance was that an unwanted link to whatever file location I happened ``` -# u/saltwaterflyguy [🔗](https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8) +# u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q) **Votes** 11 -describe-\\\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v. +Not from me, but I just wanted to share /u/arthurno1 one-line tip to get `which-key` to work with `dired` (see screenshot in linked post): -If you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions. + + +I assume the same trick applies to other mode-maps as well. -# u/geza42 [🔗](https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1) +# u/algor512 [🔗](https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d) **Votes** 11 -If you use an LSP server with semantic highlighting, it's worth checking out the value of `font-lock-maximum-decoration`. For example, I use `c++-mode` with `lsp-mode` (with clangd), I decreased `font-lock-maximum-decoration` to `2`, and I didn't notice any highlighting difference (because the lost highlighting by `c++-mode` gets highlighted by `lsp-mode`), while `c++-mode` font-locking become faster (`c++-mode` 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone). +Recently I discovered that `C-h C-q` (or `M-x help-quick`) opens a small window showing \\\*Quick Help\\\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable `help-quick-sections`. -I use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~ +I intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of `help-quick-sections`. -# u/JDRiverRun [🔗](https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6) +# u/tryptych [🔗](https://www.reddit.com/r/emacs/comments/t3_w3gx6o/comment/t1_ih6ievs) **Votes** 11 -I have long had convenience bindings for `org-emphasize` like `super-i` for *italic*, that match system bindings. But I always wanted these to **be smarter**, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not. +Emacs has better long-lines support now?? -[Check out my solution]() (scroll down to see how it acts). Will miss this behavior in other apps! - - -# u/PriorOutcome [🔗](https://www.reddit.com/r/emacs/comments/t3_15sjm3k/comment/t1_jwff8bw) - -**Votes** 11 - -I've been slowly accumulating cases for "flexing" the thing at point as a more general `capitalize-word` replacement: - -```elisp -;; Stolen from the wiki somewhere -(defun increment-number-at-point () - "Increment the number at point." - (interactive) - (skip-chars-backward "0-9") - (or (looking-at "[0-9]+") - (error "No number at point")) - (replace-match (number-to-string (1+ (string-to-number (match-string 0)))))) - -(defun lw-flex () - "Perform smart flexing at point. - -E.g. capitalize or decapitalize the next word, increment number at point." - (interactive) - (let ((case-fold-search nil)) - (call-interactively - (cond ((looking-at "[0-9]+") #'increment-number-at-point) - ((looking-at "[[:lower:]]") #'capitalize-word) - ((looking-at "==") (delete-char 1) (insert "!") (forward-char 2)) - ((looking-at "!=") (delete-char 1) (insert "=") (forward-char 2)) - ((looking-at "+") (delete-char 1) (insert "-") (forward-char 1)) - ((looking-at "-") (delete-char 1) (insert "+") (forward-char 1)) - ((looking-at "<=") (delete-char 2) (insert ">=") (forward-char 2)) - ((looking-at ">=") (delete-char 2) (insert "<=") (forward-char 2)) - ((looking-at "<") (delete-char 1) (insert ">") (forward-char 1)) - ((looking-at ">") (delete-char 1) (insert "<") (forward-char 1)) - (t #'downcase-word))))) - -``` - -I bind it to `M-c`. - - -# u/tryptych [🔗](https://www.reddit.com/r/emacs/comments/t3_w3gx6o/comment/t1_ih6ievs) - -**Votes** 11 - -Emacs has better long-lines support now?? - -I just noticed while looking at the latest additions in the NEWS: +I just noticed while looking at the latest additions in the NEWS: >\\\*\\\* Emacs is now capable of editing files with arbitrarily long lines. The display of long lines has been optimized, and Emacs no longer chokes when a buffer on display contains long lines. If you still experience slowdowns while editing files with long lines, this is either due to font locking, which you can turn off with M-x font-lock-mode or C-u C-x x f, or to the current major mode or one of the enabled minor modes, in which case you should open the the file with M-x find-file-literally instead of C-x C-f. The variable 'long-line-threshold' controls whether and when these display optimizations are used. @@ -1507,7 +1502,7 @@ You can pop this up in a separate frame using: ``` -Related docs are [here](). +Related docs are [here](https://www.gnu.org/software/auctex/manual/auctex/Error-overview.html). This totally changes the way you can handle errors messages. @@ -1516,7 +1511,7 @@ This totally changes the way you can handle errors messages. **Votes** 11 -I am porting my [config]() from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [MatthewZMD's config]() I think: +I am porting my [config](https://github.com/laurynas-biveinis/dotfiles) from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [MatthewZMD's config](https://github.com/MatthewZMD/.emacs.d) I think: ```elispelisp (add-hook 'focus-out-hook #'garbage-collect) @@ -1553,43 +1548,61 @@ Edited to add: Sorry folks, this doesn't work like I thought it did. See the com I can't say how often I use `dabbrev-expand` (`M-/`) to complete words. Saves me a ton of time. -# u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6) +# u/ilemming [🔗](https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1) **Votes** 10 -I regularly work with different emacs frames on different monitors, and [~framemove~]() is great for switching between them. It can hook into `windmove` (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions: +You know that you can use vars in org source blocks that inject some data, like: -\\\* `fm-up-frame`: move to the frame over the current frame \\\* `fm-down-frame`: move to the frame below the current frame \\\* `fm-left-frame`: move to the frame left of the current frame \\\* `fm-right-frame`: move to the frame right of the current frame +```elisp +#+begin_src bash :var token="bla-bla-bla" +echo ${token} +``` -It's not on any of the major package repositories, so you have to install it manually. Thanks to [~emacsmirror~](), this can for example be done as follows using `use-package` and `straight` (adjust bindings to your liking): + bla-bla-bla -```elisp -(use-package framemove - :straight (:host github :repo "emacsmirror/framemove") - :init - (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom - :bind - (("C-x 5 " . fm-up-frame) - ("C-x 5 " . fm-down-frame) - ("C-x 5 " . fm-left-frame) - ("C-x 5 " . fm-right-frame))) +\#+ENDSRC That can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block. +```elisp +#+name: dirs +#+begin_src bash :results silent +ls ``` -edit: The only thing I don't understand is why setting `framemove-hook-into-windmove` to `t` doesn't work in via `:config` or `:custom`. The package is loaded, `C-h f` confirms that `fm-up-frame` exists, but `C-h v` doesn't know `framemove-hook-into-windmove`. `framemove-hook-into-windmove` exists after I run `fm-up-frame`, but then it's set to `nil` and not `t`. +```js +console.log(data) +``` +\#+ENDSRC But did you know, you can also use elisp there? -# u/fuzzbomb23 [🔗](https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7) +```elisp +#+begin_src js :var data=(if (featurep :system 'macos) "🍎" "🐧") +return data; +``` -**Votes** 10 + 🍎 -One of my favourite tips for managing my init file is the `imenu` support in `use-package`. It's turned off by default, though: +\#+ENDSRC Or previous-like example with dirs but without needing additional source block: ```elisp -(setq use-package-enable-imenu-support t) +#+begin_src clojure :var data=(shell-command-to-string "ls -a ~") +;; all dotfiles +(require '[clojure.string :as str]) + +(->> (str/split data #"\n") + (filter (partial re-find #"^\.*")) + (sort) + (str/join "\n")) ``` -Combined with a nice imenu UI (`consult-imenu` and Vertico, say) you can navigate your init file really quickly. +\#+ENDSRC + + +# u/regob [🔗](https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro) + +**Votes** 10 + +`C-x C-e` to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal) # u/wintershere [🔗](https://www.reddit.com/r/emacs/comments/t3_1eaw1ia/comment/t1_leom8fv) @@ -1616,22 +1629,22 @@ Useful when you include some classless css libraries which require you to add at Don't skip `HTML_DOCTYPE` else it will duplicate the attribute because one extra will be added due to `xml:lang` -# u/UsualOffice1740 [🔗](https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9) +# u/thetemp\_ [🔗](https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy) **Votes** 10 -I've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again. +I recently discovered the [Dimmer](https://github.com/gonewest818/dimmer.el) package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that **is** focused. And of course, you can customize how much it dims and exclude certain buffers. +I love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore. -# u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q) -**Votes** 10 +# u/saltwaterflyguy [🔗](https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8) -Not from me, but I just wanted to share /u/arthurno1 one-line tip to get `which-key` to work with `dired` (see screenshot in linked post): +**Votes** 10 - +describe-\\\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v. -I assume the same trick applies to other mode-maps as well. +If you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions. # u/bopboa [🔗](https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kphrvz3) @@ -1647,6 +1660,31 @@ This is how to have a beacon without installing any packages. ``` +# u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp) + +**Votes** 10 + +Many of you probably know of this, but I found "indirect buffers" useful. + +When I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the "folding" and "narrow" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow `C-x n s` into different headings of the file in different windows. + +Indirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that `C-x 4 c C-x n s` did what I wanted. + + +# u/badmaxton [🔗](https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp) + +**Votes** 10 + +Just added this to the `:init` section of my embark configuration: + +```elisp +(define-key minibuffer-local-map [C-tab] 'embark-select) + +``` + +This allows super-convenient marking of entries for later `embark-all` using control-tab, instead of having to go first through the `embark` menu. (By default, this key binding is mapped to `file-cache-minibuffer-complete`, which I never use.) + + # u/camelcaset [🔗](https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kgce54q) **Votes** 10 @@ -1691,31 +1729,75 @@ M-x remove-hook And you've got an interactive interface (using `completing-read`) for removing arbitrary elements from any list-like variable. It's technically for altering hooks, but you can abuse it to fool around with lists, too. -# u/frosch03 [🔗](https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a) +# u/PriorOutcome [🔗](https://www.reddit.com/r/emacs/comments/t3_15sjm3k/comment/t1_jwff8bw) **Votes** 10 -Very useful, but I keep forgetting it: +I've been slowly accumulating cases for "flexing" the thing at point as a more general `capitalize-word` replacement: -If you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: `C-x -` +```elisp +;; Stolen from the wiki somewhere +(defun increment-number-at-point () + "Increment the number at point." + (interactive) + (skip-chars-backward "0-9") + (or (looking-at "[0-9]+") + (error "No number at point")) + (replace-match (number-to-string (1+ (string-to-number (match-string 0)))))) + +(defun lw-flex () + "Perform smart flexing at point. + +E.g. capitalize or decapitalize the next word, increment number at point." + (interactive) + (let ((case-fold-search nil)) + (call-interactively + (cond ((looking-at "[0-9]+") #'increment-number-at-point) + ((looking-at "[[:lower:]]") #'capitalize-word) + ((looking-at "==") (delete-char 1) (insert "!") (forward-char 2)) + ((looking-at "!=") (delete-char 1) (insert "=") (forward-char 2)) + ((looking-at "+") (delete-char 1) (insert "-") (forward-char 1)) + ((looking-at "-") (delete-char 1) (insert "+") (forward-char 1)) + ((looking-at "<=") (delete-char 2) (insert ">=") (forward-char 2)) + ((looking-at ">=") (delete-char 2) (insert "<=") (forward-char 2)) + ((looking-at "<") (delete-char 1) (insert ">") (forward-char 1)) + ((looking-at ">") (delete-char 1) (insert "<") (forward-char 1)) + (t #'downcase-word))))) -And if you want to balance these two buffers again just use `C-x +` +``` +I bind it to `M-c`. -# u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz) + +# u/gusbrs [🔗](https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts) **Votes** 10 -Put the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press) +I was converting some old `.odt` notes files to `.org` today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: `repunctuate-sentences`. I have no idea if this is new or has always been there. It is new to me. It uses `query-replace-regexp`, so it's the same experience. And also can be configured for exclusions with `repunctuate-sentences-filter`. Neat! -Win - Alt - Ctrl - Space - Ctrl - Alt - Win + +# u/sauntcartas [🔗](https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv) + +**Votes** 10 + +I work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice: + +```elisp +(defun default-to-main-project (dir) + (or dir *main-project-dir*)) + +(advice-add 'projectile-ensure-project :override #'default-to-main-project) + +``` + +I lose some of the functionality of `projectile-ensure-project`, but I never used it anyway. # u/AnugNef4 [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_ja41lso) **Votes** 10 -How I got my Info Directory node `C-h i` to display all my installed .info files living under `/opt/homebrew` on an M1 Mac. I run emacs-plus@29 from [d12frosted on github](). +How I got my Info Directory node `C-h i` to display all my installed .info files living under `/opt/homebrew` on an M1 Mac. I run emacs-plus@29 from [d12frosted on github](https://github.com/d12frosted/homebrew-emacs-plus). init.el snippet @@ -1765,7 +1847,7 @@ I started using `god-mode`, but I found it hard to get used to it at first: ther I wrote up a `god-mode`\­specific `describe-key`, which translates `god-mode` key-sequences into commands and shows their usual description. I think it's a great way to get familiar with how the package handles keys, and it allows users to invoke `describe-key` without leaving god-mode (previously, most keys would just show information about the generic `god-mode-self-insert-command`) -I also reached out to the package's maintainers, and this feature (after some tweaking) [just got added to the master branch](). It was a great way to get familiar with `god-mode` code and its behavior, and I'm happy to have made my first contribution to an Emacs package. +I also reached out to the package's maintainers, and this feature (after some tweaking) [just got added to the master branch](https://github.com/emacsorphanage/god-mode). It was a great way to get familiar with `god-mode` code and its behavior, and I'm happy to have made my first contribution to an Emacs package. # u/kickingvegas1 [🔗](https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_innk62a) @@ -1979,7 +2061,7 @@ One of the most useful bindings for me: **Votes** 10 -Read [SICP](). Preferably in Info, installable through MELPA or: []() +Read [SICP](https://mitpress.mit.edu/sites/default/files/sicp/index.html). Preferably in Info, installable through MELPA or: [https://github.com/webframp/sicp-info](https://github.com/webframp/sicp-info) # u/Stefan-Kangas [🔗](https://www.reddit.com/r/emacs/comments/t3_pxqvtm/comment/t1_hexdfiq) @@ -2201,66 +2283,66 @@ If you want to switch between two themes, depending on time of day (e.g. a light This selects the correct theme when starting Emacs and automatically switch when the times come. -# u/regob [🔗](https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro) - -**Votes** 9 - -`C-x C-e` to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal) - - -# u/thetemp\_ [🔗](https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy) +# u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1gfhkdg/comment/t1_lui5ao9) **Votes** 9 -I recently discovered the [Dimmer]() package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that **is** focused. And of course, you can customize how much it dims and exclude certain buffers. - -I love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore. - - -# u/JDRiverRun [🔗](https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3) +I've recently discovered [`org-pdftools`](https://github.com/fuxialexander/org-pdftools) and it offers everything I need for annotating pdfs in emacs. I mainly use it to enhance the inbuilt function `org-store-link`: -**Votes** 9 +\\\* mark a passage in the pdf, run `M-x org-store-link`, and it creates a highlight in the pdf (technically an empty annotation) and copies a link to it. \\\* run `C-c C-l` in any org-buffer, and it pastes the link and prompts you for a name. -A few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [this gist]() for the details. +The installation is easy, you just need to hook it into `org-mode`: +```elisp +(use-package org-pdftools + :after (org pdf-tools) + :hook (org-mode . org-pdftools-setup-link)) -# u/demosthenex [🔗](https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6) +``` -**Votes** 9 +The only thing to keep in mind is that the highlights in the pdf are not automatically deleted, as you delete the link in the org buffer. You have to do that manually in the pdf (`C-c C-a l` to list all highlights, `D` to delete). -M-x ielm Use the repl while learning elisp coding. I had no idea! +It has less features than [`org-noter`](https://github.com/org-noter/org-noter), but it is more flexible, which is why it suits my use-case better. Unfortunately, it has `org-noter` as a dependency, so you will end up loading it either way. -# u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp) +# u/fuzzbomb23 [🔗](https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7) **Votes** 9 -Many of you probably know of this, but I found "indirect buffers" useful. +One of my favourite tips for managing my init file is the `imenu` support in `use-package`. It's turned off by default, though: -When I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the "folding" and "narrow" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow `C-x n s` into different headings of the file in different windows. +```elisp +(setq use-package-enable-imenu-support t) +``` -Indirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that `C-x 4 c C-x n s` did what I wanted. +Combined with a nice imenu UI (`consult-imenu` and Vertico, say) you can navigate your init file really quickly. -# u/badmaxton [🔗](https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp) +# u/pt-guzzardo [🔗](https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx) **Votes** 9 -Just added this to the `:init` section of my embark configuration: - ```elisp -(define-key minibuffer-local-map [C-tab] 'embark-select) +(defun copy-source-for-reddit () + (interactive) + (let ((contents (buffer-substring (point) (mark)))) + (with-temp-buffer + (insert contents) + (mark-whole-buffer) + (indent-rigidly (point) (mark) 4 t) + (mark-whole-buffer) + (kill-ring-save 0 0 t)))) ``` -This allows super-convenient marking of entries for later `embark-all` using control-tab, instead of having to go first through the `embark` menu. (By default, this key binding is mapped to `file-cache-minibuffer-complete`, which I never use.) +A handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer. # u/lesliesrussell [🔗](https://www.reddit.com/r/emacs/comments/t3_198rnkj/comment/t1_kibmgv2) **Votes** 9 -[transient map for movement]() +[transient map for movement](https://gist.github.com/lesliesrussell/46302d413fcf49e9717eeea57fdadcbf) Defines a transient keymap for movement controls and sets up a global key binding to activate this transient map. This transient map, \\~my-movement-transient-map\\~, includes bindings for various movement commands like moving forward or backward by a word or character and moving to the next or previous line. The \\~activate-my-movement-map\\~ function is defined to activate this transient map, and it is globally bound to \\~C-f\\~. @@ -2275,25 +2357,11 @@ This is a neat way to create a custom, modal-like interface for movement within I didn't want to drop code in the thread so i put it in a gist -# u/Netherus [🔗](https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7) +# u/BunnyLushington [🔗](https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhrzybp) **Votes** 9 -Just recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me. - - -# u/gusbrs [🔗](https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts) - -**Votes** 9 - -I was converting some old `.odt` notes files to `.org` today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: `repunctuate-sentences`. I have no idea if this is new or has always been there. It is new to me. It uses `query-replace-regexp`, so it's the same experience. And also can be configured for exclusions with `repunctuate-sentences-filter`. Neat! - - -# u/BunnyLushington [🔗](https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhrzybp) - -**Votes** 9 - -I found myself debugging [JWTs]() earlier this week and whomped up a little function to decode them from a region into a help buffer. +I found myself debugging [JWTs](https://jwt.io) earlier this week and whomped up a little function to decode them from a region into a help buffer. ```elisp (defun ii/decode-jwt (start end &optional jwt) @@ -2319,48 +2387,13 @@ I'd forgotten about `with-output-to-temp-buffer` which is pretty handy. The `t` (This should be obvious but note that the JWT is not validated or verified. This is intended for debugging only and the JWT should not be trusted.) -# u/sauntcartas [🔗](https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv) - -**Votes** 9 - -I work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice: - -```elisp -(defun default-to-main-project (dir) - (or dir *main-project-dir*)) - -(advice-add 'projectile-ensure-project :override #'default-to-main-project) - -``` - -I lose some of the functionality of `projectile-ensure-project`, but I never used it anyway. - - -# u/slinchisl [🔗](https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jca66k0) +# u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz) **Votes** 9 -I'm once again reminded of the utility of `read-key` for small functions where one wants a nicer interface for choosing an alternative than universal arguments; taking an optional prompt, it simply reads a key from the keyboard and returns it. - -For example, I recently wanted a function that prints a set of predefined dates for me into the current buffer, and it was as easy as +Put the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press) -```elisp -(defun slot/insert-time () - (interactive) - (let* ((formats '((?i "ISO 8601" "%Y-%m-%d") - (?l "DDmmmYYYY" "%d%b%Y") - (?t "Time" "%H:%M"))) - (key (read-key - (cl-loop for (key label _) in formats - concat (format "[%s] %s " - (propertize (single-key-description key) 'face 'bold) - label))))) - (->> (alist-get key formats) - cl-second - format-time-string - downcase ; Jan -> jan - insert))) -``` +Win - Alt - Ctrl - Space - Ctrl - Alt - Win # u/pathemata [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mpo5y) @@ -2372,58 +2405,6 @@ Does anyone have an `aspell` setup with multiple dictionaries? When I try `--extra-dict` option I get an error: `Expected language "en" but got "de"`. -# u/SlowValue [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8u1ebf) - -**Votes** 9 - -I put a couple of similar functions on my `` key (with all combinations of modifier keys) and tend to forget the meanings of those combinations. - -So I made a small function to give some help for a list of keybindings.: - -```elisp -(defun my-generate-keybind-doc-on-keys (&rest keys) - "generate help on some given keybindings (kbd style)." - (substring - (apply #'concat - (mapcar #'(lambda (key) - (let* ((fun (key-binding (kbd key))) - (fun-name (symbol-name fun)) - (doc (documentation fun 'raw)) - (oneline (substring doc 0 (string-match "\n" doc)))) - (put-text-property 0 (length key) 'face 'font-lock-keyword-face key) - (put-text-property 0 (length fun-name) 'face 'font-lock-function-name-face fun-name) - (put-text-property 0 (length oneline) 'face 'font-lock-doc-face oneline) - (format "%10s : %-30s → %s\n" key fun-name oneline))) - keys)) - 0 -1)) - -``` - -To show that help in the echo buffer, one needs to define a command, which can be bound to a key: - -```elisp -(defun my-show-help-on-some-keys () - "demo generate help on 3 keys" - (interactive) - (message (my-generate-keybind-doc-on-keys "C-s" - " k" - "C-c !"))) - -``` - -Then calling the command `my-show-help-on-some-keys`, shows following message in the echo buffer: - -```elisp - C-s : isearch-forward → Do incremental search forward. - k : helpful-key → Show help for interactive command bound to KEY-SEQUENCE. - C-c ! : shell-here → Open a shell relative to default-directory. - - -``` - -Remark: I know that `which-key` exists, but I'm already above that level of knowledge and don't need `which-key` anymore. - - # u/gusbrs [🔗](https://www.reddit.com/r/emacs/comments/t3_ywnt6p/comment/t1_ix0a6ui) **Votes** 9 @@ -2474,7 +2455,7 @@ Any suggestions would be appreciated! **Votes** 9 -I've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: []() +I've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md) If you fancy procrastinating for a bit today… @@ -2592,7 +2573,7 @@ Usually I switch to `foobar.hpp`, kill the necessary part, switch to `foobar.cpp **Votes** 9 -Checkout [Topsy Mode](), it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup. +Checkout [Topsy Mode](https://github.com/alphapapa/topsy.el), it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup. # u/oantolin [🔗](https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8utmh2) @@ -2717,7 +2698,7 @@ After a while I extended org-export to get a shortcut (`C-e C-s o M`) to automat **Votes** 9 -org-variable-pitch.el users might want to give [~valign~]() a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add `org-link` to `org-variable-pitch-fixed-faces` because valign-mode handles variable pitch links neatly in tables. +org-variable-pitch.el users might want to give [`valign`](https://github.com/casouri/valign) a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add `org-link` to `org-variable-pitch-fixed-faces` because valign-mode handles variable pitch links neatly in tables. If you don't use OVP but use e.g. latex fragments in tables or just pictures, this one is still very helpful. @@ -2839,7 +2820,7 @@ end tell \\\*\* u/attentoredaz [🔗](https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_iku77h0) \\\*Votes\* 9 -Using [zotra](), [citar]() and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with "org-biblatex bibliographies" which are basically like [org-bibtex]() but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable `#+bibliography: my-org-biblatex-file.org` declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp. +Using [zotra](https://github.com/mpedramfar/zotra), [citar](https://github.com/emacs-citar/citar) and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with "org-biblatex bibliographies" which are basically like [org-bibtex](http://gewhere.github.io/org-bibtex) but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable `#+bibliography: my-org-biblatex-file.org` declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp. # u/b3n [🔗](https://www.reddit.com/r/emacs/comments/t3_oxo1xh/comment/t1_h85cv7f) @@ -2882,11 +2863,11 @@ I posted this in the emacsclient thread, but I think it deserves to live here as The emacsclient / server system is great. If you have it listening on tcp and port forward that when connecting to remote machine it adds another level of power. -I use [emacs-vterm]() for a terminal inside emacs, so I've got a lot of commands remapped. Like `man` runs `emacsclient ... man ..`, which opens the man page in the "other" buffer, so it doesn't interrupt my flow. I use "scroll-other-window" to navigate the man page while I still have my prompt. `magit`, `dired`, and others map to their `emacsclient` equivalents. +I use [emacs-vterm](https://github.com/akermu/emacs-libvterm) for a terminal inside emacs, so I've got a lot of commands remapped. Like `man` runs `emacsclient ... man ..`, which opens the man page in the "other" buffer, so it doesn't interrupt my flow. I use "scroll-other-window" to navigate the man page while I still have my prompt. `magit`, `dired`, and others map to their `emacsclient` equivalents. I've written wrapper script for e/emacs client that I've come to call `e`, because it saves keystrokes -\#### [The full repo is here e-emacs.sh]() +\#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/) It does the standard things you would expect, starts emacs if it's not already started, open a file in a new buffer / window / terminal and optionally wait for you to finish or have the shell continue. @@ -2898,7 +2879,7 @@ Or the poor man's blog system: `e -t header_template.html body_template.html foo See the repo for more examples and to download. The notes of getting it working on remote machines aren't the cleanest. If you have any suggestions or features that would make your life easier let me know; submit an issue or comment here. -\#### [The full repo is here e-emacs.sh]() +\#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/) `~I really should post this on one of the share your stuff posts. But I get distracted.~` There, I did it. @@ -2909,7 +2890,7 @@ In case you can't tell I **really** like emacs and it's client server model. **Votes** 9 -A blog post regarding my own Emacs config aiming to get the same user experience on both TUI and GUI. []() +A blog post regarding my own Emacs config aiming to get the same user experience on both TUI and GUI. [https://www.rahuljuliato.com/posts/lemacs](https://www.rahuljuliato.com/posts/lemacs) # u/emacsomancer [🔗](https://www.reddit.com/r/emacs/comments/t3_gqsz8u/comment/t1_fs5sq09) @@ -2927,28 +2908,6 @@ Each person gets a different colour to indicate the part of the file they’re e -# u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1gfhkdg/comment/t1_lui5ao9) - -**Votes** 8 - -I've recently discovered [~org-pdftools~]() and it offers everything I need for annotating pdfs in emacs. I mainly use it to enhance the inbuilt function `org-store-link`: - -\\\* mark a passage in the pdf, run `M-x org-store-link`, and it creates a highlight in the pdf (technically an empty annotation) and copies a link to it. \\\* run `C-c C-l` in any org-buffer, and it pastes the link and prompts you for a name. - -The installation is easy, you just need to hook it into `org-mode`: - -```elisp -(use-package org-pdftools - :after (org pdf-tools) - :hook (org-mode . org-pdftools-setup-link)) - -``` - -The only thing to keep in mind is that the highlights in the pdf are not automatically deleted, as you delete the link in the org buffer. You have to do that manually in the pdf (`C-c C-a l` to list all highlights, `D` to delete). - -It has less features than [~org-noter~](), but it is more flexible, which is why it suits my use-case better. Unfortunately, it has `org-noter` as a dependency, so you will end up loading it either way. - - # u/fv\_\_ [🔗](https://www.reddit.com/r/emacs/comments/t3_1fzmgwb/comment/t1_lr5ceqe) **Votes** 8 @@ -2956,56 +2915,6 @@ It has less features than [~org-noter~]( C-x in a transient popup shows menu to save selected options e.g., it can be used to select ~ –force-with-lease~ by default while pushing in magit (P p) -# u/ilemming [🔗](https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1) - -**Votes** 8 - -You know that you can use vars in org source blocks that inject some data, like: - -```elisp -#+begin_src bash :var token="bla-bla-bla" -echo ${token} -``` - - bla-bla-bla - -\#+ENDSRC That can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block. - -```elisp -#+name: dirs -#+begin_src bash :results silent -ls -``` - -```js -console.log(data) -``` - -\#+ENDSRC But did you know, you can also use elisp there? - -```elisp -#+begin_src js :var data=(if (featurep :system 'macos) "🍎" "🐧") -return data; -``` - - 🍎 - -\#+ENDSRC Or previous-like example with dirs but without needing additional source block: - -```elisp -#+begin_src clojure :var data=(shell-command-to-string "ls -a ~") -;; all dotfiles -(require '[clojure.string :as str]) - -(->> (str/split data #"\n") - (filter (partial re-find #"^\.*")) - (sort) - (str/join "\n")) -``` - -\#+ENDSRC - - # u/meedstrom [🔗](https://www.reddit.com/r/emacs/comments/t3_1fe504e/comment/t1_lmzbyro) **Votes** 8 @@ -3039,34 +2948,28 @@ Highlight regexp or strings in your buffer with `M+s h` good for analyzing logfi **Votes** 8 -For users of [rg.el]() (emacs interface to ripgrep) there is [rga]() (ripgrep-all) a wrapper around ripgrep that "enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc." You can set the rg executable in the configuration of rg.el like so: `(setq rg-executable (executable-find "rga")` to enable search in multiple document types. +For users of [rg.el](https://github.com/dajva/rg.el) (emacs interface to ripgrep) there is [rga](https://github.com/phiresky/ripgrep-all) (ripgrep-all) a wrapper around ripgrep that "enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc." You can set the rg executable in the configuration of rg.el like so: `(setq rg-executable (executable-find "rga")` to enable search in multiple document types. -# u/AdjointFunctor [🔗](https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l359pqx) +# u/JDRiverRun [🔗](https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3) **Votes** 8 -I (re) discovered rectangle mode recently. Very useful when deleting lots of indents. C-x spc then make the region. +A few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [this gist](https://gist.github.com/jdtsmith/a169362879388bc1bdf2bbb977782d4f) for the details. -# u/pt-guzzardo [🔗](https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx) +# u/AdjointFunctor [🔗](https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l359pqx) **Votes** 8 -```elisp -(defun copy-source-for-reddit () - (interactive) - (let ((contents (buffer-substring (point) (mark)))) - (with-temp-buffer - (insert contents) - (mark-whole-buffer) - (indent-rigidly (point) (mark) 4 t) - (mark-whole-buffer) - (kill-ring-save 0 0 t)))) +I (re) discovered rectangle mode recently. Very useful when deleting lots of indents. C-x spc then make the region. -``` -A handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer. +# u/demosthenex [🔗](https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6) + +**Votes** 8 + +M-x ielm Use the repl while learning elisp coding. I had no idea! # u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_18mplfa/comment/t1_ke5xr5j) @@ -3093,6 +2996,13 @@ Long story short, here's how you force `project` to find the actual project root `(setq project-vc-extra-root-markers '(".project.el" ".projectile" ".dir-locals.el"))` +# u/Netherus [🔗](https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7) + +**Votes** 8 + +Just recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me. + + # u/AP145 [🔗](https://www.reddit.com/r/emacs/comments/t3_16hh7u4/comment/t1_k1803gl) **Votes** 8 @@ -3100,6 +3010,44 @@ Long story short, here's how you force `project` to find the actual project root I used to always get confused why people say that the default Emacs key bindings hurt their pinky's, but then I realized that I don't touch type and thus I don't have to stretch my fingers anywhere for the default key bindings. Ironically my ineptitude at typing has saved me from repetitive stress injuries. +# u/frosch03 [🔗](https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a) + +**Votes** 8 + +Very useful, but I keep forgetting it: + +If you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: `C-x -` + +And if you want to balance these two buffers again just use `C-x +` + + +# u/slinchisl [🔗](https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jca66k0) + +**Votes** 8 + +I'm once again reminded of the utility of `read-key` for small functions where one wants a nicer interface for choosing an alternative than universal arguments; taking an optional prompt, it simply reads a key from the keyboard and returns it. + +For example, I recently wanted a function that prints a set of predefined dates for me into the current buffer, and it was as easy as + +```elisp +(defun slot/insert-time () + (interactive) + (let* ((formats '((?i "ISO 8601" "%Y-%m-%d") + (?l "DDmmmYYYY" "%d%b%Y") + (?t "Time" "%H:%M"))) + (key (read-key + (cl-loop for (key label _) in formats + concat (format "[%s] %s " + (propertize (single-key-description key) 'face 'bold) + label))))) + (->> (alist-get key formats) + cl-second + format-time-string + downcase ; Jan -> jan + insert))) +``` + + # u/w0ntfix [🔗](https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_jajfxc9) **Votes** 8 @@ -3115,6 +3063,58 @@ turning off org-elements cache speeds up input latency for me (found from profil it seems (at least on my org 9.6.1) to update the cache after calls to `org-self-insert-command` (so, a lot!) +# u/SlowValue [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8u1ebf) + +**Votes** 8 + +I put a couple of similar functions on my `` key (with all combinations of modifier keys) and tend to forget the meanings of those combinations. + +So I made a small function to give some help for a list of keybindings.: + +```elisp +(defun my-generate-keybind-doc-on-keys (&rest keys) + "generate help on some given keybindings (kbd style)." + (substring + (apply #'concat + (mapcar #'(lambda (key) + (let* ((fun (key-binding (kbd key))) + (fun-name (symbol-name fun)) + (doc (documentation fun 'raw)) + (oneline (substring doc 0 (string-match "\n" doc)))) + (put-text-property 0 (length key) 'face 'font-lock-keyword-face key) + (put-text-property 0 (length fun-name) 'face 'font-lock-function-name-face fun-name) + (put-text-property 0 (length oneline) 'face 'font-lock-doc-face oneline) + (format "%10s : %-30s → %s\n" key fun-name oneline))) + keys)) + 0 -1)) + +``` + +To show that help in the echo buffer, one needs to define a command, which can be bound to a key: + +```elisp +(defun my-show-help-on-some-keys () + "demo generate help on 3 keys" + (interactive) + (message (my-generate-keybind-doc-on-keys "C-s" + " k" + "C-c !"))) + +``` + +Then calling the command `my-show-help-on-some-keys`, shows following message in the echo buffer: + +```elisp + C-s : isearch-forward → Do incremental search forward. + k : helpful-key → Show help for interactive command bound to KEY-SEQUENCE. + C-c ! : shell-here → Open a shell relative to default-directory. + + +``` + +Remark: I know that `which-key` exists, but I'm already above that level of knowledge and don't need `which-key` anymore. + + # u/Nondv [🔗](https://www.reddit.com/r/emacs/comments/t3_108zin2/comment/t1_j4ct1y1) **Votes** 8 @@ -3164,7 +3164,7 @@ Is there a package/piece of code out there to: 2. execute arbitrary code 3. close frame on completion -Kind of like [emacs-everywhere]() but for arbitrary code. +Kind of like [emacs-everywhere](https://github.com/tecosaur/emacs-everywhere/) but for arbitrary code. # u/WorldsEndless [🔗](https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_inqralq) @@ -3228,22 +3228,22 @@ Pure awesomeness, thanks a lot for Magit/ Magit forge ! \\\*\* u/slinchisl [🔗](https://www.reddit.com/r/emacs/comments/t3_uxcm6i/comment/t1_i9xcaoa) \\\*Votes\* 8 -[arxiv-citation]() from my [last post]() is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)! +[arxiv-citation](https://github.com/slotthe/arxiv-citation) from my [last post](https://old.reddit.com/r/emacs/comments/ufvg93/my_phd_research_workflowemacs_inside/) is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)! -On that note, I've written a little bit about [calling Emacs from XMonad](). The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful. +On that note, I've written a little bit about [calling Emacs from XMonad](https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html). The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful. # u/diamondnbond [🔗](https://www.reddit.com/r/emacs/comments/t3_us7zae/comment/t1_i928gaj) **Votes** 8 -[I Recently discovered engine-mode.]() +[I Recently discovered engine-mode.](https://github.com/DiamondBond/emacs/blob/master/config.org#initialize-engine-mode) \\\*\* u/mmarshall540 [🔗](https://www.reddit.com/r/emacs/comments/t3_un4wf8/comment/t1_i88sp07) \\\*Votes\* 8 Here's a little solution to a minor complaint about \`isearch\` that I think is fairly common. -TLDR: See [this old StackExchange question]() +TLDR: See [this old StackExchange question](https://emacs.stackexchange.com/questions/32373/go-to-start-of-search-string-after-ret) Often, I'll want to go to a precise location in a buffer to correct a typo. If that location is behind point (as it usually is if I notice the typo shortly after entering it), then \`isearch-backward\` works great. You press "C-r" and type some characters starting with your target until the location becomes the current result. As soon as the cursor jumps to your target location, you can use an editing command like "C-t", which exits isearch automatically for you. Or you can press "C-m" to exit isearch-mode and then start inserting text at that location. Wonderful! @@ -3328,7 +3328,7 @@ Call it with M-x, insert the name of the function you want to declare (with comp **Votes** 8 -A colleague just showed me Intellij's "[compare with clipboard]()" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections. +A colleague just showed me Intellij's "[compare with clipboard](https://www.jetbrains.com/help/idea/comparing-files-and-folders.html#clipboard)" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections. It didn't take me long to implement something similar: @@ -3351,7 +3351,7 @@ It's not ideal though. In particular, is there a better way to insert the "clipb \\\*\* u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_pk6akd/comment/t1_hc3bikc) \\\*Votes\* 8 -I'm using [orderless]() for completion but I also want to walk through files with initials only, to do something like [like this]() for example. It only requires to ignore the case and ask the minibuffer to use initials. +I'm using [orderless](https://github.com/oantolin/orderless) for completion but I also want to walk through files with initials only, to do something like [like this](https://imgur.com/a/CJg8MGw) for example. It only requires to ignore the case and ask the minibuffer to use initials. ```elisp (use-package orderless @@ -3629,7 +3629,7 @@ Here's the code, maybe there can be a lot of improvements: \\\*\* u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfxbwgy) \\\*Votes\* 8 -I tried [marginalia]() with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings. +I tried [marginalia](https://github.com/minad/marginalia) with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings. # u/martinslot [🔗](https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfwlm9q) @@ -3667,7 +3667,7 @@ When I have multiple buffers opened and I switch from another program to emacs I **Votes** 8 -Hippie-expand google search suggestions. Completely inspired from [shell-parse.el](). +Hippie-expand google search suggestions. Completely inspired from [shell-parse.el](https://github.com/malloc47/shell-parse.el/blob/master/shell-parse.el). I've added `try-expand-google-completion` to the bottom of my `hippie-expand-try-functions-list` @@ -3741,12 +3741,12 @@ The advice below quiets this warning, and inserts a dash whenever space is press **Votes** 8 -AucTex users: You're missing out if you don't use [CDLatex](). It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is always available, not just during snippet entry. It's difficult to explain, so here are some demos: +AucTex users: You're missing out if you don't use [CDLatex](https://github.com/cdominik/cdlatex). It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is always available, not just during snippet entry. It's difficult to explain, so here are some demos: -1. [Fast input with cdlatex and preview.el]() -2. [Fast input with keys displayed]() +1. [Fast input with cdlatex and preview.el](https://gfycat.com/heavenlynegligiblehoiho) +2. [Fast input with keys displayed](https://gfycat.com/safeidolizedlangur) -I wrote a longer post explaining [how I set up AucTex]() recently. +I wrote a longer post explaining [how I set up AucTex](https://www.reddit.com/r/emacs/comments/g8ecpj/advice_for_auclatex_what_keybinds_do_you_find/foo64ge/) recently. CDLaTeX was written by Carsten Dominik, the author of Org-mode and reftex. Thus Org ships with an `org-cdlatex` minor-mode that makes these features available in org-mode. @@ -3755,14 +3755,14 @@ CDLaTeX was written by Carsten Dominik, the author of Org-mode and reftex. Thus **Votes** 8 -[A beginers guide to emacs 24 or later by sasha chua](![img](https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png)) this helped me tremendously to get started with emacs. +[A beginers guide to emacs 24 or later by sasha chua](https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png) this helped me tremendously to get started with emacs. # u/ji99 [🔗](https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqcycvb) **Votes** 8 -A rudimentary interface for the fabulous [Links web browser](): +A rudimentary interface for the fabulous [Links web browser](http://links.twibright.com/user_en.html): ```elisp (defun links-browser (&optional link new-window) @@ -3814,8 +3814,8 @@ A rudimentary interface for the fabulous [Links web browser]() a lot quicker! -2. `(setq eglot-events-buffer-size 0)`, `(fset #'jsonrpc--log-event #'ignore)` and [eglot-booster]() makes eglot A LOT quicker! +1. `(setq process-adaptive-read-buffering nil)` makes [EAT](https://codeberg.org/akib/emacs-eat) a lot quicker! +2. `(setq eglot-events-buffer-size 0)`, `(fset #'jsonrpc--log-event #'ignore)` and [eglot-booster](https://github.com/jdtsmith/eglot-booster) makes eglot A LOT quicker! # u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_1afd05g/comment/t1_kob6a5m) @@ -3886,7 +3886,7 @@ So the flow is: **Votes** 8 -recently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [generate org macros from my `R` script](), [display their values rather than the macro text](), and pass `org-macro-templates` to `consult--read` to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on! +recently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [generate org macros from my `R` script](https://emacs.stackexchange.com/questions/14647/use-code-variable-in-org-mode-continuous-text), [display their values rather than the macro text](https://notes.alexkehayias.com/emacs-inline-macro-in-the-buffer/), and pass `org-macro-templates` to `consult--read` to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on! # u/sebasTEEan [🔗](https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhwipv8) @@ -3957,11 +3957,11 @@ I found this one-liner yesterday, added it it to the `:config` section of ****Ev \\\*\* u/slinchisl [🔗](https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imjs86m) \\\*Votes\* 8 -I don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [rapidly capture ideas]() by using XMonad's org-mode integration! +I don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [rapidly capture ideas](https://tony-zorman.com/posts/orgmode-prompt/2022-08-27-xmonad-and-org-mode.html) by using XMonad's org-mode integration! \\\*\* u/poinkalum [🔗](https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8rdjx9) \\\*Votes\* 8 -If you follow master, you can use the very useful command `execute-extended-command-for-buffer` by using `M-X` (with a capital "X"), that implements the behaviour described in [this blog post by Lars](). It will only show commands that are relevant to the current major mode. +If you follow master, you can use the very useful command `execute-extended-command-for-buffer` by using `M-X` (with a capital "X"), that implements the behaviour described in [this blog post by Lars](https://lars.ingebrigtsen.no/2021/02/16/command-discovery-in-emacs/). It will only show commands that are relevant to the current major mode. # u/ji99 [🔗](https://www.reddit.com/r/emacs/comments/t3_k4gv0x/comment/t1_ge8si78) @@ -4144,7 +4144,7 @@ you can have an org-mode file in source block in an org file \\\*\* u/slinchisl [🔗](https://www.reddit.com/r/emacs/comments/t3_pt2xws/comment/t1_hdtoivy) \\\*Votes\* 8 -I've been playing around with Emacs 28's [repeat-mode]() a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function: +I've been playing around with Emacs 28's [repeat-mode](https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp?id=12409c9064c386a496dcbdca76b790108f6c1cad) a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function: ```elisp (defmacro defrepeatmap (symbol &optional pairs docstring) @@ -4202,7 +4202,7 @@ I use this often when working on large files. You can bookmark up to 9 places in It works like this: `C-c 0` creates a bookmark and `C-c <1-9>` jumps into a bookmark. I've written about this on my old blog. I still use this from time to time. -[Faster buffer bookmarking in Emacs](). +[Faster buffer bookmarking in Emacs](https://jcubic.wordpress.com/2012/01/25/faster-buffer-bookmarking-in-emacs/). \\\*\* u/WorldsEndless [🔗](https://www.reddit.com/r/emacs/comments/t3_z8ltei/comment/t1_izxi6ie) \\\*Votes\* 8 @@ -4255,7 +4255,7 @@ For some time I have wished I could color code the background colors of differen **Votes** 8 -I had the [defrepeater]() package for a while, but didn't realize you could use it this elegantly! +I had the [defrepeater](https://github.com/alphapapa/defrepeater.el) package for a while, but didn't realize you could use it this elegantly! ```elisp (global-set-key [remap transpose-lines] (defrepeater #'transpose-lines)) @@ -4269,7 +4269,7 @@ Something similar is actually in the readme, but I guess I glossed over it back **Votes** 8 -Just discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. []() +Just discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. [https://github.com/DamienCassou/desktop-environment](https://github.com/DamienCassou/desktop-environment) Thanks Damien ! @@ -4330,7 +4330,7 @@ I will make some more improvements in the coming days, so if I split the window **Votes** 8 -In eshell, `cd =xxx` behaves like `z xxx` in [zoxide](), jump to recent directory matching `xxx` pattern. +In eshell, `cd =xxx` behaves like `z xxx` in [zoxide](https://github.com/ajeetdsouza/zoxide), jump to recent directory matching `xxx` pattern. # u/desquared [🔗](https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_janipaz) @@ -4375,7 +4375,7 @@ but rather in regular editing buffers that are visiting your own files. \\\*\* u/nicholashubbard [🔗](https://www.reddit.com/r/emacs/comments/t3_rr330u/comment/t1_hqlp0en) \\\*Votes\* 8 -Here is a consult source for [perspective.el]() +Here is a consult source for [perspective.el](https://github.com/nex3/perspective-el) ```elisp (defvar consult--source-perspective @@ -4403,7 +4403,7 @@ I write in Arabic. **Votes** 8 -The [texdoc]() CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the `TeX-documentation-texdoc` command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [tab-completion](), which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with `completing-read` and `call-process` to call the terminal command I created my own `my-texdoc` command with interactive candidate selection. It's available as [github gist here](), but I can also paste the code: +The [texdoc](https://github.com/TeX-Live/texdoc/wiki/Tab-completion) CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the `TeX-documentation-texdoc` command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [tab-completion](https://github.com/TeX-Live/texdoc/wiki/Tab-completion), which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with `completing-read` and `call-process` to call the terminal command I created my own `my-texdoc` command with interactive candidate selection. It's available as [github gist here](https://gist.github.com/meliache/e645bf50c6aeac8e6e58b92c6bddac20), but I can also paste the code: ```elisp (defun my-texdoc--get-package-list () diff --git a/out.org b/out.org index 173aff4..2e00976 100644 --- a/out.org +++ b/out.org @@ -1,12 +1,5 @@ -** u/TheDrownedKraken [[https://www.reddit.com/r/emacs/comments/t3_o68i0v/comment/t1_h2rdkkz][🔗]] -*Votes* 37 - -Do you think it might be good to make this a little less frequently refreshed? There are usually some great tips that get lost to Reddit’s ephemerality pretty quickly. - -I think monthly would be better, given the modest size of this subreddit. - ** u/SlowMovingTarget [[https://www.reddit.com/r/emacs/comments/t3_1fzmgwb/comment/t1_lr35bm5][🔗]] -*Votes* 36 +*Votes* 39 Nothing revolutionary (and veterans will already know this), but a nice little function for splitting out text to a separate file: @@ -17,8 +10,15 @@ It's in the manual, and a basic little feature, but really handy. https://www.gn I guess the other tip is to read the manual. :) +** u/TheDrownedKraken [[https://www.reddit.com/r/emacs/comments/t3_o68i0v/comment/t1_h2rdkkz][🔗]] +*Votes* 37 + +Do you think it might be good to make this a little less frequently refreshed? There are usually some great tips that get lost to Reddit’s ephemerality pretty quickly. + +I think monthly would be better, given the modest size of this subreddit. + ** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_10qo7vb/comment/t1_j6rmvvf][🔗]] -*Votes* 32 +*Votes* 31 When you have an active region, ~undo~ will only undo changes in that region instead of the whole file. @@ -99,7 +99,7 @@ I just learned that in eshell, $$ is replaced with the output from the last comm ** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imi3kzz][🔗]] *Votes* 20 -Update from a couple of weeks ago: after some grinding, I've set the parsing of past comments from this thread to auto update on a weekly basis here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md) +Update from a couple of weeks ago: after some grinding, I've set the parsing of past comments from this thread to auto update on a weekly basis here: [[https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md][https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md]] I've also fixed the broken highlighting of some code snippets, and hopefully parsed all past threads. There's 200+ comments there (sorted by upvotes), so ctrl-f ing e.g. \~magit\~ may help you if you're looking for something specific @@ -142,14 +142,33 @@ In flyspell, I was annoyed I had to use mouse-2 when I wanted to correct a word, But the fact you can attach keymaps to overlays just seems so useful, will definitely use in the future. -** u/AndreaSomePostfix [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh][🔗]] +** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57][🔗]] *Votes* 19 -org-mode is amazing! +~use-package~ has an inbuilt feature that roughly reports the loading times of each package on startup ([[https://github.com/jschaf/esup][~esup~]] most likely does a better job, if you can get it to run; there are [[https://github.com/alexmurray/emacs-snap/issues/71][known issues]] on Emacs snap): -I discovered \~org-copy-visible\~ the other day, when I wanted to send somebody only the outline of my notes. +1. put ~(setq use-package-compute-statistics t)~ at the beginning of your ~init.el~ +2. restart Emacs +3. do ~M-x use-package-report~ -That function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful! +Which package is your biggest time sink and why is it worth it? Mine is [[https://github.com/vedang/pdf-tools][~pdf-tools~]], but to my knowledge there is simply no better alternative for working with pdfs in emacs. + +** u/vkazanov [[https://www.reddit.com/r/emacs/comments/t3_1bdm6mc/comment/t1_kuo1f9y][🔗]] +*Votes* 18 + +A dump of my Emacs-related principles after 18 years of tinkering: + +1. Don't try to replicate a static IDE setup, Emacs is fluid. +2. Emacs Lisp is inevitable for Emacser to make this fluidity possible. +3. Language-agnostic is better than language-specific. +4. Embrace display-alist, fast window manipulation, winner-mode. +5. .emacs.el reset every couple of years to accomodate innovation. +6. Org-mode/org-roam for all documentation, projects, tips. The agenda is not set in stone. Use queries, filters, tweak, evolve things. +7. A contextual dwim is always better than many keybindings. +8. Use completion everywhere on everything (vertico is magic). +9. Contribute to the core and favourite packages. + +I am a beginner though, things might change. ** u/WorldsEndless [[https://www.reddit.com/r/emacs/comments/t3_12rlq4a/comment/t1_jgwlxuw][🔗]] *Votes* 18 @@ -163,27 +182,19 @@ I'm a big user of ~ffap~. I use this function with ~M-x~ each time I want to ope But this week I discovered ~ffap-bindings~. This function replaces some key bindings to use ~ffap~ when it makes sense. For example, it replaces ~find-file~ with ~find-file-at-point~, so the usual keybindings are enriched at no cost. -** u/github-alphapapa [[https://www.reddit.com/r/emacs/comments/t3_p6mwx2/comment/t1_h9e6uqq][🔗]] +** u/AndreaSomePostfix [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh][🔗]] *Votes* 18 -Here's a popular Emacs config I just rediscovered. Some cool stuff here. https://github.com/angrybacon/dotemacs +org-mode is amazing! -** u/vkazanov [[https://www.reddit.com/r/emacs/comments/t3_1bdm6mc/comment/t1_kuo1f9y][🔗]] -*Votes* 17 +I discovered \~org-copy-visible\~ the other day, when I wanted to send somebody only the outline of my notes. -A dump of my Emacs-related principles after 18 years of tinkering: +That function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful! -1. Don't try to replicate a static IDE setup, Emacs is fluid. -2. Emacs Lisp is inevitable for Emacser to make this fluidity possible. -3. Language-agnostic is better than language-specific. -4. Embrace display-alist, fast window manipulation, winner-mode. -5. .emacs.el reset every couple of years to accomodate innovation. -6. Org-mode/org-roam for all documentation, projects, tips. The agenda is not set in stone. Use queries, filters, tweak, evolve things. -7. A contextual dwim is always better than many keybindings. -8. Use completion everywhere on everything (vertico is magic). -9. Contribute to the core and favourite packages. +** u/github-alphapapa [[https://www.reddit.com/r/emacs/comments/t3_p6mwx2/comment/t1_h9e6uqq][🔗]] +*Votes* 18 -I am a beginner though, things might change. +Here's a popular Emacs config I just rediscovered. Some cool stuff here. https://github.com/angrybacon/dotemacs ** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_vnals8/comment/t1_ie7p6ja][🔗]] *Votes* 17 @@ -205,7 +216,7 @@ Easy peasy! ** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_v2by7z/comment/t1_iauyzbl][🔗]] *Votes* 17 -It's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [post about it](https://blog.markhepburn.com/posts/understanding-use-package-optimisations/). There's a few posts around suggesting features of ~use-package~ to optimise startup, but none of them really explained how they tied back to ~autoload~, ~eval-after-load~, etc so I was trying to encourage people to dig out ~macroexpand~ and find out. +It's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [[https://blog.markhepburn.com/posts/understanding-use-package-optimisations/][post about it]]. There's a few posts around suggesting features of ~use-package~ to optimise startup, but none of them really explained how they tied back to ~autoload~, ~eval-after-load~, etc so I was trying to encourage people to dig out ~macroexpand~ and find out. ** u/AffectionateAd8985 [[https://www.reddit.com/r/emacs/comments/t3_sd10q9/comment/t1_hu9xfed][🔗]] *Votes* 17 @@ -261,17 +272,6 @@ I have two org mode link tips: (add-hook 'org-mode-hook #'echo-area-tooltips) #+END_SRC -** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57][🔗]] -*Votes* 17 - -~use-package~ has an inbuilt feature that roughly reports the loading times of each package on startup ([~esup~](https://github.com/jschaf/esup) most likely does a better job, if you can get it to run; there are [known issues](https://github.com/alexmurray/emacs-snap/issues/71) on Emacs snap): - -1. put ~(setq use-package-compute-statistics t)~ at the beginning of your ~init.el~ -2. restart Emacs -3. do ~M-x use-package-report~ - -Which package is your biggest time sink and why is it worth it? Mine is [~pdf-tools~](https://github.com/vedang/pdf-tools), but to my knowledge there is simply no better alternative for working with pdfs in emacs. - ** u/WorldsEndless [[https://www.reddit.com/r/emacs/comments/t3_1758wua/comment/t1_k4g09iw][🔗]] *Votes* 16 @@ -316,12 +316,12 @@ Combined, this allows to extend the day past midnight, with things like agenda v *Votes* 16 I just found out that Magit can backup changes of uncommitted files automatically. Here's the link to online manual: -[Magit Wip Modes](https://magit.vc/manual/magit/Wip-Modes.html#Wip-Modes). +[[https://magit.vc/manual/magit/Wip-Modes.html#Wip-Modes][Magit Wip Modes]]. ** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_mujxm7/comment/t1_gv8jxz5][🔗]] *Votes* 16 -I use, and love, [transient](https://github.com/magit/transient). I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to ~s-w~. I use [buffer-move](https://github.com/lukhas/buffer-move) for rearranging windows in a frame. +I use, and love, [[https://github.com/magit/transient][transient]]. I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to ~s-w~. I use [[https://github.com/lukhas/buffer-move][buffer-move]] for rearranging windows in a frame. #+BEGIN_SRC elisp (define-transient-command transient-window () @@ -458,56 +458,18 @@ From ~consult-grep~ documentation, command line options can be passed to grep, s #+END_SRC I have just discovered this, and it made my day. -** u/leothrix [[https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z][🔗]] -*Votes* 14 - -For ~use-package~ users (which I assume is many of us), did you know that profiling is easy to do? I'm not talking about ~esup~, but a built-in capability that makes it very straightforward to find places to optimize your ~init.el~ for significantly faster start times. - -Enable ~use-package-compute-statistics~ right after you load ~use-package~: - -#+BEGIN_SRC elisp -(setq use-package-compute-statistics t) - -#+END_SRC -Restart emacs, and then invoke ~use-package-report~. You'll get a table of the load times for each package that ~use-package~ manages. I discovered this and found an immediate way to cut my startup time in half by fixing a few packages that weren't deferred properly by adding the right ~:hook~ keyword. - -** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_11lqkbo/comment/t1_jbe06qv][🔗]] +** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc][🔗]] *Votes* 14 -You can toggle vertico's height between 15 and "almost full frame" with this. When vertico is invoked, it will always have a height of 15. But if you have a lot of matches, and like to have a better overview, press the binding, and vertico will show a full frame of matches. This is useful for example when ~consult-buffer~ presents a lot of buffers. - -#+BEGIN_SRC elisp -(advice-add 'vertico--setup :before (lambda () (setq vertico-count 15))) -(define-key minibuffer-local-map (kbd "s-'") (lambda () - (interactive) - (let ((vertico-resize t)) - (setq vertico-count (if (= vertico-count 15) (- (frame-height) 5) 15)) - (vertico--exhibit)))) +Plain old ~query-replace~ has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain ~y~/~n~: -#+END_SRC -Another useful feature is to kill buffers in ~consult-buffer~ without manually invoking ~embark-act~. I miss this feature from Helm, where you can do actions using only one binding (no need to press an intermediate binding which invokes ~embark-act~). Note, I just blindly copied some of the logic from ~embark~, maybe there are some unnecessary things here. +~!~: replaces all remaning matches -#+BEGIN_SRC elisp -(defun my-embark-M-k (&optional arg) - (interactive "P") - (require 'embark) - (if-let ((targets (embark--targets))) - (let* ((target - (or (nth - (if (or (null arg) (minibufferp)) - 0 - (mod (prefix-numeric-value arg) (length targets))) - targets))) - (type (plist-get target :type))) - (cond - ((eq type 'buffer) - (let ((embark-pre-action-hooks)) - (embark--act 'kill-buffer target))))))) +~u~: undo last replacement -(define-key minibuffer-local-map (kbd "M-k") 'my-embark-M-k) +~E~: changes replacement string on the fly -#+END_SRC -I'm not sure whether these two can be achieved out-of-the box, but I didn't find these functionalities, so I created them. +And many more you can see using ~?~. ** u/com4 [[https://www.reddit.com/r/emacs/comments/t3_xq6rpa/comment/t1_iqb2fci][🔗]] *Votes* 14 @@ -542,7 +504,7 @@ For example, here is a simple setup for Python which includes Pyright's type che ~(python-mode "pyright-langserver" "-w" "--stdio"))) #+END_SRC -Now all that's left is mypy. Flymake originally used a ["Proc"](https://www.gnu.org/software/emacs/manual/html_mono/flymake.html#The-legacy-Proc-backend) method for creating checkers which existing mypy ones use. So for a bonus tip & trick [I've written a mypy checker in the new style](http://github.com/com4/flymake-mypy). It can be enabled when using eglot like this: +Now all that's left is mypy. Flymake originally used a [[https://www.gnu.org/software/emacs/manual/html_mono/flymake.html#The-legacy-Proc-backend]["Proc"]] method for creating checkers which existing mypy ones use. So for a bonus tip & trick [[http://github.com/com4/flymake-mypy][I've written a mypy checker in the new style]]. It can be enabled when using eglot like this: #+BEGIN_SRC elisp (use-package flymake-mypy @@ -598,7 +560,7 @@ From: http://pragmaticemacs.com/emacs/scrolling-and-moving-by-line/ ** u/Tatrics [[https://www.reddit.com/r/emacs/comments/t3_n9q662/comment/t1_gxpeh9v][🔗]] *Votes* 14 -I'm slowly working on an alternative shell: [https://github.com/TatriX/tshell](https://github.com/TatriX/tshell) +I'm slowly working on an alternative shell: [[https://github.com/TatriX/tshell][https://github.com/TatriX/tshell]] Instead of using repl-like interface, all the commands go to one buffer (and file if you want) and output goes to another buffer. Like if you put your elisp code in \*scratch\* buffer and then evaluate it with \~C-x C-e\~. @@ -609,16 +571,16 @@ Let me know what is your first impression, what can be improved and what do you ** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_mg98ki/comment/t1_gstteeo][🔗]] *Votes* 14 -I just discovered the [selected](https://github.com/Kungsgeten/selected.el) package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode. +I just discovered the [[https://github.com/Kungsgeten/selected.el][selected]] package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode. ** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1fozctm/comment/t1_lpbqo0e][🔗]] *Votes* 13 -I recently got tired of constantly having to move my eyes to the bottom of Emacs, so I switched to posframes, [which moves the information in a central pop-up instead](https://blog.costan.ro/img/emacs-completion-system/switch-to.png). For me, this meant using the packages: +I recently got tired of constantly having to move my eyes to the bottom of Emacs, so I switched to posframes, [[https://blog.costan.ro/img/emacs-completion-system/switch-to.png][which moves the information in a central pop-up instead]]. For me, this meant using the packages: -\* [~vertico-posframe~](https://github.com/tumashu/vertico-posframe) - for [~vertico~](https://github.com/minad/vertico) -\* [~which-key-posframe~](https://github.com/yanghaoxie/which-key-posframe) - for [~which-key~](https://github.com/justbur/emacs-which-key) -\* [~transient-posframe~](https://github.com/yanghaoxie/transient-posframe) - for all transient commands, e.g., in [~magit~](https://github.com/magit/magit) or in [~casual-suite~](https://github.com/kickingvegas/casual-suite) +\* [[https://github.com/tumashu/vertico-posframe][~vertico-posframe~]] - for [[https://github.com/minad/vertico][~vertico~]] +\* [[https://github.com/yanghaoxie/which-key-posframe][~which-key-posframe~]] - for [[https://github.com/justbur/emacs-which-key][~which-key~]] +\* [[https://github.com/yanghaoxie/transient-posframe][~transient-posframe~]] - for all transient commands, e.g., in [[https://github.com/magit/magit][~magit~]] or in [[https://github.com/kickingvegas/casual-suite][~casual-suite~]] But regardless what you are using, chances are there already is a suitable ~*-posframe~ package for it. Installing these packages is easy: @@ -634,23 +596,56 @@ But regardless what you are using, chances are there already is a suitable ~*-po (transient-posframe-mode)) #+END_SRC -** u/ayy_ess [[https://www.reddit.com/r/emacs/comments/t3_18hc301/comment/t1_kdobd72][🔗]] +** u/leothrix [[https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z][🔗]] *Votes* 13 -I recently discovered ~(setq read-minibuffer-restore-windows nil)~ which resolves my frustration that quitting the minibuffer would discard any changes to the window layout while the minibuffer was open. For example, by default, ~M-x C-h k k C-g~ quits the just opened help buffer. I'm sure to have missed many more QOL improvements from NEWS. +For ~use-package~ users (which I assume is many of us), did you know that profiling is easy to do? I'm not talking about ~esup~, but a built-in capability that makes it very straightforward to find places to optimize your ~init.el~ for significantly faster start times. -** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc][🔗]] +Enable ~use-package-compute-statistics~ right after you load ~use-package~: + +#+BEGIN_SRC elisp +(setq use-package-compute-statistics t) + +#+END_SRC +Restart emacs, and then invoke ~use-package-report~. You'll get a table of the load times for each package that ~use-package~ manages. I discovered this and found an immediate way to cut my startup time in half by fixing a few packages that weren't deferred properly by adding the right ~:hook~ keyword. + +** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_11lqkbo/comment/t1_jbe06qv][🔗]] *Votes* 13 -Plain old ~query-replace~ has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain ~y~/~n~: +You can toggle vertico's height between 15 and "almost full frame" with this. When vertico is invoked, it will always have a height of 15. But if you have a lot of matches, and like to have a better overview, press the binding, and vertico will show a full frame of matches. This is useful for example when ~consult-buffer~ presents a lot of buffers. -~!~: replaces all remaning matches +#+BEGIN_SRC elisp +(advice-add 'vertico--setup :before (lambda () (setq vertico-count 15))) +(define-key minibuffer-local-map (kbd "s-'") (lambda () + (interactive) + (let ((vertico-resize t)) + (setq vertico-count (if (= vertico-count 15) (- (frame-height) 5) 15)) + (vertico--exhibit)))) -~u~: undo last replacement +#+END_SRC +Another useful feature is to kill buffers in ~consult-buffer~ without manually invoking ~embark-act~. I miss this feature from Helm, where you can do actions using only one binding (no need to press an intermediate binding which invokes ~embark-act~). Note, I just blindly copied some of the logic from ~embark~, maybe there are some unnecessary things here. -~E~: changes replacement string on the fly +#+BEGIN_SRC elisp +(defun my-embark-M-k (&optional arg) + (interactive "P") + (require 'embark) + (if-let ((targets (embark--targets))) + (let* ((target + (or (nth + (if (or (null arg) (minibufferp)) + 0 + (mod (prefix-numeric-value arg) (length targets))) + targets))) + (type (plist-get target :type))) + (cond + ((eq type 'buffer) + (let ((embark-pre-action-hooks)) + (embark--act 'kill-buffer target))))))) -And many more you can see using ~?~. +(define-key minibuffer-local-map (kbd "M-k") 'my-embark-M-k) + +#+END_SRC +I'm not sure whether these two can be achieved out-of-the box, but I didn't find these functionalities, so I created them. ** u/gusbrs [[https://www.reddit.com/r/emacs/comments/t3_y1y0kq/comment/t1_is1ygyw][🔗]] *Votes* 13 @@ -1056,6 +1051,11 @@ Here is how I bind it in ~bibtex-mode~ (plus my other bindings for good measure) Shells in emacs like ~shell-mode~ and ~eshell~ can write multi line input using ~comint-accumulate~. Normally bound to ~C-c SPC~. +** u/Usual_Office_1740 [[https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9][🔗]] +*Votes* 12 + +I've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again. + ** u/remillard [[https://www.reddit.com/r/emacs/comments/t3_1cbsvxd/comment/t1_l11l7he][🔗]] *Votes* 12 @@ -1067,19 +1067,31 @@ I suspect completion is doing a lot of heavy lifting here though too, so a perfe Anyway, I haven't popped open the Treemacs sidebar in weeks now, and just felt like I should write something in case someone was curious about how handy it was. -** u/algor512 [[https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d][🔗]] +** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1][🔗]] *Votes* 12 -Recently I discovered that ~C-h C-q~ (or ~M-x help-quick~) opens a small window showing \*Quick Help\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable ~help-quick-sections~. +If you use an LSP server with semantic highlighting, it's worth checking out the value of ~font-lock-maximum-decoration~. For example, I use ~c++-mode~ with ~lsp-mode~ (with clangd), I decreased ~font-lock-maximum-decoration~ to ~2~, and I didn't notice any highlighting difference (because the lost highlighting by ~c++-mode~ gets highlighted by ~lsp-mode~), while ~c++-mode~ font-locking become faster (~c++-mode~ 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone). -I intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of ~help-quick-sections~. +I use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~ + +** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6][🔗]] +*Votes* 12 + +I have long had convenience bindings for ~org-emphasize~ like ~super-i~ for /italic/, that match system bindings. But I always wanted these to *be smarter*, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not. + +[[https://gist.github.com/jdtsmith/55e6a660dd4c0779a600ac81bf9bfc23][Check out my solution]] (scroll down to see how it acts). Will miss this behavior in other apps! + +** u/ayy_ess [[https://www.reddit.com/r/emacs/comments/t3_18hc301/comment/t1_kdobd72][🔗]] +*Votes* 12 + +I recently discovered ~(setq read-minibuffer-restore-windows nil)~ which resolves my frustration that quitting the minibuffer would discard any changes to the window layout while the minibuffer was open. For example, by default, ~M-x C-h k k C-g~ quits the just opened help buffer. I'm sure to have missed many more QOL improvements from NEWS. ** u/eleven_cupfuls [[https://www.reddit.com/r/emacs/comments/t3_10ktqj0/comment/t1_j5umed8][🔗]] *Votes* 12 I jump into the built-in Elisp files a lot to see how things work. The indentation there is GNU standard, which uses a mix of tabs and spaces for alignment. The tabs have to be rendered as 8 spaces wide for the alignment to work, and I don't actually want that setting anywhere else. Since the files on Mac are inside the application bundle, I don't want to just add a .dir-locals.el file next to them, either. -[Directory classes](https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html) to the rescue! My config makes a new directory variable class, ~builtin-elisp~, with a list saying that ~emacs-lisp-mode~ should use a ~tab-width~ of 8. Then it applies that class to the Elisp files in the application bundle: +[[https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html][Directory classes]] to the rescue! My config makes a new directory variable class, ~builtin-elisp~, with a list saying that ~emacs-lisp-mode~ should use a ~tab-width~ of 8. Then it applies that class to the Elisp files in the application bundle: #+BEGIN_SRC elisp (use-package elisp-mode @@ -1225,6 +1237,32 @@ I made my agenda collapsible (like org headings) by using outline-minor-mode. To (add-hook 'org-agenda-mode-hook 'my/org-agenda-fold) #+END_SRC +** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6][🔗]] +*Votes* 11 + +I regularly work with different emacs frames on different monitors, and [[https://github.com/emacsmirror/framemove][~framemove~]] is great for switching between them. It can hook into ~windmove~ (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions: + +\* ~fm-up-frame~: move to the frame over the current frame +\* ~fm-down-frame~: move to the frame below the current frame +\* ~fm-left-frame~: move to the frame left of the current frame +\* ~fm-right-frame~: move to the frame right of the current frame + +It's not on any of the major package repositories, so you have to install it manually. Thanks to [[https://github.com/emacsmirror][~emacsmirror~]], this can for example be done as follows using ~use-package~ and ~straight~ (adjust bindings to your liking): + +#+BEGIN_SRC elisp + (use-package framemove + :straight (:host github :repo "emacsmirror/framemove") + :init + (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom + :bind + (("C-x 5 " . fm-up-frame) + ("C-x 5 " . fm-down-frame) + ("C-x 5 " . fm-left-frame) + ("C-x 5 " . fm-right-frame))) + +#+END_SRC +edit: The only thing I don't understand is why setting ~framemove-hook-into-windmove~ to ~t~ doesn't work in via ~:config~ or ~:custom~. The package is loaded, ~C-h f~ confirms that ~fm-up-frame~ exists, but ~C-h v~ doesn't know ~framemove-hook-into-windmove~. ~framemove-hook-into-windmove~ exists after I run ~fm-up-frame~, but then it's set to ~nil~ and not ~t~. + ** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_1djdync/comment/t1_l9cmdp9][🔗]] *Votes* 11 @@ -1242,88 +1280,46 @@ A minor annoyance was that an unwanted link to whatever file location I happened '(("d" "Done" entry (file+olp+datetree "~/org/done.org") "* %?"))) #+END_SRC -** u/saltwaterflyguy [[https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8][🔗]] +** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q][🔗]] *Votes* 11 -describe-\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v. +Not from me, but I just wanted to share /u/arthurno1 one-line tip to get ~which-key~ to work with ~dired~ (see screenshot in linked post): -If you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions. +https://www.reddit.com/r/emacs/comments/1clvkfe/announcing_casual_dired_an_opinionated_porcelain/l2yi5tn/ -** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1][🔗]] +I assume the same trick applies to other mode-maps as well. + +** u/algor512 [[https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d][🔗]] *Votes* 11 -If you use an LSP server with semantic highlighting, it's worth checking out the value of ~font-lock-maximum-decoration~. For example, I use ~c++-mode~ with ~lsp-mode~ (with clangd), I decreased ~font-lock-maximum-decoration~ to ~2~, and I didn't notice any highlighting difference (because the lost highlighting by ~c++-mode~ gets highlighted by ~lsp-mode~), while ~c++-mode~ font-locking become faster (~c++-mode~ 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone). +Recently I discovered that ~C-h C-q~ (or ~M-x help-quick~) opens a small window showing \*Quick Help\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable ~help-quick-sections~. -I use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~ +I intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of ~help-quick-sections~. -** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6][🔗]] +** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_w3gx6o/comment/t1_ih6ievs][🔗]] *Votes* 11 -I have long had convenience bindings for ~org-emphasize~ like ~super-i~ for /italic/, that match system bindings. But I always wanted these to *be smarter*, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not. +Emacs has better long-lines support now?? -[Check out my solution](https://gist.github.com/jdtsmith/55e6a660dd4c0779a600ac81bf9bfc23) (scroll down to see how it acts). Will miss this behavior in other apps! +I just noticed while looking at the latest additions in the NEWS: -** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_15sjm3k/comment/t1_jwff8bw][🔗]] +>\*\* Emacs is now capable of editing files with arbitrarily long lines. The display of long lines has been optimized, and Emacs no longer chokes when a buffer on display contains long lines. If you still experience slowdowns while editing files with long lines, this is either due to font locking, which you can turn off with M-x font-lock-mode or C-u C-x x f, or to the current major mode or one of the enabled minor modes, in which case you should open the the file with M-x find-file-literally instead of C-x C-f. The variable 'long-line-threshold' controls whether and when these display optimizations are used. + +That sounds like great news! Does anyone know what went into it? + +(edit to add: this was added some time this week. I rebuild from master weekly, and check out the NEWS diff each time) + +** u/yogsototh [[https://www.reddit.com/r/emacs/comments/t3_qgrpte/comment/t1_hi8crmc][🔗]] *Votes* 11 -I've been slowly accumulating cases for "flexing" the thing at point as a more general ~capitalize-word~ replacement: - -#+BEGIN_SRC elisp -;; Stolen from the wiki somewhere -(defun increment-number-at-point () - "Increment the number at point." - (interactive) - (skip-chars-backward "0-9") - (or (looking-at "[0-9]+") - (error "No number at point")) - (replace-match (number-to-string (1+ (string-to-number (match-string 0)))))) - -(defun lw-flex () - "Perform smart flexing at point. - -E.g. capitalize or decapitalize the next word, increment number at point." - (interactive) - (let ((case-fold-search nil)) - (call-interactively - (cond ((looking-at "[0-9]+") #'increment-number-at-point) - ((looking-at "[[:lower:]]") #'capitalize-word) - ((looking-at "==") (delete-char 1) (insert "!") (forward-char 2)) - ((looking-at "!=") (delete-char 1) (insert "=") (forward-char 2)) - ((looking-at "+") (delete-char 1) (insert "-") (forward-char 1)) - ((looking-at "-") (delete-char 1) (insert "+") (forward-char 1)) - ((looking-at "<=") (delete-char 2) (insert ">=") (forward-char 2)) - ((looking-at ">=") (delete-char 2) (insert "<=") (forward-char 2)) - ((looking-at "<") (delete-char 1) (insert ">") (forward-char 1)) - ((looking-at ">") (delete-char 1) (insert "<") (forward-char 1)) - (t #'downcase-word))))) - -#+END_SRC -I bind it to ~M-c~. - -** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_w3gx6o/comment/t1_ih6ievs][🔗]] -*Votes* 11 - -Emacs has better long-lines support now?? - -I just noticed while looking at the latest additions in the NEWS: - ->\*\* Emacs is now capable of editing files with arbitrarily long lines. The display of long lines has been optimized, and Emacs no longer chokes when a buffer on display contains long lines. If you still experience slowdowns while editing files with long lines, this is either due to font locking, which you can turn off with M-x font-lock-mode or C-u C-x x f, or to the current major mode or one of the enabled minor modes, in which case you should open the the file with M-x find-file-literally instead of C-x C-f. The variable 'long-line-threshold' controls whether and when these display optimizations are used. - -That sounds like great news! Does anyone know what went into it? - -(edit to add: this was added some time this week. I rebuild from master weekly, and check out the NEWS diff each time) - -** u/yogsototh [[https://www.reddit.com/r/emacs/comments/t3_qgrpte/comment/t1_hi8crmc][🔗]] -*Votes* 11 - -I just made this nice combination of emacs packages and personal theme to achieve the cool effect of iAWriter - -See here: https://her.esy.fun/posts/0021-ia-writer-clone-within-doom-emacs/index.html - -** u/PotentiallyAlice [[https://www.reddit.com/r/emacs/comments/t3_n9q662/comment/t1_gxx6frj][🔗]] -*Votes* 11 - -I thought it might be a fun project to make a package to expose org-capture templates as endpoints, so I can add reminders to my TODO list via any device on the network. Turns out, it was easy enough that a package would be kinda pointless: +I just made this nice combination of emacs packages and personal theme to achieve the cool effect of iAWriter + +See here: https://her.esy.fun/posts/0021-ia-writer-clone-within-doom-emacs/index.html + +** u/PotentiallyAlice [[https://www.reddit.com/r/emacs/comments/t3_n9q662/comment/t1_gxx6frj][🔗]] +*Votes* 11 + +I thought it might be a fun project to make a package to expose org-capture templates as endpoints, so I can add reminders to my TODO list via any device on the network. Turns out, it was easy enough that a package would be kinda pointless: #+BEGIN_SRC elisp (defservlet* capture/:keys/:contents text/plain () (org-capture-string contents keys)) @@ -1356,7 +1352,7 @@ You can pop this up in a separate frame using: (setq TeX-error-overview-setup 'separate-frame) #+END_SRC -Related docs are [here](https://www.gnu.org/software/auctex/manual/auctex/Error-overview.html). +Related docs are [[https://www.gnu.org/software/auctex/manual/auctex/Error-overview.html][here]]. This totally changes the way you can handle errors messages. @@ -1365,7 +1361,7 @@ This totally changes the way you can handle errors messages. # 27.1 do GC if no frame has focus -I am porting my [config](https://github.com/laurynas-biveinis/dotfiles) from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [MatthewZMD's config](https://github.com/MatthewZMD/.emacs.d) I think: +I am porting my [[https://github.com/laurynas-biveinis/dotfiles][config]] from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [[https://github.com/MatthewZMD/.emacs.d][MatthewZMD's config]] I think: #+BEGIN_SRC elispelisp (add-hook 'focus-out-hook #'garbage-collect) #+END_SRC @@ -1394,42 +1390,62 @@ Edited to add: Sorry folks, this doesn't work like I thought it did. See the c I can't say how often I use ~dabbrev-expand~ (~M-/~) to complete words. Saves me a ton of time. -** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6][🔗]] +** u/ilemming [[https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1][🔗]] *Votes* 10 -I regularly work with different emacs frames on different monitors, and [~framemove~](https://github.com/emacsmirror/framemove) is great for switching between them. It can hook into ~windmove~ (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions: +You know that you can use vars in org source blocks that inject some data, like: -\* ~fm-up-frame~: move to the frame over the current frame -\* ~fm-down-frame~: move to the frame below the current frame -\* ~fm-left-frame~: move to the frame left of the current frame -\* ~fm-right-frame~: move to the frame right of the current frame +#+BEGIN_SRC elisp + #+begin_src bash :var token="bla-bla-bla" + echo ${token} + #+end_src + + #+RESULTS: + : bla-bla-bla -It's not on any of the major package repositories, so you have to install it manually. Thanks to [~emacsmirror~](https://github.com/emacsmirror), this can for example be done as follows using ~use-package~ and ~straight~ (adjust bindings to your liking): +#+END_SRC +That can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block. #+BEGIN_SRC elisp - (use-package framemove - :straight (:host github :repo "emacsmirror/framemove") - :init - (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom - :bind - (("C-x 5 " . fm-up-frame) - ("C-x 5 " . fm-down-frame) - ("C-x 5 " . fm-left-frame) - ("C-x 5 " . fm-right-frame))) + #+name: dirs + #+begin_src bash :results silent + ls + #+end_src + + #+begin_src js :var data=dirs + console.log(data) + #+end_src #+END_SRC -edit: The only thing I don't understand is why setting ~framemove-hook-into-windmove~ to ~t~ doesn't work in via ~:config~ or ~:custom~. The package is loaded, ~C-h f~ confirms that ~fm-up-frame~ exists, but ~C-h v~ doesn't know ~framemove-hook-into-windmove~. ~framemove-hook-into-windmove~ exists after I run ~fm-up-frame~, but then it's set to ~nil~ and not ~t~. +But did you know, you can also use elisp there? -** u/fuzzbomb23 [[https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7][🔗]] -*Votes* 10 +#+BEGIN_SRC elisp + #+begin_src js :var data=(if (featurep :system 'macos) "🍎" "🐧") + return data; + #+end_src -One of my favourite tips for managing my init file is the ~imenu~ support in ~use-package~. It's turned off by default, though: + #+RESULTS: + : 🍎 + +#+END_SRC +Or previous-like example with dirs but without needing additional source block: #+BEGIN_SRC elisp -(setq use-package-enable-imenu-support t) +#+begin_src clojure :var data=(shell-command-to-string "ls -a ~") +;; all dotfiles +(require '[clojure.string :as str]) + +(->> (str/split data #"\n") + (filter (partial re-find #"^\.*")) + (sort) + (str/join "\n")) +#+end_src #+END_SRC -Combined with a nice imenu UI (~consult-imenu~ and Vertico, say) you can navigate your init file really quickly. +** u/rego_b [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro][🔗]] +*Votes* 10 + +~C-x C-e~ to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal) ** u/winters_here [[https://www.reddit.com/r/emacs/comments/t3_1eaw1ia/comment/t1_leom8fv][🔗]] *Votes* 10 @@ -1451,19 +1467,19 @@ Useful when you include some classless css libraries which require you to add at Don't skip ~HTML_DOCTYPE~ else it will duplicate the attribute because one extra will be added due to ~xml:lang~ -** u/Usual_Office_1740 [[https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9][🔗]] +** u/thetemp_ [[https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy][🔗]] *Votes* 10 -I've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again. +I recently discovered the [[https://github.com/gonewest818/dimmer.el][Dimmer]] package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that *is* focused. And of course, you can customize how much it dims and exclude certain buffers. -** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q][🔗]] -*Votes* 10 +I love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore. -Not from me, but I just wanted to share /u/arthurno1 one-line tip to get ~which-key~ to work with ~dired~ (see screenshot in linked post): +** u/saltwaterflyguy [[https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8][🔗]] +*Votes* 10 -https://www.reddit.com/r/emacs/comments/1clvkfe/announcing_casual_dired_an_opinionated_porcelain/l2yi5tn/ +describe-\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v. -I assume the same trick applies to other mode-maps as well. +If you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions. ** u/bopboa [[https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kphrvz3][🔗]] *Votes* 10 @@ -1476,6 +1492,26 @@ This is how to have a beacon without installing any packages. (setq window-selection-change-functions '(pulse-line)) #+END_SRC +** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp][🔗]] +*Votes* 10 + +Many of you probably know of this, but I found "indirect buffers" useful. + +When I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the "folding" and "narrow" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow ~C-x n s~ into different headings of the file in different windows. + +Indirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that ~C-x 4 c C-x n s~ did what I wanted. + +** u/badmaxton [[https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp][🔗]] +*Votes* 10 + +Just added this to the ~:init~ section of my embark configuration: + +#+BEGIN_SRC elisp +(define-key minibuffer-local-map [C-tab] 'embark-select) + +#+END_SRC +This allows super-convenient marking of entries for later ~embark-all~ using control-tab, instead of having to go first through the ~embark~ menu. (By default, this key binding is mapped to ~file-cache-minibuffer-complete~, which I never use.) + ** u/camel_case_t [[https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kgce54q][🔗]] *Votes* 10 @@ -1514,26 +1550,66 @@ M-x remove-hook #+END_SRC And you've got an interactive interface (using ~completing-read~) for removing arbitrary elements from any list-like variable. It's _technically_ for altering hooks, but you can abuse it to fool around with lists, too. -** u/frosch03 [[https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a][🔗]] +** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_15sjm3k/comment/t1_jwff8bw][🔗]] *Votes* 10 -Very useful, but I keep forgetting it: +I've been slowly accumulating cases for "flexing" the thing at point as a more general ~capitalize-word~ replacement: -If you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: ~C-x -~ +#+BEGIN_SRC elisp +;; Stolen from the wiki somewhere +(defun increment-number-at-point () + "Increment the number at point." + (interactive) + (skip-chars-backward "0-9") + (or (looking-at "[0-9]+") + (error "No number at point")) + (replace-match (number-to-string (1+ (string-to-number (match-string 0)))))) + +(defun lw-flex () + "Perform smart flexing at point. + +E.g. capitalize or decapitalize the next word, increment number at point." + (interactive) + (let ((case-fold-search nil)) + (call-interactively + (cond ((looking-at "[0-9]+") #'increment-number-at-point) + ((looking-at "[[:lower:]]") #'capitalize-word) + ((looking-at "==") (delete-char 1) (insert "!") (forward-char 2)) + ((looking-at "!=") (delete-char 1) (insert "=") (forward-char 2)) + ((looking-at "+") (delete-char 1) (insert "-") (forward-char 1)) + ((looking-at "-") (delete-char 1) (insert "+") (forward-char 1)) + ((looking-at "<=") (delete-char 2) (insert ">=") (forward-char 2)) + ((looking-at ">=") (delete-char 2) (insert "<=") (forward-char 2)) + ((looking-at "<") (delete-char 1) (insert ">") (forward-char 1)) + ((looking-at ">") (delete-char 1) (insert "<") (forward-char 1)) + (t #'downcase-word))))) -And if you want to balance these two buffers again just use ~C-x +~ +#+END_SRC +I bind it to ~M-c~. -** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz][🔗]] +** u/gusbrs [[https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts][🔗]] *Votes* 10 -Put the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press) +I was converting some old ~.odt~ notes files to ~.org~ today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: ~repunctuate-sentences~. I have no idea if this is new or has always been there. It is new to me. It uses ~query-replace-regexp~, so it's the same experience. And also can be configured for exclusions with ~repunctuate-sentences-filter~. Neat! -Win - Alt - Ctrl - Space - Ctrl - Alt - Win +** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv][🔗]] +*Votes* 10 + +I work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice: + +#+BEGIN_SRC elisp +(defun default-to-main-project (dir) + (or dir *main-project-dir*)) + +(advice-add 'projectile-ensure-project :override #'default-to-main-project) + +#+END_SRC +I lose some of the functionality of ~projectile-ensure-project~, but I never used it anyway. ** u/AnugNef4 [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_ja41lso][🔗]] *Votes* 10 -How I got my Info Directory node ~C-h i~ to display all my installed .info files living under ~/opt/homebrew~ on an M1 Mac. I run emacs-plus@29 from [d12frosted on github](https://github.com/d12frosted/homebrew-emacs-plus). +How I got my Info Directory node ~C-h i~ to display all my installed .info files living under ~/opt/homebrew~ on an M1 Mac. I run emacs-plus@29 from [[https://github.com/d12frosted/homebrew-emacs-plus][d12frosted on github]]. init.el snippet @@ -1577,7 +1653,7 @@ I started using ~god-mode~, but I found it hard to get used to it at first: ther I wrote up a ~god-mode~\-specific ~describe-key~, which translates ~god-mode~ key-sequences into commands and shows their usual description. I think it's a great way to get familiar with how the package handles keys, and it allows users to invoke ~describe-key~ without leaving god-mode (previously, most keys would just show information about the generic ~god-mode-self-insert-command~) -I also reached out to the package's maintainers, and this feature (after some tweaking) [just got added to the master branch](https://github.com/emacsorphanage/god-mode). It was a great way to get familiar with ~god-mode~ code and its behavior, and I'm happy to have made my first contribution to an Emacs package. +I also reached out to the package's maintainers, and this feature (after some tweaking) [[https://github.com/emacsorphanage/god-mode][just got added to the master branch]]. It was a great way to get familiar with ~god-mode~ code and its behavior, and I'm happy to have made my first contribution to an Emacs package. ** u/kickingvegas1 [[https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_innk62a][🔗]] *Votes* 10 @@ -1765,7 +1841,7 @@ One of the most useful bindings for me: ** u/Stefan-Kangas [[https://www.reddit.com/r/emacs/comments/t3_pxqvtm/comment/t1_hf1gzs2][🔗]] *Votes* 10 -Read [SICP](https://mitpress.mit.edu/sites/default/files/sicp/index.html). Preferably in Info, installable through MELPA or: [https://github.com/webframp/sicp-info](https://github.com/webframp/sicp-info) +Read [[https://mitpress.mit.edu/sites/default/files/sicp/index.html][SICP]]. Preferably in Info, installable through MELPA or: [[https://github.com/webframp/sicp-info][https://github.com/webframp/sicp-info]] ** u/Stefan-Kangas [[https://www.reddit.com/r/emacs/comments/t3_pxqvtm/comment/t1_hexdfiq][🔗]] *Votes* 10 @@ -1961,52 +2037,58 @@ If you want to switch between two themes, depending on time of day (e.g. a light #+END_SRC This selects the correct theme when starting Emacs and automatically switch when the times come. -** u/rego_b [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro][🔗]] -*Votes* 9 - -~C-x C-e~ to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal) - -** u/thetemp_ [[https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy][🔗]] +** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gfhkdg/comment/t1_lui5ao9][🔗]] *Votes* 9 -I recently discovered the [Dimmer](https://github.com/gonewest818/dimmer.el) package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that *is* focused. And of course, you can customize how much it dims and exclude certain buffers. +I've recently discovered [[https://github.com/fuxialexander/org-pdftools][~org-pdftools~]] and it offers everything I need for annotating pdfs in emacs. I mainly use it to enhance the inbuilt function ~org-store-link~: -I love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore. +\* mark a passage in the pdf, run ~M-x org-store-link~, and it creates a highlight in the pdf (technically an empty annotation) and copies a link to it. +\* run ~C-c C-l~ in any org-buffer, and it pastes the link and prompts you for a name. -** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3][🔗]] -*Votes* 9 +The installation is easy, you just need to hook it into ~org-mode~: -A few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [this gist](https://gist.github.com/jdtsmith/a169362879388bc1bdf2bbb977782d4f) for the details. +#+BEGIN_SRC elisp + (use-package org-pdftools + :after (org pdf-tools) + :hook (org-mode . org-pdftools-setup-link)) -** u/demosthenex [[https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6][🔗]] -*Votes* 9 +#+END_SRC +The only thing to keep in mind is that the highlights in the pdf are not automatically deleted, as you delete the link in the org buffer. You have to do that manually in the pdf (~C-c C-a l~ to list all highlights, ~D~ to delete). -M-x ielm Use the repl while learning elisp coding. I had no idea! +It has less features than [[https://github.com/org-noter/org-noter][~org-noter~]], but it is more flexible, which is why it suits my use-case better. Unfortunately, it has ~org-noter~ as a dependency, so you will end up loading it either way. -** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp][🔗]] +** u/fuzzbomb23 [[https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7][🔗]] *Votes* 9 -Many of you probably know of this, but I found "indirect buffers" useful. +One of my favourite tips for managing my init file is the ~imenu~ support in ~use-package~. It's turned off by default, though: -When I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the "folding" and "narrow" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow ~C-x n s~ into different headings of the file in different windows. +#+BEGIN_SRC elisp +(setq use-package-enable-imenu-support t) +#+END_SRC -Indirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that ~C-x 4 c C-x n s~ did what I wanted. +Combined with a nice imenu UI (~consult-imenu~ and Vertico, say) you can navigate your init file really quickly. -** u/badmaxton [[https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp][🔗]] +** u/pt-guzzardo [[https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx][🔗]] *Votes* 9 -Just added this to the ~:init~ section of my embark configuration: - #+BEGIN_SRC elisp -(define-key minibuffer-local-map [C-tab] 'embark-select) +(defun copy-source-for-reddit () + (interactive) + (let ((contents (buffer-substring (point) (mark)))) + (with-temp-buffer + (insert contents) + (mark-whole-buffer) + (indent-rigidly (point) (mark) 4 t) + (mark-whole-buffer) + (kill-ring-save 0 0 t)))) #+END_SRC -This allows super-convenient marking of entries for later ~embark-all~ using control-tab, instead of having to go first through the ~embark~ menu. (By default, this key binding is mapped to ~file-cache-minibuffer-complete~, which I never use.) +A handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer. ** u/lesliesrussell [[https://www.reddit.com/r/emacs/comments/t3_198rnkj/comment/t1_kibmgv2][🔗]] *Votes* 9 -[transient map for movement](https://gist.github.com/lesliesrussell/46302d413fcf49e9717eeea57fdadcbf) +[[https://gist.github.com/lesliesrussell/46302d413fcf49e9717eeea57fdadcbf][transient map for movement]] Defines a transient keymap for movement controls and sets up a global key binding to activate this transient map. This transient map, \~my-movement-transient-map\~, includes bindings for various movement commands like moving forward or backward by a word or character and moving to the next or previous line. The \~activate-my-movement-map\~ function is defined to activate this transient map, and it is globally bound to \~C-f\~. @@ -2020,20 +2102,10 @@ This is a neat way to create a custom, modal-like interface for movement within I didn't want to drop code in the thread so i put it in a gist -** u/Netherus [[https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7][🔗]] +** u/BunnyLushington [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhrzybp][🔗]] *Votes* 9 -Just recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me. - -** u/gusbrs [[https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts][🔗]] -*Votes* 9 - -I was converting some old ~.odt~ notes files to ~.org~ today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: ~repunctuate-sentences~. I have no idea if this is new or has always been there. It is new to me. It uses ~query-replace-regexp~, so it's the same experience. And also can be configured for exclusions with ~repunctuate-sentences-filter~. Neat! - -** u/BunnyLushington [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhrzybp][🔗]] -*Votes* 9 - -I found myself debugging [JWTs](https://jwt.io) earlier this week and whomped up a little function to decode them from a region into a help buffer. +I found myself debugging [[https://jwt.io][JWTs]] earlier this week and whomped up a little function to decode them from a region into a help buffer. #+BEGIN_SRC elisp (defun ii/decode-jwt (start end &optional jwt) @@ -2058,44 +2130,12 @@ I'd forgotten about ~with-output-to-temp-buffer~ which is pretty handy. The ~t~ (This should be obvious but note that the JWT is not validated or verified. This is intended for debugging only and the JWT should not be trusted.) -** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv][🔗]] -*Votes* 9 - -I work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice: - -#+BEGIN_SRC elisp -(defun default-to-main-project (dir) - (or dir *main-project-dir*)) - -(advice-add 'projectile-ensure-project :override #'default-to-main-project) - -#+END_SRC -I lose some of the functionality of ~projectile-ensure-project~, but I never used it anyway. - -** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jca66k0][🔗]] +** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz][🔗]] *Votes* 9 -I'm once again reminded of the utility of ~read-key~ for small functions where one wants a nicer interface for choosing an alternative than universal arguments; taking an optional prompt, it simply reads a key from the keyboard and returns it. - -For example, I recently wanted a function that prints a set of predefined dates for me into the current buffer, and it was as easy as +Put the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press) -#+BEGIN_SRC elisp -(defun slot/insert-time () - (interactive) - (let* ((formats '((?i "ISO 8601" "%Y-%m-%d") - (?l "DDmmmYYYY" "%d%b%Y") - (?t "Time" "%H:%M"))) - (key (read-key - (cl-loop for (key label _) in formats - concat (format "[%s] %s " - (propertize (single-key-description key) 'face 'bold) - label))))) - (->> (alist-get key formats) - cl-second - format-time-string - downcase ; Jan -> jan - insert))) -#+END_SRC +Win - Alt - Ctrl - Space - Ctrl - Alt - Win ** u/pathemata [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mpo5y][🔗]] *Votes* 9 @@ -2104,53 +2144,6 @@ Does anyone have an ~aspell~ setup with multiple dictionaries? When I try ~--extra-dict~ option I get an error: ~Expected language "en" but got "de"~. -** u/SlowValue [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8u1ebf][🔗]] -*Votes* 9 - -I put a couple of similar functions on my ~~ key (with all combinations of modifier keys) and tend to forget the meanings of those combinations. - -So I made a small function to give some help for a list of keybindings.: - -#+BEGIN_SRC elisp -(defun my-generate-keybind-doc-on-keys (&rest keys) - "generate help on some given keybindings (kbd style)." - (substring - (apply #'concat - (mapcar #'(lambda (key) - (let* ((fun (key-binding (kbd key))) - (fun-name (symbol-name fun)) - (doc (documentation fun 'raw)) - (oneline (substring doc 0 (string-match "\n" doc)))) - (put-text-property 0 (length key) 'face 'font-lock-keyword-face key) - (put-text-property 0 (length fun-name) 'face 'font-lock-function-name-face fun-name) - (put-text-property 0 (length oneline) 'face 'font-lock-doc-face oneline) - (format "%10s : %-30s → %s\n" key fun-name oneline))) - keys)) - 0 -1)) - -#+END_SRC -To show that help in the echo buffer, one needs to define a command, which can be bound to a key: - -#+BEGIN_SRC elisp -(defun my-show-help-on-some-keys () - "demo generate help on 3 keys" - (interactive) - (message (my-generate-keybind-doc-on-keys "C-s" - " k" - "C-c !"))) - -#+END_SRC -Then calling the command ~my-show-help-on-some-keys~, shows following message in the echo buffer: - -#+BEGIN_SRC elisp - C-s : isearch-forward → Do incremental search forward. - k : helpful-key → Show help for interactive command bound to KEY-SEQUENCE. - C-c ! : shell-here → Open a shell relative to default-directory. - - -#+END_SRC -Remark: I know that ~which-key~ exists, but I'm already above that level of knowledge and don't need ~which-key~ anymore. - ** u/gusbrs [[https://www.reddit.com/r/emacs/comments/t3_ywnt6p/comment/t1_ix0a6ui][🔗]] *Votes* 9 @@ -2197,7 +2190,7 @@ Any suggestions would be appreciated! ** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_ikrx30z][🔗]] *Votes* 9 -I've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md) +I've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: [[https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md][https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md]] If you fancy procrastinating for a bit today... @@ -2305,7 +2298,7 @@ Usually I switch to ~foobar.hpp~, kill the necessary part, switch to ~foobar.cpp ** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_q76kok/comment/t1_hghp1e4][🔗]] *Votes* 9 -Checkout [Topsy Mode](https://github.com/alphapapa/topsy.el), it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup. +Checkout [[https://github.com/alphapapa/topsy.el][Topsy Mode]], it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup. ** u/oantolin [[https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8utmh2][🔗]] *Votes* 9 @@ -2419,7 +2412,7 @@ After a while I extended org-export to get a shortcut (~C-e C-s o M~) to automat ** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_ixjcau/comment/t1_g69no38][🔗]] *Votes* 9 -org-variable-pitch.el users might want to give [~valign~](https://github.com/casouri/valign) a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add ~org-link~ to ~org-variable-pitch-fixed-faces~ because valign-mode handles variable pitch links neatly in tables. +org-variable-pitch.el users might want to give [[https://github.com/casouri/valign][~valign~]] a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add ~org-link~ to ~org-variable-pitch-fixed-faces~ because valign-mode handles variable pitch links neatly in tables. If you don't use OVP but use e.g. latex fragments in tables or just pictures, this one is still very helpful. @@ -2538,7 +2531,7 @@ end tell \** u/attento_redaz [[https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_iku77h0][🔗]] \*Votes* 9 -Using [zotra](https://github.com/mpedramfar/zotra), [citar](https://github.com/emacs-citar/citar) and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with "org-biblatex bibliographies" which are basically like [org-bibtex](http://gewhere.github.io/org-bibtex) but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable ~#+bibliography: my-org-biblatex-file.org~ declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp. +Using [[https://github.com/mpedramfar/zotra][zotra]], [[https://github.com/emacs-citar/citar][citar]] and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with "org-biblatex bibliographies" which are basically like [[http://gewhere.github.io/org-bibtex][org-bibtex]] but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable ~#+bibliography: my-org-biblatex-file.org~ declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp. ** u/b3n [[https://www.reddit.com/r/emacs/comments/t3_oxo1xh/comment/t1_h85cv7f][🔗]] *Votes* 9 @@ -2578,11 +2571,11 @@ I posted this in the emacsclient thread, but I think it deserves to live here as The emacsclient / server system is great. If you have it listening on tcp and port forward that when connecting to remote machine it adds another level of power. -I use [emacs-vterm](https://github.com/akermu/emacs-libvterm) for a terminal inside emacs, so I've got a lot of commands remapped. Like ~man~ runs ~emacsclient ... man ..~, which opens the man page in the "other" buffer, so it doesn't interrupt my flow. I use "scroll-other-window" to navigate the man page while I still have my prompt. ~magit~, ~dired~, and others map to their ~emacsclient~ equivalents. +I use [[https://github.com/akermu/emacs-libvterm][emacs-vterm]] for a terminal inside emacs, so I've got a lot of commands remapped. Like ~man~ runs ~emacsclient ... man ..~, which opens the man page in the "other" buffer, so it doesn't interrupt my flow. I use "scroll-other-window" to navigate the man page while I still have my prompt. ~magit~, ~dired~, and others map to their ~emacsclient~ equivalents. I've written wrapper script for e/emacs client that I've come to call ~e~, because it saves keystrokes -#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/) +#### [[https://gitlab.com/zackallison/e-emacs/][The full repo is here e-emacs.sh]] It does the standard things you would expect, starts emacs if it's not already started, open a file in a new buffer / window / terminal and optionally wait for you to finish or have the shell continue. @@ -2594,7 +2587,7 @@ Or the poor man's blog system: ~e -t header_template.html body_template.html foo See the repo for more examples and to download. The notes of getting it working on remote machines aren't the cleanest. If you have any suggestions or features that would make your life easier let me know; submit an issue or comment here. -#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/) +#### [[https://gitlab.com/zackallison/e-emacs/][The full repo is here e-emacs.sh]] ~~I really should post this on one of the share your stuff posts. But I get distracted.~~ There, I did it. @@ -2604,7 +2597,7 @@ In case you can't tell I *really* like emacs and it's client server model. *Votes* 9 A blog post regarding my own Emacs config aiming to get the same user experience on both TUI and GUI. -[https://www.rahuljuliato.com/posts/lemacs](https://www.rahuljuliato.com/posts/lemacs) +[[https://www.rahuljuliato.com/posts/lemacs][https://www.rahuljuliato.com/posts/lemacs]] ** u/emacsomancer [[https://www.reddit.com/r/emacs/comments/t3_gqsz8u/comment/t1_fs5sq09][🔗]] *Votes* 9 @@ -2619,83 +2612,11 @@ Each person gets a different colour to indicate the part of the file they’re e https://imgur.com/a/zvfLpdH -** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gfhkdg/comment/t1_lui5ao9][🔗]] -*Votes* 8 - -I've recently discovered [~org-pdftools~](https://github.com/fuxialexander/org-pdftools) and it offers everything I need for annotating pdfs in emacs. I mainly use it to enhance the inbuilt function ~org-store-link~: - -\* mark a passage in the pdf, run ~M-x org-store-link~, and it creates a highlight in the pdf (technically an empty annotation) and copies a link to it. -\* run ~C-c C-l~ in any org-buffer, and it pastes the link and prompts you for a name. - -The installation is easy, you just need to hook it into ~org-mode~: - -#+BEGIN_SRC elisp - (use-package org-pdftools - :after (org pdf-tools) - :hook (org-mode . org-pdftools-setup-link)) - -#+END_SRC -The only thing to keep in mind is that the highlights in the pdf are not automatically deleted, as you delete the link in the org buffer. You have to do that manually in the pdf (~C-c C-a l~ to list all highlights, ~D~ to delete). - -It has less features than [~org-noter~](https://github.com/org-noter/org-noter), but it is more flexible, which is why it suits my use-case better. Unfortunately, it has ~org-noter~ as a dependency, so you will end up loading it either way. - ** u/fv__ [[https://www.reddit.com/r/emacs/comments/t3_1fzmgwb/comment/t1_lr5ceqe][🔗]] *Votes* 8 C-x in a transient popup shows menu to save selected options e.g., it can be used to select ~ --force-with-lease~ by default while pushing in magit (P p) -** u/ilemming [[https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1][🔗]] -*Votes* 8 - -You know that you can use vars in org source blocks that inject some data, like: - -#+BEGIN_SRC elisp - #+begin_src bash :var token="bla-bla-bla" - echo ${token} - #+end_src - - #+RESULTS: - : bla-bla-bla - -#+END_SRC -That can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block. - -#+BEGIN_SRC elisp - #+name: dirs - #+begin_src bash :results silent - ls - #+end_src - - #+begin_src js :var data=dirs - console.log(data) - #+end_src - -#+END_SRC -But did you know, you can also use elisp there? - -#+BEGIN_SRC elisp - #+begin_src js :var data=(if (featurep :system 'macos) "🍎" "🐧") - return data; - #+end_src - - #+RESULTS: - : 🍎 - -#+END_SRC -Or previous-like example with dirs but without needing additional source block: - -#+BEGIN_SRC elisp -#+begin_src clojure :var data=(shell-command-to-string "ls -a ~") -;; all dotfiles -(require '[clojure.string :as str]) - -(->> (str/split data #"\n") - (filter (partial re-find #"^\.*")) - (sort) - (str/join "\n")) -#+end_src -#+END_SRC - ** u/meedstrom [[https://www.reddit.com/r/emacs/comments/t3_1fe504e/comment/t1_lmzbyro][🔗]] *Votes* 8 @@ -2723,29 +2644,22 @@ Highlight regexp or strings in your buffer with =M+s h= good for analyzing logfi ** u/Motor_Mouth_ [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lg6q2rq][🔗]] *Votes* 8 -For users of [rg.el](https://github.com/dajva/rg.el) (emacs interface to ripgrep) there is [rga](https://github.com/phiresky/ripgrep-all) (ripgrep-all) a wrapper around ripgrep that "enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc." You can set the rg executable in the configuration of rg.el like so: ~(setq rg-executable (executable-find "rga")~ to enable search in multiple document types. +For users of [[https://github.com/dajva/rg.el][rg.el]] (emacs interface to ripgrep) there is [[https://github.com/phiresky/ripgrep-all][rga]] (ripgrep-all) a wrapper around ripgrep that "enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc." You can set the rg executable in the configuration of rg.el like so: ~(setq rg-executable (executable-find "rga")~ to enable search in multiple document types. + +** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3][🔗]] +*Votes* 8 + +A few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [[https://gist.github.com/jdtsmith/a169362879388bc1bdf2bbb977782d4f][this gist]] for the details. ** u/AdjointFunctor [[https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l359pqx][🔗]] *Votes* 8 I (re) discovered rectangle mode recently. Very useful when deleting lots of indents. C-x spc then make the region. https://emacsredux.com/blog/2014/01/01/a-peek-at-emacs-24-dot-4-rectangular-selection/ -** u/pt-guzzardo [[https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx][🔗]] +** u/demosthenex [[https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6][🔗]] *Votes* 8 -#+BEGIN_SRC elisp -(defun copy-source-for-reddit () - (interactive) - (let ((contents (buffer-substring (point) (mark)))) - (with-temp-buffer - (insert contents) - (mark-whole-buffer) - (indent-rigidly (point) (mark) 4 t) - (mark-whole-buffer) - (kill-ring-save 0 0 t)))) - -#+END_SRC -A handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer. +M-x ielm Use the repl while learning elisp coding. I had no idea! ** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_18mplfa/comment/t1_ke5xr5j][🔗]] *Votes* 8 @@ -2767,11 +2681,50 @@ Long story short, here's how you force ~project~ to find the actual project root ~(setq project-vc-extra-root-markers '(".project.el" ".projectile" ".dir-locals.el"))~ +** u/Netherus [[https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7][🔗]] +*Votes* 8 + +Just recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me. + ** u/AP145 [[https://www.reddit.com/r/emacs/comments/t3_16hh7u4/comment/t1_k1803gl][🔗]] *Votes* 8 I used to always get confused why people say that the default Emacs key bindings hurt their pinky's, but then I realized that I don't touch type and thus I don't have to stretch my fingers anywhere for the default key bindings. Ironically my ineptitude at typing has saved me from repetitive stress injuries. +** u/frosch03 [[https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a][🔗]] +*Votes* 8 + +Very useful, but I keep forgetting it: + +If you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: ~C-x -~ + +And if you want to balance these two buffers again just use ~C-x +~ + +** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jca66k0][🔗]] +*Votes* 8 + +I'm once again reminded of the utility of ~read-key~ for small functions where one wants a nicer interface for choosing an alternative than universal arguments; taking an optional prompt, it simply reads a key from the keyboard and returns it. + +For example, I recently wanted a function that prints a set of predefined dates for me into the current buffer, and it was as easy as + +#+BEGIN_SRC elisp +(defun slot/insert-time () + (interactive) + (let* ((formats '((?i "ISO 8601" "%Y-%m-%d") + (?l "DDmmmYYYY" "%d%b%Y") + (?t "Time" "%H:%M"))) + (key (read-key + (cl-loop for (key label _) in formats + concat (format "[%s] %s " + (propertize (single-key-description key) 'face 'bold) + label))))) + (->> (alist-get key formats) + cl-second + format-time-string + downcase ; Jan -> jan + insert))) +#+END_SRC + ** u/w0ntfix [[https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_jajfxc9][🔗]] *Votes* 8 @@ -2784,6 +2737,53 @@ turning off org-elements cache speeds up input latency for me (found from profil #+END_SRC it seems (at least on my org 9.6.1) to update the cache after calls to ~org-self-insert-command~ (so, a lot!) +** u/SlowValue [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8u1ebf][🔗]] +*Votes* 8 + +I put a couple of similar functions on my ~~ key (with all combinations of modifier keys) and tend to forget the meanings of those combinations. + +So I made a small function to give some help for a list of keybindings.: + +#+BEGIN_SRC elisp +(defun my-generate-keybind-doc-on-keys (&rest keys) + "generate help on some given keybindings (kbd style)." + (substring + (apply #'concat + (mapcar #'(lambda (key) + (let* ((fun (key-binding (kbd key))) + (fun-name (symbol-name fun)) + (doc (documentation fun 'raw)) + (oneline (substring doc 0 (string-match "\n" doc)))) + (put-text-property 0 (length key) 'face 'font-lock-keyword-face key) + (put-text-property 0 (length fun-name) 'face 'font-lock-function-name-face fun-name) + (put-text-property 0 (length oneline) 'face 'font-lock-doc-face oneline) + (format "%10s : %-30s → %s\n" key fun-name oneline))) + keys)) + 0 -1)) + +#+END_SRC +To show that help in the echo buffer, one needs to define a command, which can be bound to a key: + +#+BEGIN_SRC elisp +(defun my-show-help-on-some-keys () + "demo generate help on 3 keys" + (interactive) + (message (my-generate-keybind-doc-on-keys "C-s" + " k" + "C-c !"))) + +#+END_SRC +Then calling the command ~my-show-help-on-some-keys~, shows following message in the echo buffer: + +#+BEGIN_SRC elisp + C-s : isearch-forward → Do incremental search forward. + k : helpful-key → Show help for interactive command bound to KEY-SEQUENCE. + C-c ! : shell-here → Open a shell relative to default-directory. + + +#+END_SRC +Remark: I know that ~which-key~ exists, but I'm already above that level of knowledge and don't need ~which-key~ anymore. + ** u/Nondv [[https://www.reddit.com/r/emacs/comments/t3_108zin2/comment/t1_j4ct1y1][🔗]] *Votes* 8 @@ -2828,7 +2828,7 @@ Is there a package/piece of code out there to: 2. execute arbitrary code 3. close frame on completion -Kind of like [emacs-everywhere](https://github.com/tecosaur/emacs-everywhere/) but for arbitrary code. +Kind of like [[https://github.com/tecosaur/emacs-everywhere/][emacs-everywhere]] but for arbitrary code. ** u/WorldsEndless [[https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_inqralq][🔗]] *Votes* 8 @@ -2886,14 +2886,14 @@ Pure awesomeness, thanks a lot for Magit/ Magit forge ! \** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_uxcm6i/comment/t1_i9xcaoa][🔗]] \*Votes* 8 -[arxiv-citation](https://github.com/slotthe/arxiv-citation) from my [last post](https://old.reddit.com/r/emacs/comments/ufvg93/my_phd_research_workflowemacs_inside/) is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)! +[[https://github.com/slotthe/arxiv-citation][arxiv-citation]] from my [[https://old.reddit.com/r/emacs/comments/ufvg93/my_phd_research_workflowemacs_inside/][last post]] is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)! -On that note, I've written a little bit about [calling Emacs from XMonad](https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html). The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful. +On that note, I've written a little bit about [[https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html][calling Emacs from XMonad]]. The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful. ** u/diamondnbond [[https://www.reddit.com/r/emacs/comments/t3_us7zae/comment/t1_i928gaj][🔗]] *Votes* 8 -[I Recently discovered engine-mode.](https://github.com/DiamondBond/emacs/blob/master/config.org#initialize-engine-mode) +[[https://github.com/DiamondBond/emacs/blob/master/config.org#initialize-engine-mode][I Recently discovered engine-mode.]] \** u/mmarshall540 [[https://www.reddit.com/r/emacs/comments/t3_un4wf8/comment/t1_i88sp07][🔗]] \*Votes* 8 @@ -2902,7 +2902,7 @@ Here's a little solution to a minor complaint about `isearch` that I think is fa # The Problem -TLDR: See [this old StackExchange question](https://emacs.stackexchange.com/questions/32373/go-to-start-of-search-string-after-ret) +TLDR: See [[https://emacs.stackexchange.com/questions/32373/go-to-start-of-search-string-after-ret][this old StackExchange question]] Often, I'll want to go to a precise location in a buffer to correct a typo. If that location is behind point (as it usually is if I notice the typo shortly after entering it), then `isearch-backward` works great. You press "C-r" and type some characters starting with your target until the location becomes the current result. As soon as the cursor jumps to your target location, you can use an editing command like "C-t", which exits isearch automatically for you. Or you can press "C-m" to exit isearch-mode and then start inserting text at that location. Wonderful! @@ -2982,7 +2982,7 @@ Call it with M-x, insert the name of the function you want to declare (with comp ** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_qgrpte/comment/t1_hicheof][🔗]] *Votes* 8 -A colleague just showed me Intellij's "[compare with clipboard](https://www.jetbrains.com/help/idea/comparing-files-and-folders.html#clipboard)" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections. +A colleague just showed me Intellij's "[[https://www.jetbrains.com/help/idea/comparing-files-and-folders.html#clipboard][compare with clipboard]]" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections. It didn't take me long to implement something similar: @@ -3005,7 +3005,7 @@ It's not ideal though. In particular, is there a better way to insert the "clip \** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_pk6akd/comment/t1_hc3bikc][🔗]] \*Votes* 8 -I'm using [orderless](https://github.com/oantolin/orderless) for completion but I also want to walk through files with initials only, to do something like [like this](https://imgur.com/a/CJg8MGw) for example. It only requires to ignore the case and ask the minibuffer to use initials. +I'm using [[https://github.com/oantolin/orderless][orderless]] for completion but I also want to walk through files with initials only, to do something like [[https://imgur.com/a/CJg8MGw][like this]] for example. It only requires to ignore the case and ask the minibuffer to use initials. #+BEGIN_SRC elisp (use-package orderless @@ -3277,7 +3277,7 @@ Here's the code, maybe there can be a lot of improvements: \** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfxbwgy][🔗]] \*Votes* 8 -I tried [marginalia](https://github.com/minad/marginalia) with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings. +I tried [[https://github.com/minad/marginalia][marginalia]] with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings. ** u/martinslot [[https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfwlm9q][🔗]] *Votes* 8 @@ -3308,7 +3308,7 @@ When I have multiple buffers opened and I switch from another program to emacs I ** u/ji99 [[https://www.reddit.com/r/emacs/comments/t3_hqxm5v/comment/t1_fy0xduj][🔗]] *Votes* 8 -Hippie-expand google search suggestions. Completely inspired from [shell-parse.el](https://github.com/malloc47/shell-parse.el/blob/master/shell-parse.el). +Hippie-expand google search suggestions. Completely inspired from [[https://github.com/malloc47/shell-parse.el/blob/master/shell-parse.el][shell-parse.el]]. I've added ~try-expand-google-completion~ to the bottom of my ~hippie-expand-try-functions-list~ @@ -3376,24 +3376,24 @@ The advice below quiets this warning, and inserts a dash whenever space is press ** u/karthink [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqfc1wi][🔗]] *Votes* 8 -AucTex users: You're missing out if you don't use [CDLatex](https://github.com/cdominik/cdlatex). It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is _always available_, not just during snippet entry. It's difficult to explain, so here are some demos: +AucTex users: You're missing out if you don't use [[https://github.com/cdominik/cdlatex][CDLatex]]. It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is _always available_, not just during snippet entry. It's difficult to explain, so here are some demos: -1. [Fast input with cdlatex and preview.el](https://gfycat.com/heavenlynegligiblehoiho) -2. [Fast input with keys displayed](https://gfycat.com/safeidolizedlangur) +1. [[https://gfycat.com/heavenlynegligiblehoiho][Fast input with cdlatex and preview.el]] +2. [[https://gfycat.com/safeidolizedlangur][Fast input with keys displayed]] -I wrote a longer post explaining [how I set up AucTex](https://www.reddit.com/r/emacs/comments/g8ecpj/advice_for_auclatex_what_keybinds_do_you_find/foo64ge/) recently. +I wrote a longer post explaining [[https://www.reddit.com/r/emacs/comments/g8ecpj/advice_for_auclatex_what_keybinds_do_you_find/foo64ge/][how I set up AucTex]] recently. CDLaTeX was written by Carsten Dominik, the author of Org-mode and reftex. Thus Org ships with an ~org-cdlatex~ minor-mode that makes these features available in org-mode. ** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqczes1][🔗]] *Votes* 8 -[A beginers guide to emacs 24 or later by sasha chua](https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png) this helped me tremendously to get started with emacs. +[[https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png][A beginers guide to emacs 24 or later by sasha chua]] this helped me tremendously to get started with emacs. ** u/ji99 [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqcycvb][🔗]] *Votes* 8 -A rudimentary interface for the fabulous [Links web browser](http://links.twibright.com/user_en.html): +A rudimentary interface for the fabulous [[http://links.twibright.com/user_en.html][Links web browser]]: #+BEGIN_SRC elisp (defun links-browser (&optional link new-window) @@ -3443,8 +3443,8 @@ A rudimentary interface for the fabulous [Links web browser](http://links.twibri Two tricks that helped me make my workflow a lot better: -1. ~(setq process-adaptive-read-buffering nil)~ makes [EAT](https://codeberg.org/akib/emacs-eat) a lot quicker! -2. ~(setq eglot-events-buffer-size 0)~, ~(fset #'jsonrpc--log-event #'ignore)~ and [eglot-booster](https://github.com/jdtsmith/eglot-booster) makes eglot A LOT quicker! +1. ~(setq process-adaptive-read-buffering nil)~ makes [[https://codeberg.org/akib/emacs-eat][EAT]] a lot quicker! +2. ~(setq eglot-events-buffer-size 0)~, ~(fset #'jsonrpc--log-event #'ignore)~ and [[https://github.com/jdtsmith/eglot-booster][eglot-booster]] makes eglot A LOT quicker! ** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_1afd05g/comment/t1_kob6a5m][🔗]] *Votes* 8 @@ -3508,7 +3508,7 @@ So the flow is: ** u/swhalemwo [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhtis87][🔗]] *Votes* 8 -recently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [generate org macros from my ~R~ script](https://emacs.stackexchange.com/questions/14647/use-code-variable-in-org-mode-continuous-text), [display their values rather than the macro text](https://notes.alexkehayias.com/emacs-inline-macro-in-the-buffer/), and pass ~org-macro-templates~ to ~consult--read~ to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on! +recently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [[https://emacs.stackexchange.com/questions/14647/use-code-variable-in-org-mode-continuous-text][generate org macros from my ~R~ script]], [[https://notes.alexkehayias.com/emacs-inline-macro-in-the-buffer/][display their values rather than the macro text]], and pass ~org-macro-templates~ to ~consult--read~ to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on! ** u/sebasTEEan [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhwipv8][🔗]] *Votes* 8 @@ -3575,12 +3575,12 @@ Now I can undo in selected region. Like magic. \** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imjs86m][🔗]] \*Votes* 8 -I don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [rapidly capture ideas](https://tony-zorman.com/posts/orgmode-prompt/2022-08-27-xmonad-and-org-mode.html) by using XMonad's org-mode integration! +I don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [[https://tony-zorman.com/posts/orgmode-prompt/2022-08-27-xmonad-and-org-mode.html][rapidly capture ideas]] by using XMonad's org-mode integration! \** u/poinkalum [[https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8rdjx9][🔗]] \*Votes* 8 -If you follow master, you can use the very useful command ~execute-extended-command-for-buffer~ by using ~M-X~ (with a capital "X"), that implements the behaviour described in [this blog post by Lars](https://lars.ingebrigtsen.no/2021/02/16/command-discovery-in-emacs/). It will only show commands that are relevant to the current major mode. +If you follow master, you can use the very useful command ~execute-extended-command-for-buffer~ by using ~M-X~ (with a capital "X"), that implements the behaviour described in [[https://lars.ingebrigtsen.no/2021/02/16/command-discovery-in-emacs/][this blog post by Lars]]. It will only show commands that are relevant to the current major mode. ** u/ji99 [[https://www.reddit.com/r/emacs/comments/t3_k4gv0x/comment/t1_ge8si78][🔗]] *Votes* 8 @@ -3753,7 +3753,7 @@ you can have an org-mode file in source block in an org file \** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_pt2xws/comment/t1_hdtoivy][🔗]] \*Votes* 8 -I've been playing around with Emacs 28's [repeat-mode](https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp?id=12409c9064c386a496dcbdca76b790108f6c1cad) a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function: +I've been playing around with Emacs 28's [[https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp?id=12409c9064c386a496dcbdca76b790108f6c1cad][repeat-mode]] a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function: #+BEGIN_SRC elisp (defmacro defrepeatmap (symbol &optional pairs docstring) @@ -3806,7 +3806,7 @@ I use this often when working on large files. You can bookmark up to 9 places in It works like this: ~C-c 0~ creates a bookmark and ~C-c <1-9>~ jumps into a bookmark. I've written about this on my old blog. I still use this from time to time. -[Faster buffer bookmarking in Emacs](https://jcubic.wordpress.com/2012/01/25/faster-buffer-bookmarking-in-emacs/). +[[https://jcubic.wordpress.com/2012/01/25/faster-buffer-bookmarking-in-emacs/][Faster buffer bookmarking in Emacs]]. \** u/WorldsEndless [[https://www.reddit.com/r/emacs/comments/t3_z8ltei/comment/t1_izxi6ie][🔗]] \*Votes* 8 @@ -3859,7 +3859,7 @@ For some time I have wished I could color code the background colors of differen ** u/meedstrom [[https://www.reddit.com/r/emacs/comments/t3_ydsjfy/comment/t1_itwo67r][🔗]] *Votes* 8 -I had the [defrepeater](https://github.com/alphapapa/defrepeater.el) package for a while, but didn't realize you could use it this elegantly! +I had the [[https://github.com/alphapapa/defrepeater.el][defrepeater]] package for a while, but didn't realize you could use it this elegantly! #+BEGIN_SRC elisp (global-set-key [remap transpose-lines] (defrepeater #'transpose-lines)) @@ -3870,7 +3870,7 @@ Something similar is actually in the readme, but I guess I glossed over it back ** u/khourhin [[https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_inp54pm][🔗]] *Votes* 8 -Just discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. [https://github.com/DamienCassou/desktop-environment](https://github.com/DamienCassou/desktop-environment) +Just discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. [[https://github.com/DamienCassou/desktop-environment][https://github.com/DamienCassou/desktop-environment]] Thanks Damien ! @@ -3929,7 +3929,7 @@ I will make some more improvements in the coming days, so if I split the window ** u/AffectionateAd8985 [[https://www.reddit.com/r/emacs/comments/t3_17vp0o1/comment/t1_k9g3i9s][🔗]] *Votes* 8 -In eshell, ~cd =xxx~ behaves like ~z xxx~ in [zoxide](https://github.com/ajeetdsouza/zoxide), jump to recent directory matching ~xxx~ pattern. +In eshell, ~cd =xxx~ behaves like ~z xxx~ in [[https://github.com/ajeetdsouza/zoxide][zoxide]], jump to recent directory matching ~xxx~ pattern. ** u/desquared [[https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_janipaz][🔗]] *Votes* 8 @@ -3973,7 +3973,7 @@ but rather in regular editing buffers that are visiting your own files. \** u/nicholas_hubbard [[https://www.reddit.com/r/emacs/comments/t3_rr330u/comment/t1_hqlp0en][🔗]] \*Votes* 8 -Here is a consult source for [perspective.el](https://github.com/nex3/perspective-el) +Here is a consult source for [[https://github.com/nex3/perspective-el][perspective.el]] #+BEGIN_SRC elisp (defvar consult--source-perspective @@ -4009,7 +4009,7 @@ I write in Arabic. ** u/elimik31 [[https://www.reddit.com/r/emacs/comments/t3_118sowc/comment/t1_j9jgfhg][🔗]] *Votes* 8 -The [texdoc](https://github.com/TeX-Live/texdoc/wiki/Tab-completion) CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the ~TeX-documentation-texdoc~ command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [tab-completion](https://github.com/TeX-Live/texdoc/wiki/Tab-completion), which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with ~completing-read~ and ~call-process~ to call the terminal command I created my own ~my-texdoc~ command with interactive candidate selection. It's available as [github gist here](https://gist.github.com/meliache/e645bf50c6aeac8e6e58b92c6bddac20), but I can also paste the code: +The [[https://github.com/TeX-Live/texdoc/wiki/Tab-completion][texdoc]] CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the ~TeX-documentation-texdoc~ command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [[https://github.com/TeX-Live/texdoc/wiki/Tab-completion][tab-completion]], which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with ~completing-read~ and ~call-process~ to call the terminal command I created my own ~my-texdoc~ command with interactive candidate selection. It's available as [[https://gist.github.com/meliache/e645bf50c6aeac8e6e58b92c6bddac20][github gist here]], but I can also paste the code: #+BEGIN_SRC elisp (defun my-texdoc--get-package-list () diff --git a/out_by_year.md b/out_by_year.md index bb91dec..ffab6e6 100644 --- a/out_by_year.md +++ b/out_by_year.md @@ -1,8 +1,8 @@ - + -# Years +# Comments Grouped by Year -- [Years](#years) +- [Comments Grouped by Year](#comments-grouped-by-year) - [2024](#2024) - [2023](#2023) - [2022](#2022) @@ -17,7 +17,7 @@ ### u/SlowMovingTarget [🔗](https://www.reddit.com/r/emacs/comments/t3_1fzmgwb/comment/t1_lr35bm5) -**Votes** 36 +**Votes** 39 Nothing revolutionary (and veterans will already know this), but a nice little function for splitting out text to a separate file: @@ -51,9 +51,22 @@ Then if you bind `(yas-expand-snippet (yas-lookup-snippet "namespace-surround")) ![img](https://i.redd.it/fbsbbr98smtc1.gif) +### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57) + +**Votes** 19 + +`use-package` has an inbuilt feature that roughly reports the loading times of each package on startup ([`esup`](https://github.com/jschaf/esup) most likely does a better job, if you can get it to run; there are [known issues](https://github.com/alexmurray/emacs-snap/issues/71) on Emacs snap): + +1. put `(setq use-package-compute-statistics t)` at the beginning of your `init.el` +2. restart Emacs +3. do `M-x use-package-report` + +Which package is your biggest time sink and why is it worth it? Mine is [`pdf-tools`](https://github.com/vedang/pdf-tools), but to my knowledge there is simply no better alternative for working with pdfs in emacs. + + ### u/vkazanov [🔗](https://www.reddit.com/r/emacs/comments/t3_1bdm6mc/comment/t1_kuo1f9y) -**Votes** 17 +**Votes** 18 A dump of my Emacs-related principles after 18 years of tinkering: @@ -70,26 +83,13 @@ A dump of my Emacs-related principles after 18 years of tinkering: I am a beginner though, things might change. -### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57) - -**Votes** 17 - -`use-package` has an inbuilt feature that roughly reports the loading times of each package on startup ([~esup~]() most likely does a better job, if you can get it to run; there are [known issues]() on Emacs snap): - -1. put `(setq use-package-compute-statistics t)` at the beginning of your `init.el` -2. restart Emacs -3. do `M-x use-package-report` - -Which package is your biggest time sink and why is it worth it? Mine is [~pdf-tools~](), but to my knowledge there is simply no better alternative for working with pdfs in emacs. - - ### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1fozctm/comment/t1_lpbqo0e) **Votes** 13 -I recently got tired of constantly having to move my eyes to the bottom of Emacs, so I switched to posframes, [which moves the information in a central pop-up instead](![img](https://blog.costan.ro/img/emacs-completion-system/switch-to.png)). For me, this meant using the packages: +I recently got tired of constantly having to move my eyes to the bottom of Emacs, so I switched to posframes, [which moves the information in a central pop-up instead](https://blog.costan.ro/img/emacs-completion-system/switch-to.png). For me, this meant using the packages: -\\\* [~vertico-posframe~]() - for [~vertico~]() \\\* [~which-key-posframe~]() - for [~which-key~]() \\\* [~transient-posframe~]() - for all transient commands, e.g., in [~magit~]() or in [~casual-suite~]() +\\\* [`vertico-posframe`](https://github.com/tumashu/vertico-posframe) - for [`vertico`](https://github.com/minad/vertico) \\\* [`which-key-posframe`](https://github.com/yanghaoxie/which-key-posframe) - for [`which-key`](https://github.com/justbur/emacs-which-key) \\\* [`transient-posframe`](https://github.com/yanghaoxie/transient-posframe) - for all transient commands, e.g., in [`magit`](https://github.com/magit/magit) or in [`casual-suite`](https://github.com/kickingvegas/casual-suite) But regardless what you are using, chances are there already is a suitable `*-posframe` package for it. Installing these packages is easy: @@ -106,6 +106,13 @@ But regardless what you are using, chances are there already is a suitable `*-po ``` +### u/UsualOffice1740 [🔗](https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9) + +**Votes** 12 + +I've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again. + + ### u/remillard [🔗](https://www.reddit.com/r/emacs/comments/t3_1cbsvxd/comment/t1_l11l7he) **Votes** 12 @@ -119,13 +126,22 @@ I suspect completion is doing a lot of heavy lifting here though too, so a perfe Anyway, I haven't popped open the Treemacs sidebar in weeks now, and just felt like I should write something in case someone was curious about how handy it was. -### u/algor512 [🔗](https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d) +### u/geza42 [🔗](https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1) **Votes** 12 -Recently I discovered that `C-h C-q` (or `M-x help-quick`) opens a small window showing \\\*Quick Help\\\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable `help-quick-sections`. +If you use an LSP server with semantic highlighting, it's worth checking out the value of `font-lock-maximum-decoration`. For example, I use `c++-mode` with `lsp-mode` (with clangd), I decreased `font-lock-maximum-decoration` to `2`, and I didn't notice any highlighting difference (because the lost highlighting by `c++-mode` gets highlighted by `lsp-mode`), while `c++-mode` font-locking become faster (`c++-mode` 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone). -I intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of `help-quick-sections`. +I use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~ + + +### u/JDRiverRun [🔗](https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6) + +**Votes** 12 + +I have long had convenience bindings for `org-emphasize` like `super-i` for *italic*, that match system bindings. But I always wanted these to **be smarter**, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not. + +[Check out my solution](https://gist.github.com/jdtsmith/55e6a660dd4c0779a600ac81bf9bfc23) (scroll down to see how it acts). Will miss this behavior in other apps! ### u/mlk [🔗](https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_lnqelw9) @@ -156,6 +172,32 @@ I made my agenda collapsible (like org headings) by using outline-minor-mode. To ``` +### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6) + +**Votes** 11 + +I regularly work with different emacs frames on different monitors, and [`framemove`](https://github.com/emacsmirror/framemove) is great for switching between them. It can hook into `windmove` (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions: + +\\\* `fm-up-frame`: move to the frame over the current frame \\\* `fm-down-frame`: move to the frame below the current frame \\\* `fm-left-frame`: move to the frame left of the current frame \\\* `fm-right-frame`: move to the frame right of the current frame + +It's not on any of the major package repositories, so you have to install it manually. Thanks to [`emacsmirror`](https://github.com/emacsmirror), this can for example be done as follows using `use-package` and `straight` (adjust bindings to your liking): + +```elisp +(use-package framemove + :straight (:host github :repo "emacsmirror/framemove") + :init + (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom + :bind + (("C-x 5 " . fm-up-frame) + ("C-x 5 " . fm-down-frame) + ("C-x 5 " . fm-left-frame) + ("C-x 5 " . fm-right-frame))) + +``` + +edit: The only thing I don't understand is why setting `framemove-hook-into-windmove` to `t` doesn't work in via `:config` or `:custom`. The package is loaded, `C-h f` confirms that `fm-up-frame` exists, but `C-h v` doesn't know `framemove-hook-into-windmove`. `framemove-hook-into-windmove` exists after I run `fm-up-frame`, but then it's set to `nil` and not `t`. + + ### u/sauntcartas [🔗](https://www.reddit.com/r/emacs/comments/t3_1djdync/comment/t1_l9cmdp9) **Votes** 11 @@ -176,70 +218,81 @@ A minor annoyance was that an unwanted link to whatever file location I happened ``` -### u/saltwaterflyguy [🔗](https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8) +### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q) **Votes** 11 -describe-\\\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v. +Not from me, but I just wanted to share /u/arthurno1 one-line tip to get `which-key` to work with `dired` (see screenshot in linked post): -If you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions. + +I assume the same trick applies to other mode-maps as well. -### u/geza42 [🔗](https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1) + +### u/algor512 [🔗](https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d) **Votes** 11 -If you use an LSP server with semantic highlighting, it's worth checking out the value of `font-lock-maximum-decoration`. For example, I use `c++-mode` with `lsp-mode` (with clangd), I decreased `font-lock-maximum-decoration` to `2`, and I didn't notice any highlighting difference (because the lost highlighting by `c++-mode` gets highlighted by `lsp-mode`), while `c++-mode` font-locking become faster (`c++-mode` 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone). +Recently I discovered that `C-h C-q` (or `M-x help-quick`) opens a small window showing \\\*Quick Help\\\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable `help-quick-sections`. -I use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~ +I intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of `help-quick-sections`. -### u/JDRiverRun [🔗](https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6) +### u/ilemming [🔗](https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1) -**Votes** 11 +**Votes** 10 -I have long had convenience bindings for `org-emphasize` like `super-i` for *italic*, that match system bindings. But I always wanted these to **be smarter**, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not. +You know that you can use vars in org source blocks that inject some data, like: -[Check out my solution]() (scroll down to see how it acts). Will miss this behavior in other apps! +```elisp +#+begin_src bash :var token="bla-bla-bla" +echo ${token} +``` + bla-bla-bla -### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6) +\#+ENDSRC That can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block. -**Votes** 10 +```elisp +#+name: dirs +#+begin_src bash :results silent +ls +``` + +```js +console.log(data) +``` -I regularly work with different emacs frames on different monitors, and [~framemove~]() is great for switching between them. It can hook into `windmove` (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions: +\#+ENDSRC But did you know, you can also use elisp there? -\\\* `fm-up-frame`: move to the frame over the current frame \\\* `fm-down-frame`: move to the frame below the current frame \\\* `fm-left-frame`: move to the frame left of the current frame \\\* `fm-right-frame`: move to the frame right of the current frame +```elisp +#+begin_src js :var data=(if (featurep :system 'macos) "🍎" "🐧") +return data; +``` -It's not on any of the major package repositories, so you have to install it manually. Thanks to [~emacsmirror~](), this can for example be done as follows using `use-package` and `straight` (adjust bindings to your liking): + 🍎 + +\#+ENDSRC Or previous-like example with dirs but without needing additional source block: ```elisp -(use-package framemove - :straight (:host github :repo "emacsmirror/framemove") - :init - (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom - :bind - (("C-x 5 " . fm-up-frame) - ("C-x 5 " . fm-down-frame) - ("C-x 5 " . fm-left-frame) - ("C-x 5 " . fm-right-frame))) +#+begin_src clojure :var data=(shell-command-to-string "ls -a ~") +;; all dotfiles +(require '[clojure.string :as str]) +(->> (str/split data #"\n") + (filter (partial re-find #"^\.*")) + (sort) + (str/join "\n")) ``` -edit: The only thing I don't understand is why setting `framemove-hook-into-windmove` to `t` doesn't work in via `:config` or `:custom`. The package is loaded, `C-h f` confirms that `fm-up-frame` exists, but `C-h v` doesn't know `framemove-hook-into-windmove`. `framemove-hook-into-windmove` exists after I run `fm-up-frame`, but then it's set to `nil` and not `t`. +\#+ENDSRC -### u/fuzzbomb23 [🔗](https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7) +### u/regob [🔗](https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro) **Votes** 10 -One of my favourite tips for managing my init file is the `imenu` support in `use-package`. It's turned off by default, though: - -```elisp -(setq use-package-enable-imenu-support t) -``` - -Combined with a nice imenu UI (`consult-imenu` and Vertico, say) you can navigate your init file really quickly. +`C-x C-e` to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal) ### u/wintershere [🔗](https://www.reddit.com/r/emacs/comments/t3_1eaw1ia/comment/t1_leom8fv) @@ -266,22 +319,22 @@ Useful when you include some classless css libraries which require you to add at Don't skip `HTML_DOCTYPE` else it will duplicate the attribute because one extra will be added due to `xml:lang` -### u/UsualOffice1740 [🔗](https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9) +### u/thetemp\_ [🔗](https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy) **Votes** 10 -I've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again. +I recently discovered the [Dimmer](https://github.com/gonewest818/dimmer.el) package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that **is** focused. And of course, you can customize how much it dims and exclude certain buffers. +I love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore. -### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q) -**Votes** 10 +### u/saltwaterflyguy [🔗](https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8) -Not from me, but I just wanted to share /u/arthurno1 one-line tip to get `which-key` to work with `dired` (see screenshot in linked post): +**Votes** 10 - +describe-\\\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v. -I assume the same trick applies to other mode-maps as well. +If you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions. ### u/bopboa [🔗](https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kphrvz3) @@ -297,6 +350,31 @@ This is how to have a beacon without installing any packages. ``` +### u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp) + +**Votes** 10 + +Many of you probably know of this, but I found "indirect buffers" useful. + +When I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the "folding" and "narrow" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow `C-x n s` into different headings of the file in different windows. + +Indirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that `C-x 4 c C-x n s` did what I wanted. + + +### u/badmaxton [🔗](https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp) + +**Votes** 10 + +Just added this to the `:init` section of my embark configuration: + +```elisp +(define-key minibuffer-local-map [C-tab] 'embark-select) + +``` + +This allows super-convenient marking of entries for later `embark-all` using control-tab, instead of having to go first through the `embark` menu. (By default, this key binding is mapped to `file-cache-minibuffer-complete`, which I never use.) + + ### u/camelcaset [🔗](https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kgce54q) **Votes** 10 @@ -325,66 +403,66 @@ I created this file and now Emacs keybindings work everywhere: You can read more here: -### u/regob [🔗](https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro) - -**Votes** 9 - -`C-x C-e` to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal) - - -### u/thetemp\_ [🔗](https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy) +### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1gfhkdg/comment/t1_lui5ao9) **Votes** 9 -I recently discovered the [Dimmer]() package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that **is** focused. And of course, you can customize how much it dims and exclude certain buffers. +I've recently discovered [`org-pdftools`](https://github.com/fuxialexander/org-pdftools) and it offers everything I need for annotating pdfs in emacs. I mainly use it to enhance the inbuilt function `org-store-link`: -I love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore. - - -### u/JDRiverRun [🔗](https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3) - -**Votes** 9 +\\\* mark a passage in the pdf, run `M-x org-store-link`, and it creates a highlight in the pdf (technically an empty annotation) and copies a link to it. \\\* run `C-c C-l` in any org-buffer, and it pastes the link and prompts you for a name. -A few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [this gist]() for the details. +The installation is easy, you just need to hook it into `org-mode`: +```elisp +(use-package org-pdftools + :after (org pdf-tools) + :hook (org-mode . org-pdftools-setup-link)) -### u/demosthenex [🔗](https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6) +``` -**Votes** 9 +The only thing to keep in mind is that the highlights in the pdf are not automatically deleted, as you delete the link in the org buffer. You have to do that manually in the pdf (`C-c C-a l` to list all highlights, `D` to delete). -M-x ielm Use the repl while learning elisp coding. I had no idea! +It has less features than [`org-noter`](https://github.com/org-noter/org-noter), but it is more flexible, which is why it suits my use-case better. Unfortunately, it has `org-noter` as a dependency, so you will end up loading it either way. -### u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp) +### u/fuzzbomb23 [🔗](https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7) **Votes** 9 -Many of you probably know of this, but I found "indirect buffers" useful. +One of my favourite tips for managing my init file is the `imenu` support in `use-package`. It's turned off by default, though: -When I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the "folding" and "narrow" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow `C-x n s` into different headings of the file in different windows. +```elisp +(setq use-package-enable-imenu-support t) +``` -Indirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that `C-x 4 c C-x n s` did what I wanted. +Combined with a nice imenu UI (`consult-imenu` and Vertico, say) you can navigate your init file really quickly. -### u/badmaxton [🔗](https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp) +### u/pt-guzzardo [🔗](https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx) **Votes** 9 -Just added this to the `:init` section of my embark configuration: - ```elisp -(define-key minibuffer-local-map [C-tab] 'embark-select) +(defun copy-source-for-reddit () + (interactive) + (let ((contents (buffer-substring (point) (mark)))) + (with-temp-buffer + (insert contents) + (mark-whole-buffer) + (indent-rigidly (point) (mark) 4 t) + (mark-whole-buffer) + (kill-ring-save 0 0 t)))) ``` -This allows super-convenient marking of entries for later `embark-all` using control-tab, instead of having to go first through the `embark` menu. (By default, this key binding is mapped to `file-cache-minibuffer-complete`, which I never use.) +A handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer. ### u/lesliesrussell [🔗](https://www.reddit.com/r/emacs/comments/t3_198rnkj/comment/t1_kibmgv2) **Votes** 9 -[transient map for movement]() +[transient map for movement](https://gist.github.com/lesliesrussell/46302d413fcf49e9717eeea57fdadcbf) Defines a transient keymap for movement controls and sets up a global key binding to activate this transient map. This transient map, \\~my-movement-transient-map\\~, includes bindings for various movement commands like moving forward or backward by a word or character and moving to the next or previous line. The \\~activate-my-movement-map\\~ function is defined to activate this transient map, and it is globally bound to \\~C-f\\~. @@ -403,29 +481,7 @@ I didn't want to drop code in the thread so i put it in a gist **Votes** 9 -A blog post regarding my own Emacs config aiming to get the same user experience on both TUI and GUI. []() - - -### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1gfhkdg/comment/t1_lui5ao9) - -**Votes** 8 - -I've recently discovered [~org-pdftools~]() and it offers everything I need for annotating pdfs in emacs. I mainly use it to enhance the inbuilt function `org-store-link`: - -\\\* mark a passage in the pdf, run `M-x org-store-link`, and it creates a highlight in the pdf (technically an empty annotation) and copies a link to it. \\\* run `C-c C-l` in any org-buffer, and it pastes the link and prompts you for a name. - -The installation is easy, you just need to hook it into `org-mode`: - -```elisp -(use-package org-pdftools - :after (org pdf-tools) - :hook (org-mode . org-pdftools-setup-link)) - -``` - -The only thing to keep in mind is that the highlights in the pdf are not automatically deleted, as you delete the link in the org buffer. You have to do that manually in the pdf (`C-c C-a l` to list all highlights, `D` to delete). - -It has less features than [~org-noter~](), but it is more flexible, which is why it suits my use-case better. Unfortunately, it has `org-noter` as a dependency, so you will end up loading it either way. +A blog post regarding my own Emacs config aiming to get the same user experience on both TUI and GUI. [https://www.rahuljuliato.com/posts/lemacs](https://www.rahuljuliato.com/posts/lemacs) ### u/fv\_\_ [🔗](https://www.reddit.com/r/emacs/comments/t3_1fzmgwb/comment/t1_lr5ceqe) @@ -435,56 +491,6 @@ It has less features than [~org-noter~]( C-x in a transient popup shows menu to save selected options e.g., it can be used to select ~ –force-with-lease~ by default while pushing in magit (P p) -### u/ilemming [🔗](https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1) - -**Votes** 8 - -You know that you can use vars in org source blocks that inject some data, like: - -```elisp -#+begin_src bash :var token="bla-bla-bla" -echo ${token} -``` - - bla-bla-bla - -\#+ENDSRC That can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block. - -```elisp -#+name: dirs -#+begin_src bash :results silent -ls -``` - -```js -console.log(data) -``` - -\#+ENDSRC But did you know, you can also use elisp there? - -```elisp -#+begin_src js :var data=(if (featurep :system 'macos) "🍎" "🐧") -return data; -``` - - 🍎 - -\#+ENDSRC Or previous-like example with dirs but without needing additional source block: - -```elisp -#+begin_src clojure :var data=(shell-command-to-string "ls -a ~") -;; all dotfiles -(require '[clojure.string :as str]) - -(->> (str/split data #"\n") - (filter (partial re-find #"^\.*")) - (sort) - (str/join "\n")) -``` - -\#+ENDSRC - - ### u/meedstrom [🔗](https://www.reddit.com/r/emacs/comments/t3_1fe504e/comment/t1_lmzbyro) **Votes** 8 @@ -518,34 +524,28 @@ Highlight regexp or strings in your buffer with `M+s h` good for analyzing logfi **Votes** 8 -For users of [rg.el]() (emacs interface to ripgrep) there is [rga]() (ripgrep-all) a wrapper around ripgrep that "enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc." You can set the rg executable in the configuration of rg.el like so: `(setq rg-executable (executable-find "rga")` to enable search in multiple document types. +For users of [rg.el](https://github.com/dajva/rg.el) (emacs interface to ripgrep) there is [rga](https://github.com/phiresky/ripgrep-all) (ripgrep-all) a wrapper around ripgrep that "enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc." You can set the rg executable in the configuration of rg.el like so: `(setq rg-executable (executable-find "rga")` to enable search in multiple document types. -### u/AdjointFunctor [🔗](https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l359pqx) +### u/JDRiverRun [🔗](https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3) **Votes** 8 -I (re) discovered rectangle mode recently. Very useful when deleting lots of indents. C-x spc then make the region. +A few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [this gist](https://gist.github.com/jdtsmith/a169362879388bc1bdf2bbb977782d4f) for the details. -### u/pt-guzzardo [🔗](https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx) +### u/AdjointFunctor [🔗](https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l359pqx) **Votes** 8 -```elisp -(defun copy-source-for-reddit () - (interactive) - (let ((contents (buffer-substring (point) (mark)))) - (with-temp-buffer - (insert contents) - (mark-whole-buffer) - (indent-rigidly (point) (mark) 4 t) - (mark-whole-buffer) - (kill-ring-save 0 0 t)))) +I (re) discovered rectangle mode recently. Very useful when deleting lots of indents. C-x spc then make the region. + -``` +### u/demosthenex [🔗](https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6) -A handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer. +**Votes** 8 + +M-x ielm Use the repl while learning elisp coding. I had no idea! ### u/IcyThought [🔗](https://www.reddit.com/r/emacs/comments/t3_1aw6xkc/comment/t1_kriu3ye) @@ -554,8 +554,8 @@ A handy little snippet for exporting code to reddit markdown. Takes the region, Two tricks that helped me make my workflow a lot better: -1. `(setq process-adaptive-read-buffering nil)` makes [EAT]() a lot quicker! -2. `(setq eglot-events-buffer-size 0)`, `(fset #'jsonrpc--log-event #'ignore)` and [eglot-booster]() makes eglot A LOT quicker! +1. `(setq process-adaptive-read-buffering nil)` makes [EAT](https://codeberg.org/akib/emacs-eat) a lot quicker! +2. `(setq eglot-events-buffer-size 0)`, `(fset #'jsonrpc--log-event #'ignore)` and [eglot-booster](https://github.com/jdtsmith/eglot-booster) makes eglot A LOT quicker! ### u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_1afd05g/comment/t1_kob6a5m) @@ -585,7 +585,7 @@ I use this often when working on large files. You can bookmark up to 9 places in It works like this: `C-c 0` creates a bookmark and `C-c <1-9>` jumps into a bookmark. I've written about this on my old blog. I still use this from time to time. -[Faster buffer bookmarking in Emacs](). +[Faster buffer bookmarking in Emacs](https://jcubic.wordpress.com/2012/01/25/faster-buffer-bookmarking-in-emacs/). ### u/ImJustPassinBy [🔗](https://www.reddit.com/r/emacs/comments/t3_1c64gcj/comment/t1_l01n03t) @@ -602,7 +602,7 @@ Just found out about the variable `confirm-kill-emacs`. Never again will I quit ### u/PriorOutcome [🔗](https://www.reddit.com/r/emacs/comments/t3_10qo7vb/comment/t1_j6rmvvf) -**Votes** 32 +**Votes** 31 When you have an active region, `undo` will only undo changes in that region instead of the whole file. @@ -614,17 +614,6 @@ When you have an active region, `undo` will only undo changes in that region ins With an active region, you can freely toggle between rectangle mark mode and normal, you don't need to get rid of your active region to switch between the two. -### u/AndreaSomePostfix [🔗](https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh) - -**Votes** 19 - -org-mode is amazing! - -I discovered \\~org-copy-visible\\~ the other day, when I wanted to send somebody only the outline of my notes. - -That function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful! - - ### u/WorldsEndless [🔗](https://www.reddit.com/r/emacs/comments/t3_12rlq4a/comment/t1_jgwlxuw) **Votes** 18 @@ -641,6 +630,17 @@ I'm a big user of `ffap`. I use this function with `M-x` each time I want to ope But this week I discovered `ffap-bindings`. This function replaces some key bindings to use `ffap` when it makes sense. For example, it replaces `find-file` with `find-file-at-point`, so the usual keybindings are enriched at no cost. +### u/AndreaSomePostfix [🔗](https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh) + +**Votes** 18 + +org-mode is amazing! + +I discovered \\~org-copy-visible\\~ the other day, when I wanted to send somebody only the outline of my notes. + +That function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful! + + ### u/WorldsEndless [🔗](https://www.reddit.com/r/emacs/comments/t3_1758wua/comment/t1_k4g09iw) **Votes** 16 @@ -666,10 +666,25 @@ From `consult-grep` documentation, command line options can be passed to grep, s I have just discovered this, and it made my day. -### u/leothrix [🔗](https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z) +### u/PriorOutcome [🔗](https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc) **Votes** 14 +Plain old `query-replace` has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain `y~/~n`: + +`!`: replaces all remaning matches + +`u`: undo last replacement + +`E`: changes replacement string on the fly + +And many more you can see using `?`. + + +### u/leothrix [🔗](https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z) + +**Votes** 13 + For `use-package` users (which I assume is many of us), did you know that profiling is easy to do? I'm not talking about `esup`, but a built-in capability that makes it very straightforward to find places to optimize your `init.el` for significantly faster start times. Enable `use-package-compute-statistics` right after you load `use-package`: @@ -684,7 +699,7 @@ Restart emacs, and then invoke `use-package-report`. You'll get a table of the l ### u/geza42 [🔗](https://www.reddit.com/r/emacs/comments/t3_11lqkbo/comment/t1_jbe06qv) -**Votes** 14 +**Votes** 13 You can toggle vertico's height between 15 and "almost full frame" with this. When vertico is invoked, it will always have a height of 15. But if you have a lot of matches, and like to have a better overview, press the binding, and vertico will show a full frame of matches. This is useful for example when `consult-buffer` presents a lot of buffers. @@ -726,33 +741,18 @@ I'm not sure whether these two can be achieved out-of-the box, but I didn't find ### u/ayyess [🔗](https://www.reddit.com/r/emacs/comments/t3_18hc301/comment/t1_kdobd72) -**Votes** 13 +**Votes** 12 I recently discovered `(setq read-minibuffer-restore-windows nil)` which resolves my frustration that quitting the minibuffer would discard any changes to the window layout while the minibuffer was open. For example, by default, `M-x C-h k k C-g` quits the just opened help buffer. I'm sure to have missed many more QOL improvements from NEWS. -### u/PriorOutcome [🔗](https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc) - -**Votes** 13 - -Plain old `query-replace` has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain `y~/~n`: - -`!`: replaces all remaning matches - -`u`: undo last replacement - -`E`: changes replacement string on the fly - -And many more you can see using `?`. - - ### u/elevencupfuls [🔗](https://www.reddit.com/r/emacs/comments/t3_10ktqj0/comment/t1_j5umed8) **Votes** 12 I jump into the built-in Elisp files a lot to see how things work. The indentation there is GNU standard, which uses a mix of tabs and spaces for alignment. The tabs have to be rendered as 8 spaces wide for the alignment to work, and I don't actually want that setting anywhere else. Since the files on Mac are inside the application bundle, I don't want to just add a .dir-locals.el file next to them, either. -[Directory classes]() to the rescue! My config makes a new directory variable class, `builtin-elisp`, with a list saying that `emacs-lisp-mode` should use a `tab-width` of 8. Then it applies that class to the Elisp files in the application bundle: +[Directory classes](https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html) to the rescue! My config makes a new directory variable class, `builtin-elisp`, with a list saying that `emacs-lisp-mode` should use a `tab-width` of 8. Then it applies that class to the Elisp files in the application bundle: ```elisp (use-package elisp-mode @@ -769,9 +769,25 @@ I jump into the built-in Elisp files a lot to see how things work. The indentati And now when I visit one of those files, the alignment is always correct. +### u/leothrix [🔗](https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8dlt4c) + +**Votes** 10 + +Need to remove an element from a list when you're tinkering with elisp? + +Sometimes when I'm adding and removing elements from hooks or variables like `completion-at-point-functions` I'll often need to tinker with the symbols I've added. You could evaluate some form somewhere, but I like to be lazy and just: + +```elisp +M-x remove-hook + +``` + +And you've got an interactive interface (using `completing-read`) for removing arbitrary elements from any list-like variable. It's technically for altering hooks, but you can abuse it to fool around with lists, too. + + ### u/PriorOutcome [🔗](https://www.reddit.com/r/emacs/comments/t3_15sjm3k/comment/t1_jwff8bw) -**Votes** 11 +**Votes** 10 I've been slowly accumulating cases for "flexing" the thing at point as a more general `capitalize-word` replacement: @@ -809,47 +825,35 @@ E.g. capitalize or decapitalize the next word, increment number at point." I bind it to `M-c`. -### u/leothrix [🔗](https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8dlt4c) +### u/gusbrs [🔗](https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts) **Votes** 10 -Need to remove an element from a list when you're tinkering with elisp? - -Sometimes when I'm adding and removing elements from hooks or variables like `completion-at-point-functions` I'll often need to tinker with the symbols I've added. You could evaluate some form somewhere, but I like to be lazy and just: - -```elisp -M-x remove-hook - -``` - -And you've got an interactive interface (using `completing-read`) for removing arbitrary elements from any list-like variable. It's technically for altering hooks, but you can abuse it to fool around with lists, too. +I was converting some old `.odt` notes files to `.org` today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: `repunctuate-sentences`. I have no idea if this is new or has always been there. It is new to me. It uses `query-replace-regexp`, so it's the same experience. And also can be configured for exclusions with `repunctuate-sentences-filter`. Neat! -### u/frosch03 [🔗](https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a) +### u/sauntcartas [🔗](https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv) **Votes** 10 -Very useful, but I keep forgetting it: - -If you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: `C-x -` - -And if you want to balance these two buffers again just use `C-x +` - +I work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice: -### u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz) +```elisp +(defun default-to-main-project (dir) + (or dir *main-project-dir*)) -**Votes** 10 +(advice-add 'projectile-ensure-project :override #'default-to-main-project) -Put the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press) +``` -Win - Alt - Ctrl - Space - Ctrl - Alt - Win +I lose some of the functionality of `projectile-ensure-project`, but I never used it anyway. ### u/AnugNef4 [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_ja41lso) **Votes** 10 -How I got my Info Directory node `C-h i` to display all my installed .info files living under `/opt/homebrew` on an M1 Mac. I run emacs-plus@29 from [d12frosted on github](). +How I got my Info Directory node `C-h i` to display all my installed .info files living under `/opt/homebrew` on an M1 Mac. I run emacs-plus@29 from [d12frosted on github](https://github.com/d12frosted/homebrew-emacs-plus). init.el snippet @@ -891,25 +895,11 @@ Do you want a key binding to wrap the selection in some kind of delimiter? Here' This setups up `C-S-w` to be a prefix map, `insert-pair-map`. The only key binding in `insert-pair-map` is for `[t]`, which means it is the default key binding and any key after the prefix will run the same command: `insert-pair`. Now, `insert-pair` looks at which key was used to invoke it and if it is an opening delimiter it inserts both it and the corresponding closing delimiter (and if the region is active it insert the opening delimiter at the start and the closing delimiter at the end, wrapping the region). -### u/Netherus [🔗](https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7) - -**Votes** 9 - -Just recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me. - - -### u/gusbrs [🔗](https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts) - -**Votes** 9 - -I was converting some old `.odt` notes files to `.org` today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: `repunctuate-sentences`. I have no idea if this is new or has always been there. It is new to me. It uses `query-replace-regexp`, so it's the same experience. And also can be configured for exclusions with `repunctuate-sentences-filter`. Neat! - - ### u/BunnyLushington [🔗](https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhrzybp) **Votes** 9 -I found myself debugging [JWTs]() earlier this week and whomped up a little function to decode them from a region into a help buffer. +I found myself debugging [JWTs](https://jwt.io) earlier this week and whomped up a little function to decode them from a region into a help buffer. ```elisp (defun ii/decode-jwt (start end &optional jwt) @@ -935,26 +925,76 @@ I'd forgotten about `with-output-to-temp-buffer` which is pretty handy. The `t` (This should be obvious but note that the JWT is not validated or verified. This is intended for debugging only and the JWT should not be trusted.) -### u/sauntcartas [🔗](https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv) +### u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz) **Votes** 9 -I work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice: +Put the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press) -```elisp -(defun default-to-main-project (dir) - (or dir *main-project-dir*)) +Win - Alt - Ctrl - Space - Ctrl - Alt - Win -(advice-add 'projectile-ensure-project :override #'default-to-main-project) +### u/pathemata [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mpo5y) + +**Votes** 9 + +Does anyone have an `aspell` setup with multiple dictionaries? + +When I try `--extra-dict` option I get an error: `Expected language "en" but got "de"`. + + +### u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_18mplfa/comment/t1_ke5xr5j) + +**Votes** 8 + +This makes stack-outputs of debug-buffers much more readable: + +```elisp +(setopt debugger-stack-frame-as-list t) ``` -I lose some of the functionality of `projectile-ensure-project`, but I never used it anyway. + +### u/vjgoh [🔗](https://www.reddit.com/r/emacs/comments/t3_18149ql/comment/t1_kahspwz) + +**Votes** 8 + +I used to have a problem where eglot would decide that many mid-hierarchy directories were the project root and spin up a separate instance of clangd for each one (sometimes 10 or 12 total). This was almost certainly due to using emacs' built-in `project` to handle project discovery. At that point, I switched to lsp-mode because I generally find `project` to be impenetrable and poorly documented compared to projectile. + +I was forced to go back to eglot, however, because lsp-mode has been failing to parse things well for a while. + +Long story short, here's how you force `project` to find the actual project root if the automatic detection doesn't work. With this, eglot started working great, didn't spin up 10 instances of clangd, and has generally been ticking over just fine. + +`(setq project-vc-extra-root-markers '(".project.el" ".projectile" ".dir-locals.el"))` + + +### u/Netherus [🔗](https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7) + +**Votes** 8 + +Just recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me. + + +### u/AP145 [🔗](https://www.reddit.com/r/emacs/comments/t3_16hh7u4/comment/t1_k1803gl) + +**Votes** 8 + +I used to always get confused why people say that the default Emacs key bindings hurt their pinky's, but then I realized that I don't touch type and thus I don't have to stretch my fingers anywhere for the default key bindings. Ironically my ineptitude at typing has saved me from repetitive stress injuries. + + +### u/frosch03 [🔗](https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a) + +**Votes** 8 + +Very useful, but I keep forgetting it: + +If you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: `C-x -` + +And if you want to balance these two buffers again just use `C-x +` ### u/slinchisl [🔗](https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jca66k0) -**Votes** 9 +**Votes** 8 I'm once again reminded of the utility of `read-key` for small functions where one wants a nicer interface for choosing an alternative than universal arguments; taking an optional prompt, it simply reads a key from the keyboard and returns it. @@ -979,18 +1019,24 @@ For example, I recently wanted a function that prints a set of predefined dates ``` -### u/pathemata [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mpo5y) +### u/w0ntfix [🔗](https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_jajfxc9) -**Votes** 9 +**Votes** 8 -Does anyone have an `aspell` setup with multiple dictionaries? +turning off org-elements cache speeds up input latency for me (found from profiling): -When I try `--extra-dict` option I get an error: `Expected language "en" but got "de"`. +```elisp +(setq org-element-use-cache nil) + + +``` + +it seems (at least on my org 9.6.1) to update the cache after calls to `org-self-insert-command` (so, a lot!) ### u/SlowValue [🔗](https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8u1ebf) -**Votes** 9 +**Votes** 8 I put a couple of similar functions on my `` key (with all combinations of modifier keys) and tend to forget the meanings of those combinations. @@ -1040,52 +1086,6 @@ Then calling the command `my-show-help-on-some-keys`, shows following message in Remark: I know that `which-key` exists, but I'm already above that level of knowledge and don't need `which-key` anymore. -### u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_18mplfa/comment/t1_ke5xr5j) - -**Votes** 8 - -This makes stack-outputs of debug-buffers much more readable: - -```elisp -(setopt debugger-stack-frame-as-list t) -``` - - -### u/vjgoh [🔗](https://www.reddit.com/r/emacs/comments/t3_18149ql/comment/t1_kahspwz) - -**Votes** 8 - -I used to have a problem where eglot would decide that many mid-hierarchy directories were the project root and spin up a separate instance of clangd for each one (sometimes 10 or 12 total). This was almost certainly due to using emacs' built-in `project` to handle project discovery. At that point, I switched to lsp-mode because I generally find `project` to be impenetrable and poorly documented compared to projectile. - -I was forced to go back to eglot, however, because lsp-mode has been failing to parse things well for a while. - -Long story short, here's how you force `project` to find the actual project root if the automatic detection doesn't work. With this, eglot started working great, didn't spin up 10 instances of clangd, and has generally been ticking over just fine. - -`(setq project-vc-extra-root-markers '(".project.el" ".projectile" ".dir-locals.el"))` - - -### u/AP145 [🔗](https://www.reddit.com/r/emacs/comments/t3_16hh7u4/comment/t1_k1803gl) - -**Votes** 8 - -I used to always get confused why people say that the default Emacs key bindings hurt their pinky's, but then I realized that I don't touch type and thus I don't have to stretch my fingers anywhere for the default key bindings. Ironically my ineptitude at typing has saved me from repetitive stress injuries. - - -### u/w0ntfix [🔗](https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_jajfxc9) - -**Votes** 8 - -turning off org-elements cache speeds up input latency for me (found from profiling): - -```elisp -(setq org-element-use-cache nil) - - -``` - -it seems (at least on my org 9.6.1) to update the cache after calls to `org-self-insert-command` (so, a lot!) - - ### u/Nondv [🔗](https://www.reddit.com/r/emacs/comments/t3_108zin2/comment/t1_j4ct1y1) **Votes** 8 @@ -1144,7 +1144,7 @@ So the flow is: **Votes** 8 -recently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [generate org macros from my `R` script](), [display their values rather than the macro text](), and pass `org-macro-templates` to `consult--read` to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on! +recently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [generate org macros from my `R` script](https://emacs.stackexchange.com/questions/14647/use-code-variable-in-org-mode-continuous-text), [display their values rather than the macro text](https://notes.alexkehayias.com/emacs-inline-macro-in-the-buffer/), and pass `org-macro-templates` to `consult--read` to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on! ### u/sebasTEEan [🔗](https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhwipv8) @@ -1209,7 +1209,7 @@ In a presentation this morning, I wanted to show a file, but it contained sensit **Votes** 8 -In eshell, `cd =xxx` behaves like `z xxx` in [zoxide](), jump to recent directory matching `xxx` pattern. +In eshell, `cd =xxx` behaves like `z xxx` in [zoxide](https://github.com/ajeetdsouza/zoxide), jump to recent directory matching `xxx` pattern. ### u/desquared [🔗](https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_janipaz) @@ -1246,7 +1246,7 @@ To get the link target – the note, the abbreviation, and so on – t **Votes** 8 -The [texdoc]() CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the `TeX-documentation-texdoc` command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [tab-completion](), which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with `completing-read` and `call-process` to call the terminal command I created my own `my-texdoc` command with interactive candidate selection. It's available as [github gist here](), but I can also paste the code: +The [texdoc](https://github.com/TeX-Live/texdoc/wiki/Tab-completion) CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the `TeX-documentation-texdoc` command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [tab-completion](https://github.com/TeX-Live/texdoc/wiki/Tab-completion), which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with `completing-read` and `call-process` to call the terminal command I created my own `my-texdoc` command with interactive candidate selection. It's available as [github gist here](https://gist.github.com/meliache/e645bf50c6aeac8e6e58b92c6bddac20), but I can also paste the code: ```elisp (defun my-texdoc--get-package-list () @@ -1415,7 +1415,7 @@ I just learned that in eshell, $$ is replaced with the output from the last comm **Votes** 20 -Update from a couple of weeks ago: after some grinding, I've set the parsing of past comments from this thread to auto update on a weekly basis here: []() +Update from a couple of weeks ago: after some grinding, I've set the parsing of past comments from this thread to auto update on a weekly basis here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md) I've also fixed the broken highlighting of some code snippets, and hopefully parsed all past threads. There's 200+ comments there (sorted by upvotes), so ctrl-f ing e.g. \\~magit\\~ may help you if you're looking for something specific @@ -1488,7 +1488,7 @@ Easy peasy! **Votes** 17 -It's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [post about it](). There's a few posts around suggesting features of `use-package` to optimise startup, but none of them really explained how they tied back to `autoload`, `eval-after-load`, etc so I was trying to encourage people to dig out `macroexpand` and find out. +It's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [post about it](https://blog.markhepburn.com/posts/understanding-use-package-optimisations/). There's a few posts around suggesting features of `use-package` to optimise startup, but none of them really explained how they tied back to `autoload`, `eval-after-load`, etc so I was trying to encourage people to dig out `macroexpand` and find out. ### u/AffectionateAd8985 [🔗](https://www.reddit.com/r/emacs/comments/t3_sd10q9/comment/t1_hu9xfed) @@ -1583,7 +1583,7 @@ For example, here is a simple setup for Python which includes Pyright's type che ``` -Now all that's left is mypy. Flymake originally used a ["Proc"]() method for creating checkers which existing mypy ones use. So for a bonus tip & trick [I've written a mypy checker in the new style](). It can be enabled when using eglot like this: +Now all that's left is mypy. Flymake originally used a ["Proc"](https://www.gnu.org/software/emacs/manual/html_mono/flymake.html#The-legacy-Proc-backend) method for creating checkers which existing mypy ones use. So for a bonus tip & trick [I've written a mypy checker in the new style](http://github.com/com4/flymake-mypy). It can be enabled when using eglot like this: ```elisp (use-package flymake-mypy @@ -1854,7 +1854,7 @@ I started using `god-mode`, but I found it hard to get used to it at first: ther I wrote up a `god-mode`\­specific `describe-key`, which translates `god-mode` key-sequences into commands and shows their usual description. I think it's a great way to get familiar with how the package handles keys, and it allows users to invoke `describe-key` without leaving god-mode (previously, most keys would just show information about the generic `god-mode-self-insert-command`) -I also reached out to the package's maintainers, and this feature (after some tweaking) [just got added to the master branch](). It was a great way to get familiar with `god-mode` code and its behavior, and I'm happy to have made my first contribution to an Emacs package. +I also reached out to the package's maintainers, and this feature (after some tweaking) [just got added to the master branch](https://github.com/emacsorphanage/god-mode). It was a great way to get familiar with `god-mode` code and its behavior, and I'm happy to have made my first contribution to an Emacs package. ### u/kickingvegas1 [🔗](https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_innk62a) @@ -2044,7 +2044,7 @@ Any suggestions would be appreciated! **Votes** 9 -I've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: []() +I've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md) If you fancy procrastinating for a bit today… @@ -2145,7 +2145,7 @@ Though it's not very accurate when using `text-scale-adjust`, as line width is n \\\*\* u/attentoredaz [🔗](https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_iku77h0) \\\*Votes\* 9 -Using [zotra](), [citar]() and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with "org-biblatex bibliographies" which are basically like [org-bibtex]() but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable `#+bibliography: my-org-biblatex-file.org` declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp. +Using [zotra](https://github.com/mpedramfar/zotra), [citar](https://github.com/emacs-citar/citar) and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with "org-biblatex bibliographies" which are basically like [org-bibtex](http://gewhere.github.io/org-bibtex) but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable `#+bibliography: my-org-biblatex-file.org` declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp. ### u/luiggioasis [🔗](https://www.reddit.com/r/emacs/comments/t3_zred55/comment/t1_j14grej) @@ -2188,7 +2188,7 @@ Is there a package/piece of code out there to: 2. execute arbitrary code 3. close frame on completion -Kind of like [emacs-everywhere]() but for arbitrary code. +Kind of like [emacs-everywhere](https://github.com/tecosaur/emacs-everywhere/) but for arbitrary code. ### u/WorldsEndless [🔗](https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_inqralq) @@ -2252,22 +2252,22 @@ Pure awesomeness, thanks a lot for Magit/ Magit forge ! \\\*\* u/slinchisl [🔗](https://www.reddit.com/r/emacs/comments/t3_uxcm6i/comment/t1_i9xcaoa) \\\*Votes\* 8 -[arxiv-citation]() from my [last post]() is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)! +[arxiv-citation](https://github.com/slotthe/arxiv-citation) from my [last post](https://old.reddit.com/r/emacs/comments/ufvg93/my_phd_research_workflowemacs_inside/) is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)! -On that note, I've written a little bit about [calling Emacs from XMonad](). The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful. +On that note, I've written a little bit about [calling Emacs from XMonad](https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html). The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful. ### u/diamondnbond [🔗](https://www.reddit.com/r/emacs/comments/t3_us7zae/comment/t1_i928gaj) **Votes** 8 -[I Recently discovered engine-mode.]() +[I Recently discovered engine-mode.](https://github.com/DiamondBond/emacs/blob/master/config.org#initialize-engine-mode) \\\*\* u/mmarshall540 [🔗](https://www.reddit.com/r/emacs/comments/t3_un4wf8/comment/t1_i88sp07) \\\*Votes\* 8 Here's a little solution to a minor complaint about \`isearch\` that I think is fairly common. -TLDR: See [this old StackExchange question]() +TLDR: See [this old StackExchange question](https://emacs.stackexchange.com/questions/32373/go-to-start-of-search-string-after-ret) Often, I'll want to go to a precise location in a buffer to correct a typo. If that location is behind point (as it usually is if I notice the typo shortly after entering it), then \`isearch-backward\` works great. You press "C-r" and type some characters starting with your target until the location becomes the current result. As soon as the cursor jumps to your target location, you can use an editing command like "C-t", which exits isearch automatically for you. Or you can press "C-m" to exit isearch-mode and then start inserting text at that location. Wonderful! @@ -2321,7 +2321,7 @@ I found this one-liner yesterday, added it it to the `:config` section of ****Ev \\\*\* u/slinchisl [🔗](https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imjs86m) \\\*Votes\* 8 -I don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [rapidly capture ideas]() by using XMonad's org-mode integration! +I don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [rapidly capture ideas](https://tony-zorman.com/posts/orgmode-prompt/2022-08-27-xmonad-and-org-mode.html) by using XMonad's org-mode integration! ### u/agumonkey [🔗](https://www.reddit.com/r/emacs/comments/t3_w3gx6o/comment/t1_ih3s9fl) @@ -2339,7 +2339,7 @@ A great functionality for calculating some schedule events is \`org-evaluate-tim **Votes** 8 -I had the [defrepeater]() package for a while, but didn't realize you could use it this elegantly! +I had the [defrepeater](https://github.com/alphapapa/defrepeater.el) package for a while, but didn't realize you could use it this elegantly! ```elisp (global-set-key [remap transpose-lines] (defrepeater #'transpose-lines)) @@ -2353,7 +2353,7 @@ Something similar is actually in the readme, but I guess I glossed over it back **Votes** 8 -Just discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. []() +Just discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. [https://github.com/DamienCassou/desktop-environment](https://github.com/DamienCassou/desktop-environment) Thanks Damien ! @@ -2511,14 +2511,14 @@ Combined, this allows to extend the day past midnight, with things like agenda v **Votes** 16 -I just found out that Magit can backup changes of uncommitted files automatically. Here's the link to online manual: [Magit Wip Modes](). +I just found out that Magit can backup changes of uncommitted files automatically. Here's the link to online manual: [Magit Wip Modes](https://magit.vc/manual/magit/Wip-Modes.html#Wip-Modes). ### u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_mujxm7/comment/t1_gv8jxz5) **Votes** 16 -I use, and love, [transient](). I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to `s-w`. I use [buffer-move]() for rearranging windows in a frame. +I use, and love, [transient](https://github.com/magit/transient). I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to `s-w`. I use [buffer-move](https://github.com/lukhas/buffer-move) for rearranging windows in a frame. ```elisp (define-transient-command transient-window () @@ -2631,7 +2631,7 @@ From: **Votes** 14 -I'm slowly working on an alternative shell: []() +I'm slowly working on an alternative shell: [https://github.com/TatriX/tshell](https://github.com/TatriX/tshell) Instead of using repl-like interface, all the commands go to one buffer (and file if you want) and output goes to another buffer. Like if you put your elisp code in \\\*scratch\\\* buffer and then evaluate it with \\~C-x C-e\\~. @@ -2644,7 +2644,7 @@ Let me know what is your first impression, what can be improved and what do you **Votes** 14 -I just discovered the [selected]() package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode. +I just discovered the [selected](https://github.com/Kungsgeten/selected.el) package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode. ### u/vatai [🔗](https://www.reddit.com/r/emacs/comments/t3_ojzv53/comment/t1_h5584no) @@ -2775,7 +2775,7 @@ You can pop this up in a separate frame using: ``` -Related docs are [here](). +Related docs are [here](https://www.gnu.org/software/auctex/manual/auctex/Error-overview.html). This totally changes the way you can handle errors messages. @@ -2854,7 +2854,7 @@ One of the most useful bindings for me: **Votes** 10 -Read [SICP](). Preferably in Info, installable through MELPA or: []() +Read [SICP](https://mitpress.mit.edu/sites/default/files/sicp/index.html). Preferably in Info, installable through MELPA or: [https://github.com/webframp/sicp-info](https://github.com/webframp/sicp-info) ### u/Stefan-Kangas [🔗](https://www.reddit.com/r/emacs/comments/t3_pxqvtm/comment/t1_hexdfiq) @@ -3001,7 +3001,7 @@ Usually I switch to `foobar.hpp`, kill the necessary part, switch to `foobar.cpp **Votes** 9 -Checkout [Topsy Mode](), it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup. +Checkout [Topsy Mode](https://github.com/alphapapa/topsy.el), it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup. ### u/oantolin [🔗](https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8utmh2) @@ -3105,7 +3105,7 @@ Call it with M-x, insert the name of the function you want to declare (with comp **Votes** 8 -A colleague just showed me Intellij's "[compare with clipboard]()" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections. +A colleague just showed me Intellij's "[compare with clipboard](https://www.jetbrains.com/help/idea/comparing-files-and-folders.html#clipboard)" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections. It didn't take me long to implement something similar: @@ -3128,7 +3128,7 @@ It's not ideal though. In particular, is there a better way to insert the "clipb \\\*\* u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_pk6akd/comment/t1_hc3bikc) \\\*Votes\* 8 -I'm using [orderless]() for completion but I also want to walk through files with initials only, to do something like [like this]() for example. It only requires to ignore the case and ask the minibuffer to use initials. +I'm using [orderless](https://github.com/oantolin/orderless) for completion but I also want to walk through files with initials only, to do something like [like this](https://imgur.com/a/CJg8MGw) for example. It only requires to ignore the case and ask the minibuffer to use initials. ```elisp (use-package orderless @@ -3406,11 +3406,11 @@ Here's the code, maybe there can be a lot of improvements: \\\*\* u/poinkalum [🔗](https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8rdjx9) \\\*Votes\* 8 -If you follow master, you can use the very useful command `execute-extended-command-for-buffer` by using `M-X` (with a capital "X"), that implements the behaviour described in [this blog post by Lars](). It will only show commands that are relevant to the current major mode. +If you follow master, you can use the very useful command `execute-extended-command-for-buffer` by using `M-X` (with a capital "X"), that implements the behaviour described in [this blog post by Lars](https://lars.ingebrigtsen.no/2021/02/16/command-discovery-in-emacs/). It will only show commands that are relevant to the current major mode. \\\*\* u/slinchisl [🔗](https://www.reddit.com/r/emacs/comments/t3_pt2xws/comment/t1_hdtoivy) \\\*Votes\* 8 -I've been playing around with Emacs 28's [repeat-mode]() a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function: +I've been playing around with Emacs 28's [repeat-mode](https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp?id=12409c9064c386a496dcbdca76b790108f6c1cad) a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function: ```elisp (defmacro defrepeatmap (symbol &optional pairs docstring) @@ -3527,7 +3527,7 @@ I will make some more improvements in the coming days, so if I split the window \\\*\* u/nicholashubbard [🔗](https://www.reddit.com/r/emacs/comments/t3_rr330u/comment/t1_hqlp0en) \\\*Votes\* 8 -Here is a consult source for [perspective.el]() +Here is a consult source for [perspective.el](https://github.com/nex3/perspective-el) ```elisp (defvar consult--source-perspective @@ -3830,7 +3830,7 @@ I tend to have a lot of function that is defined solely to be added to a hook. T **Votes** 11 -I am porting my [config]() from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [MatthewZMD's config]() I think: +I am porting my [config](https://github.com/laurynas-biveinis/dotfiles) from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [MatthewZMD's config](https://github.com/MatthewZMD/.emacs.d) I think: ```elispelisp (add-hook 'focus-out-hook #'garbage-collect) @@ -4054,7 +4054,7 @@ After a while I extended org-export to get a shortcut (`C-e C-s o M`) to automat **Votes** 9 -org-variable-pitch.el users might want to give [~valign~]() a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add `org-link` to `org-variable-pitch-fixed-faces` because valign-mode handles variable pitch links neatly in tables. +org-variable-pitch.el users might want to give [`valign`](https://github.com/casouri/valign) a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add `org-link` to `org-variable-pitch-fixed-faces` because valign-mode handles variable pitch links neatly in tables. If you don't use OVP but use e.g. latex fragments in tables or just pictures, this one is still very helpful. @@ -4183,11 +4183,11 @@ I posted this in the emacsclient thread, but I think it deserves to live here as The emacsclient / server system is great. If you have it listening on tcp and port forward that when connecting to remote machine it adds another level of power. -I use [emacs-vterm]() for a terminal inside emacs, so I've got a lot of commands remapped. Like `man` runs `emacsclient ... man ..`, which opens the man page in the "other" buffer, so it doesn't interrupt my flow. I use "scroll-other-window" to navigate the man page while I still have my prompt. `magit`, `dired`, and others map to their `emacsclient` equivalents. +I use [emacs-vterm](https://github.com/akermu/emacs-libvterm) for a terminal inside emacs, so I've got a lot of commands remapped. Like `man` runs `emacsclient ... man ..`, which opens the man page in the "other" buffer, so it doesn't interrupt my flow. I use "scroll-other-window" to navigate the man page while I still have my prompt. `magit`, `dired`, and others map to their `emacsclient` equivalents. I've written wrapper script for e/emacs client that I've come to call `e`, because it saves keystrokes -\#### [The full repo is here e-emacs.sh]() +\#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/) It does the standard things you would expect, starts emacs if it's not already started, open a file in a new buffer / window / terminal and optionally wait for you to finish or have the shell continue. @@ -4199,7 +4199,7 @@ Or the poor man's blog system: `e -t header_template.html body_template.html foo See the repo for more examples and to download. The notes of getting it working on remote machines aren't the cleanest. If you have any suggestions or features that would make your life easier let me know; submit an issue or comment here. -\#### [The full repo is here e-emacs.sh]() +\#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/) `~I really should post this on one of the share your stuff posts. But I get distracted.~` There, I did it. @@ -4222,7 +4222,7 @@ Each person gets a different colour to indicate the part of the file they’re e \\\*\* u/[deleted] [🔗](https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfxbwgy) \\\*Votes\* 8 -I tried [marginalia]() with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings. +I tried [marginalia](https://github.com/minad/marginalia) with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings. ### u/martinslot [🔗](https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfwlm9q) @@ -4260,7 +4260,7 @@ When I have multiple buffers opened and I switch from another program to emacs I **Votes** 8 -Hippie-expand google search suggestions. Completely inspired from [shell-parse.el](). +Hippie-expand google search suggestions. Completely inspired from [shell-parse.el](https://github.com/malloc47/shell-parse.el/blob/master/shell-parse.el). I've added `try-expand-google-completion` to the bottom of my `hippie-expand-try-functions-list` @@ -4334,12 +4334,12 @@ The advice below quiets this warning, and inserts a dash whenever space is press **Votes** 8 -AucTex users: You're missing out if you don't use [CDLatex](). It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is always available, not just during snippet entry. It's difficult to explain, so here are some demos: +AucTex users: You're missing out if you don't use [CDLatex](https://github.com/cdominik/cdlatex). It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is always available, not just during snippet entry. It's difficult to explain, so here are some demos: -1. [Fast input with cdlatex and preview.el]() -2. [Fast input with keys displayed]() +1. [Fast input with cdlatex and preview.el](https://gfycat.com/heavenlynegligiblehoiho) +2. [Fast input with keys displayed](https://gfycat.com/safeidolizedlangur) -I wrote a longer post explaining [how I set up AucTex]() recently. +I wrote a longer post explaining [how I set up AucTex](https://www.reddit.com/r/emacs/comments/g8ecpj/advice_for_auclatex_what_keybinds_do_you_find/foo64ge/) recently. CDLaTeX was written by Carsten Dominik, the author of Org-mode and reftex. Thus Org ships with an `org-cdlatex` minor-mode that makes these features available in org-mode. @@ -4348,14 +4348,14 @@ CDLaTeX was written by Carsten Dominik, the author of Org-mode and reftex. Thus **Votes** 8 -[A beginers guide to emacs 24 or later by sasha chua](![img](https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png)) this helped me tremendously to get started with emacs. +[A beginers guide to emacs 24 or later by sasha chua](https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png) this helped me tremendously to get started with emacs. ### u/ji99 [🔗](https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqcycvb) **Votes** 8 -A rudimentary interface for the fabulous [Links web browser](): +A rudimentary interface for the fabulous [Links web browser](http://links.twibright.com/user_en.html): ```elisp (defun links-browser (&optional link new-window) diff --git a/out_by_year.org b/out_by_year.org index a1aa7b7..1fd62d8 100644 --- a/out_by_year.org +++ b/out_by_year.org @@ -1,12 +1,12 @@ #+OPTIONS: toc:nil broken-links:t -* Years +* Comments Grouped by Year :PROPERTIES: :TOC: :include all :depth 1 -:CUSTOM_ID: years +:CUSTOM_ID: comments-grouped-by-year :END: :CONTENTS: -- [[#years][Years]] +- [[#comments-grouped-by-year][Comments Grouped by Year]] - [[#2024][2024]] - [[#2023][2023]] - [[#2022][2022]] @@ -20,7 +20,7 @@ :END: *** u/SlowMovingTarget [[https://www.reddit.com/r/emacs/comments/t3_1fzmgwb/comment/t1_lr35bm5][🔗]] -*Votes* 36 +*Votes* 39 Nothing revolutionary (and veterans will already know this), but a nice little function for splitting out text to a separate file: @@ -50,8 +50,19 @@ Then if you bind ~(yas-expand-snippet (yas-lookup-snippet "namespace-surround")) https://i.redd.it/fbsbbr98smtc1.gif +*** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57][🔗]] +*Votes* 19 + +~use-package~ has an inbuilt feature that roughly reports the loading times of each package on startup ([[https://github.com/jschaf/esup][~esup~]] most likely does a better job, if you can get it to run; there are [[https://github.com/alexmurray/emacs-snap/issues/71][known issues]] on Emacs snap): + +1. put ~(setq use-package-compute-statistics t)~ at the beginning of your ~init.el~ +2. restart Emacs +3. do ~M-x use-package-report~ + +Which package is your biggest time sink and why is it worth it? Mine is [[https://github.com/vedang/pdf-tools][~pdf-tools~]], but to my knowledge there is simply no better alternative for working with pdfs in emacs. + *** u/vkazanov [[https://www.reddit.com/r/emacs/comments/t3_1bdm6mc/comment/t1_kuo1f9y][🔗]] -*Votes* 17 +*Votes* 18 A dump of my Emacs-related principles after 18 years of tinkering: @@ -67,25 +78,14 @@ A dump of my Emacs-related principles after 18 years of tinkering: I am a beginner though, things might change. -*** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gktndf/comment/t1_lvojz57][🔗]] -*Votes* 17 - -~use-package~ has an inbuilt feature that roughly reports the loading times of each package on startup ([~esup~](https://github.com/jschaf/esup) most likely does a better job, if you can get it to run; there are [known issues](https://github.com/alexmurray/emacs-snap/issues/71) on Emacs snap): - -1. put ~(setq use-package-compute-statistics t)~ at the beginning of your ~init.el~ -2. restart Emacs -3. do ~M-x use-package-report~ - -Which package is your biggest time sink and why is it worth it? Mine is [~pdf-tools~](https://github.com/vedang/pdf-tools), but to my knowledge there is simply no better alternative for working with pdfs in emacs. - *** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1fozctm/comment/t1_lpbqo0e][🔗]] *Votes* 13 -I recently got tired of constantly having to move my eyes to the bottom of Emacs, so I switched to posframes, [which moves the information in a central pop-up instead](https://blog.costan.ro/img/emacs-completion-system/switch-to.png). For me, this meant using the packages: +I recently got tired of constantly having to move my eyes to the bottom of Emacs, so I switched to posframes, [[https://blog.costan.ro/img/emacs-completion-system/switch-to.png][which moves the information in a central pop-up instead]]. For me, this meant using the packages: -\* [~vertico-posframe~](https://github.com/tumashu/vertico-posframe) - for [~vertico~](https://github.com/minad/vertico) -\* [~which-key-posframe~](https://github.com/yanghaoxie/which-key-posframe) - for [~which-key~](https://github.com/justbur/emacs-which-key) -\* [~transient-posframe~](https://github.com/yanghaoxie/transient-posframe) - for all transient commands, e.g., in [~magit~](https://github.com/magit/magit) or in [~casual-suite~](https://github.com/kickingvegas/casual-suite) +\* [[https://github.com/tumashu/vertico-posframe][~vertico-posframe~]] - for [[https://github.com/minad/vertico][~vertico~]] +\* [[https://github.com/yanghaoxie/which-key-posframe][~which-key-posframe~]] - for [[https://github.com/justbur/emacs-which-key][~which-key~]] +\* [[https://github.com/yanghaoxie/transient-posframe][~transient-posframe~]] - for all transient commands, e.g., in [[https://github.com/magit/magit][~magit~]] or in [[https://github.com/kickingvegas/casual-suite][~casual-suite~]] But regardless what you are using, chances are there already is a suitable ~*-posframe~ package for it. Installing these packages is easy: @@ -101,6 +101,11 @@ But regardless what you are using, chances are there already is a suitable ~*-po (transient-posframe-mode)) #+END_SRC +*** u/Usual_Office_1740 [[https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9][🔗]] +*Votes* 12 + +I've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again. + *** u/remillard [[https://www.reddit.com/r/emacs/comments/t3_1cbsvxd/comment/t1_l11l7he][🔗]] *Votes* 12 @@ -112,12 +117,19 @@ I suspect completion is doing a lot of heavy lifting here though too, so a perfe Anyway, I haven't popped open the Treemacs sidebar in weeks now, and just felt like I should write something in case someone was curious about how handy it was. -*** u/algor512 [[https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d][🔗]] +*** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1][🔗]] *Votes* 12 -Recently I discovered that ~C-h C-q~ (or ~M-x help-quick~) opens a small window showing \*Quick Help\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable ~help-quick-sections~. +If you use an LSP server with semantic highlighting, it's worth checking out the value of ~font-lock-maximum-decoration~. For example, I use ~c++-mode~ with ~lsp-mode~ (with clangd), I decreased ~font-lock-maximum-decoration~ to ~2~, and I didn't notice any highlighting difference (because the lost highlighting by ~c++-mode~ gets highlighted by ~lsp-mode~), while ~c++-mode~ font-locking become faster (~c++-mode~ 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone). -I intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of ~help-quick-sections~. +I use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~ + +*** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6][🔗]] +*Votes* 12 + +I have long had convenience bindings for ~org-emphasize~ like ~super-i~ for /italic/, that match system bindings. But I always wanted these to *be smarter*, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not. + +[[https://gist.github.com/jdtsmith/55e6a660dd4c0779a600ac81bf9bfc23][Check out my solution]] (scroll down to see how it acts). Will miss this behavior in other apps! *** u/mlk [[https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_lnqelw9][🔗]] *Votes* 11 @@ -146,6 +158,32 @@ I made my agenda collapsible (like org headings) by using outline-minor-mode. To (add-hook 'org-agenda-mode-hook 'my/org-agenda-fold) #+END_SRC +*** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6][🔗]] +*Votes* 11 + +I regularly work with different emacs frames on different monitors, and [[https://github.com/emacsmirror/framemove][~framemove~]] is great for switching between them. It can hook into ~windmove~ (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions: + +\* ~fm-up-frame~: move to the frame over the current frame +\* ~fm-down-frame~: move to the frame below the current frame +\* ~fm-left-frame~: move to the frame left of the current frame +\* ~fm-right-frame~: move to the frame right of the current frame + +It's not on any of the major package repositories, so you have to install it manually. Thanks to [[https://github.com/emacsmirror][~emacsmirror~]], this can for example be done as follows using ~use-package~ and ~straight~ (adjust bindings to your liking): + +#+BEGIN_SRC elisp + (use-package framemove + :straight (:host github :repo "emacsmirror/framemove") + :init + (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom + :bind + (("C-x 5 " . fm-up-frame) + ("C-x 5 " . fm-down-frame) + ("C-x 5 " . fm-left-frame) + ("C-x 5 " . fm-right-frame))) + +#+END_SRC +edit: The only thing I don't understand is why setting ~framemove-hook-into-windmove~ to ~t~ doesn't work in via ~:config~ or ~:custom~. The package is loaded, ~C-h f~ confirms that ~fm-up-frame~ exists, but ~C-h v~ doesn't know ~framemove-hook-into-windmove~. ~framemove-hook-into-windmove~ exists after I run ~fm-up-frame~, but then it's set to ~nil~ and not ~t~. + *** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_1djdync/comment/t1_l9cmdp9][🔗]] *Votes* 11 @@ -163,63 +201,78 @@ A minor annoyance was that an unwanted link to whatever file location I happened '(("d" "Done" entry (file+olp+datetree "~/org/done.org") "* %?"))) #+END_SRC -*** u/saltwaterflyguy [[https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8][🔗]] +*** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q][🔗]] *Votes* 11 -describe-\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v. - -If you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions. - -*** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_ksifwh1][🔗]] -*Votes* 11 +Not from me, but I just wanted to share /u/arthurno1 one-line tip to get ~which-key~ to work with ~dired~ (see screenshot in linked post): -If you use an LSP server with semantic highlighting, it's worth checking out the value of ~font-lock-maximum-decoration~. For example, I use ~c++-mode~ with ~lsp-mode~ (with clangd), I decreased ~font-lock-maximum-decoration~ to ~2~, and I didn't notice any highlighting difference (because the lost highlighting by ~c++-mode~ gets highlighted by ~lsp-mode~), while ~c++-mode~ font-locking become faster (~c++-mode~ 's font-locking works well 99.9% of the time, but sometimes it can become slow in some circumstances, these slowdowns seems to be gone). +https://www.reddit.com/r/emacs/comments/1clvkfe/announcing_casual_dired_an_opinionated_porcelain/l2yi5tn/ -I use:~(setq font-lock-maximum-decoration '((c-mode . 2) (c++-mode . 2) (t . t)))~ +I assume the same trick applies to other mode-maps as well. -*** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1933co6/comment/t1_khe4dq6][🔗]] +*** u/algor512 [[https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kg4ni5d][🔗]] *Votes* 11 -I have long had convenience bindings for ~org-emphasize~ like ~super-i~ for /italic/, that match system bindings. But I always wanted these to *be smarter*, i.e. do something useful when there is no text selected. Something like intelligently toggling emphasis depending on whether you were already in the right kind of emphasized text, or just emphasize the word at point if not. +Recently I discovered that ~C-h C-q~ (or ~M-x help-quick~) opens a small window showing \*Quick Help\* buffer with a nice overview of some basic keybindings. It seems that the content of this buffer is configurable via the variable ~help-quick-sections~. -[Check out my solution](https://gist.github.com/jdtsmith/55e6a660dd4c0779a600ac81bf9bfc23) (scroll down to see how it acts). Will miss this behavior in other apps! +I intend to use it as a cheatsheet, reminding me about rare keybindings I always forget; I believe it is easy to make it context-dependent, just by changing the value of ~help-quick-sections~. -*** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1f8nxb5/comment/t1_llfyzu6][🔗]] +*** u/ilemming [[https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1][🔗]] *Votes* 10 -I regularly work with different emacs frames on different monitors, and [~framemove~](https://github.com/emacsmirror/framemove) is great for switching between them. It can hook into ~windmove~ (which means switching to an adjacent window becomes switching to an adjacent frame if no such window exists) and offers the functions: +You know that you can use vars in org source blocks that inject some data, like: -\* ~fm-up-frame~: move to the frame over the current frame -\* ~fm-down-frame~: move to the frame below the current frame -\* ~fm-left-frame~: move to the frame left of the current frame -\* ~fm-right-frame~: move to the frame right of the current frame +#+BEGIN_SRC elisp + #+begin_src bash :var token="bla-bla-bla" + echo ${token} + #+end_src -It's not on any of the major package repositories, so you have to install it manually. Thanks to [~emacsmirror~](https://github.com/emacsmirror), this can for example be done as follows using ~use-package~ and ~straight~ (adjust bindings to your liking): + #+RESULTS: + : bla-bla-bla + +#+END_SRC +That can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block. #+BEGIN_SRC elisp - (use-package framemove - :straight (:host github :repo "emacsmirror/framemove") - :init - (setq framemove-hook-into-windmove t) ;; doesn't work as :config or :custom - :bind - (("C-x 5 " . fm-up-frame) - ("C-x 5 " . fm-down-frame) - ("C-x 5 " . fm-left-frame) - ("C-x 5 " . fm-right-frame))) + #+name: dirs + #+begin_src bash :results silent + ls + #+end_src + + #+begin_src js :var data=dirs + console.log(data) + #+end_src #+END_SRC -edit: The only thing I don't understand is why setting ~framemove-hook-into-windmove~ to ~t~ doesn't work in via ~:config~ or ~:custom~. The package is loaded, ~C-h f~ confirms that ~fm-up-frame~ exists, but ~C-h v~ doesn't know ~framemove-hook-into-windmove~. ~framemove-hook-into-windmove~ exists after I run ~fm-up-frame~, but then it's set to ~nil~ and not ~t~. +But did you know, you can also use elisp there? -*** u/fuzzbomb23 [[https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7][🔗]] -*Votes* 10 +#+BEGIN_SRC elisp + #+begin_src js :var data=(if (featurep :system 'macos) "🍎" "🐧") + return data; + #+end_src -One of my favourite tips for managing my init file is the ~imenu~ support in ~use-package~. It's turned off by default, though: + #+RESULTS: + : 🍎 + +#+END_SRC +Or previous-like example with dirs but without needing additional source block: #+BEGIN_SRC elisp -(setq use-package-enable-imenu-support t) +#+begin_src clojure :var data=(shell-command-to-string "ls -a ~") +;; all dotfiles +(require '[clojure.string :as str]) + +(->> (str/split data #"\n") + (filter (partial re-find #"^\.*")) + (sort) + (str/join "\n")) +#+end_src #+END_SRC -Combined with a nice imenu UI (~consult-imenu~ and Vertico, say) you can navigate your init file really quickly. +*** u/rego_b [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro][🔗]] +*Votes* 10 + +~C-x C-e~ to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal) *** u/winters_here [[https://www.reddit.com/r/emacs/comments/t3_1eaw1ia/comment/t1_leom8fv][🔗]] *Votes* 10 @@ -241,19 +294,19 @@ Useful when you include some classless css libraries which require you to add at Don't skip ~HTML_DOCTYPE~ else it will duplicate the attribute because one extra will be added due to ~xml:lang~ -*** u/Usual_Office_1740 [[https://www.reddit.com/r/emacs/comments/t3_1d371oz/comment/t1_l687lg9][🔗]] +*** u/thetemp_ [[https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy][🔗]] *Votes* 10 -I've just started to use macros. They are amazing. Here are my tips. C-x -( to start recording. C-x-) to stop recording. F4 to run last recorded macro. Always start at the beginning of a line. Always move by words or lines. If you go forward two chars and the next line needs you to go forward three chars, the macro won't work. Always return to the beginning of the line. For added awesome move down to the next line, positioning yourself to use the macro again. +I recently discovered the [[https://github.com/gonewest818/dimmer.el][Dimmer]] package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that *is* focused. And of course, you can customize how much it dims and exclude certain buffers. -*** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l33y04q][🔗]] -*Votes* 10 +I love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore. -Not from me, but I just wanted to share /u/arthurno1 one-line tip to get ~which-key~ to work with ~dired~ (see screenshot in linked post): +*** u/saltwaterflyguy [[https://www.reddit.com/r/emacs/comments/t3_1bun8ky/comment/t1_kxur0j8][🔗]] +*Votes* 10 -https://www.reddit.com/r/emacs/comments/1clvkfe/announcing_casual_dired_an_opinionated_porcelain/l2yi5tn/ +describe-\*. It is one of the most useful feature sets to access documentation for just about everything there is in Emacs. Not sure what key bindings are set for a given mode? M-x describe-mode or C-h m. Need to know what font is begin used for a certain piece of text? M-x describe-char. Need to know how a given command works? M-x describe-command or C-h x. Need to know the value of a given variable? M-x describe-variable or C-h v. -I assume the same trick applies to other mode-maps as well. +If you are new to Emacs you will get so many answers to your questions by getting to know all of the describe functions. *** u/bopboa [[https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kphrvz3][🔗]] *Votes* 10 @@ -266,6 +319,26 @@ This is how to have a beacon without installing any packages. (setq window-selection-change-functions '(pulse-line)) #+END_SRC +*** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp][🔗]] +*Votes* 10 + +Many of you probably know of this, but I found "indirect buffers" useful. + +When I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the "folding" and "narrow" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow ~C-x n s~ into different headings of the file in different windows. + +Indirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that ~C-x 4 c C-x n s~ did what I wanted. + +*** u/badmaxton [[https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp][🔗]] +*Votes* 10 + +Just added this to the ~:init~ section of my embark configuration: + +#+BEGIN_SRC elisp +(define-key minibuffer-local-map [C-tab] 'embark-select) + +#+END_SRC +This allows super-convenient marking of entries for later ~embark-all~ using control-tab, instead of having to go first through the ~embark~ menu. (By default, this key binding is mapped to ~file-cache-minibuffer-complete~, which I never use.) + *** u/camel_case_t [[https://www.reddit.com/r/emacs/comments/t3_18xebux/comment/t1_kgce54q][🔗]] *Votes* 10 @@ -291,52 +364,58 @@ I created this file and now Emacs keybindings work everywhere: #+END_SRC You can read more here: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html -*** u/rego_b [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lfskmro][🔗]] -*Votes* 9 - -~C-x C-e~ to edit current command line in bash which opens the line in emacs (maybe not emacs related but I found this recently useful when working in the terminal) - -*** u/thetemp_ [[https://www.reddit.com/r/emacs/comments/t3_1e5ctk2/comment/t1_ldsl3vy][🔗]] +*** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gfhkdg/comment/t1_lui5ao9][🔗]] *Votes* 9 -I recently discovered the [Dimmer](https://github.com/gonewest818/dimmer.el) package and can't believe I didn't try it until now. It subtly dims windows that aren't focused, just enough to draw your eyes to the window that *is* focused. And of course, you can customize how much it dims and exclude certain buffers. +I've recently discovered [[https://github.com/fuxialexander/org-pdftools][~org-pdftools~]] and it offers everything I need for annotating pdfs in emacs. I mainly use it to enhance the inbuilt function ~org-store-link~: -I love things that reduce cognitive load like this. You don't realize how much time you spent looking for little clues like a solid cursor, until you don't have to anymore. +\* mark a passage in the pdf, run ~M-x org-store-link~, and it creates a highlight in the pdf (technically an empty annotation) and copies a link to it. +\* run ~C-c C-l~ in any org-buffer, and it pastes the link and prompts you for a name. -*** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3][🔗]] -*Votes* 9 +The installation is easy, you just need to hook it into ~org-mode~: -A few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [this gist](https://gist.github.com/jdtsmith/a169362879388bc1bdf2bbb977782d4f) for the details. +#+BEGIN_SRC elisp + (use-package org-pdftools + :after (org pdf-tools) + :hook (org-mode . org-pdftools-setup-link)) -*** u/demosthenex [[https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6][🔗]] -*Votes* 9 +#+END_SRC +The only thing to keep in mind is that the highlights in the pdf are not automatically deleted, as you delete the link in the org buffer. You have to do that manually in the pdf (~C-c C-a l~ to list all highlights, ~D~ to delete). -M-x ielm Use the repl while learning elisp coding. I had no idea! +It has less features than [[https://github.com/org-noter/org-noter][~org-noter~]], but it is more flexible, which is why it suits my use-case better. Unfortunately, it has ~org-noter~ as a dependency, so you will end up loading it either way. -*** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_1aky57w/comment/t1_kpct4cp][🔗]] +*** u/fuzzbomb23 [[https://www.reddit.com/r/emacs/comments/t3_1f34tdh/comment/t1_lkrhqf7][🔗]] *Votes* 9 -Many of you probably know of this, but I found "indirect buffers" useful. +One of my favourite tips for managing my init file is the ~imenu~ support in ~use-package~. It's turned off by default, though: -When I'm in Vim, I've found it useful to sometimes split a buffer into two windows, and use code folding to view different parts of the same file in the two windows. But this doesn't work in Emacs, because the "folding" and "narrow" states of the buffer are synced between the windows in contrast to Vim. One concrete use case I had: I have a huge Org file, and wanted to narrow ~C-x n s~ into different headings of the file in different windows. +#+BEGIN_SRC elisp +(setq use-package-enable-imenu-support t) +#+END_SRC -Indirect buffers solve this. It makes two buffers for one file, and these buffers have separate settings for folding, narrowing, etc. But the buffer contents are still synced, so there's no risk of diverging file states. With default keybindings, I found that ~C-x 4 c C-x n s~ did what I wanted. +Combined with a nice imenu UI (~consult-imenu~ and Vertico, say) you can navigate your init file really quickly. -*** u/badmaxton [[https://www.reddit.com/r/emacs/comments/t3_19ec8v5/comment/t1_kjcu7vp][🔗]] +*** u/pt-guzzardo [[https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx][🔗]] *Votes* 9 -Just added this to the ~:init~ section of my embark configuration: - #+BEGIN_SRC elisp -(define-key minibuffer-local-map [C-tab] 'embark-select) +(defun copy-source-for-reddit () + (interactive) + (let ((contents (buffer-substring (point) (mark)))) + (with-temp-buffer + (insert contents) + (mark-whole-buffer) + (indent-rigidly (point) (mark) 4 t) + (mark-whole-buffer) + (kill-ring-save 0 0 t)))) #+END_SRC -This allows super-convenient marking of entries for later ~embark-all~ using control-tab, instead of having to go first through the ~embark~ menu. (By default, this key binding is mapped to ~file-cache-minibuffer-complete~, which I never use.) +A handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer. *** u/lesliesrussell [[https://www.reddit.com/r/emacs/comments/t3_198rnkj/comment/t1_kibmgv2][🔗]] *Votes* 9 -[transient map for movement](https://gist.github.com/lesliesrussell/46302d413fcf49e9717eeea57fdadcbf) +[[https://gist.github.com/lesliesrussell/46302d413fcf49e9717eeea57fdadcbf][transient map for movement]] Defines a transient keymap for movement controls and sets up a global key binding to activate this transient map. This transient map, \~my-movement-transient-map\~, includes bindings for various movement commands like moving forward or backward by a word or character and moving to the next or previous line. The \~activate-my-movement-map\~ function is defined to activate this transient map, and it is globally bound to \~C-f\~. @@ -346,92 +425,20 @@ This setup allows you to press \~C-f\~ followed by one of the specified keys (\~ ​ -This is a neat way to create a custom, modal-like interface for movement within Emacs, leveraging your Emacs Lisp skills to tailor your editing environment to your preferences. If you have any specific modifications or additional features you'd like to implement, feel free to ask! - -I didn't want to drop code in the thread so i put it in a gist - -*** u/LionyxML [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_kslwb72][🔗]] -*Votes* 9 - -A blog post regarding my own Emacs config aiming to get the same user experience on both TUI and GUI. -[https://www.rahuljuliato.com/posts/lemacs](https://www.rahuljuliato.com/posts/lemacs) - -*** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1gfhkdg/comment/t1_lui5ao9][🔗]] -*Votes* 8 - -I've recently discovered [~org-pdftools~](https://github.com/fuxialexander/org-pdftools) and it offers everything I need for annotating pdfs in emacs. I mainly use it to enhance the inbuilt function ~org-store-link~: - -\* mark a passage in the pdf, run ~M-x org-store-link~, and it creates a highlight in the pdf (technically an empty annotation) and copies a link to it. -\* run ~C-c C-l~ in any org-buffer, and it pastes the link and prompts you for a name. - -The installation is easy, you just need to hook it into ~org-mode~: - -#+BEGIN_SRC elisp - (use-package org-pdftools - :after (org pdf-tools) - :hook (org-mode . org-pdftools-setup-link)) - -#+END_SRC -The only thing to keep in mind is that the highlights in the pdf are not automatically deleted, as you delete the link in the org buffer. You have to do that manually in the pdf (~C-c C-a l~ to list all highlights, ~D~ to delete). - -It has less features than [~org-noter~](https://github.com/org-noter/org-noter), but it is more flexible, which is why it suits my use-case better. Unfortunately, it has ~org-noter~ as a dependency, so you will end up loading it either way. - -*** u/fv__ [[https://www.reddit.com/r/emacs/comments/t3_1fzmgwb/comment/t1_lr5ceqe][🔗]] -*Votes* 8 - -C-x in a transient popup shows menu to save selected options e.g., it can be used to select ~ --force-with-lease~ by default while pushing in magit (P p) - -*** u/ilemming [[https://www.reddit.com/r/emacs/comments/t3_1fjnqgy/comment/t1_ls4kmt1][🔗]] -*Votes* 8 - -You know that you can use vars in org source blocks that inject some data, like: - -#+BEGIN_SRC elisp - #+begin_src bash :var token="bla-bla-bla" - echo ${token} - #+end_src - - #+RESULTS: - : bla-bla-bla - -#+END_SRC -That can be used to pass data from one block to another, right? So if you need to calculate something based on the result of another block, you just need a named block. - -#+BEGIN_SRC elisp - #+name: dirs - #+begin_src bash :results silent - ls - #+end_src - - #+begin_src js :var data=dirs - console.log(data) - #+end_src - -#+END_SRC -But did you know, you can also use elisp there? - -#+BEGIN_SRC elisp - #+begin_src js :var data=(if (featurep :system 'macos) "🍎" "🐧") - return data; - #+end_src - - #+RESULTS: - : 🍎 +This is a neat way to create a custom, modal-like interface for movement within Emacs, leveraging your Emacs Lisp skills to tailor your editing environment to your preferences. If you have any specific modifications or additional features you'd like to implement, feel free to ask! -#+END_SRC -Or previous-like example with dirs but without needing additional source block: +I didn't want to drop code in the thread so i put it in a gist -#+BEGIN_SRC elisp -#+begin_src clojure :var data=(shell-command-to-string "ls -a ~") -;; all dotfiles -(require '[clojure.string :as str]) +*** u/LionyxML [[https://www.reddit.com/r/emacs/comments/t3_1b20xgn/comment/t1_kslwb72][🔗]] +*Votes* 9 -(->> (str/split data #"\n") - (filter (partial re-find #"^\.*")) - (sort) - (str/join "\n")) -#+end_src -#+END_SRC +A blog post regarding my own Emacs config aiming to get the same user experience on both TUI and GUI. +[[https://www.rahuljuliato.com/posts/lemacs][https://www.rahuljuliato.com/posts/lemacs]] + +*** u/fv__ [[https://www.reddit.com/r/emacs/comments/t3_1fzmgwb/comment/t1_lr5ceqe][🔗]] +*Votes* 8 + +C-x in a transient popup shows menu to save selected options e.g., it can be used to select ~ --force-with-lease~ by default while pushing in magit (P p) *** u/meedstrom [[https://www.reddit.com/r/emacs/comments/t3_1fe504e/comment/t1_lmzbyro][🔗]] *Votes* 8 @@ -460,37 +467,30 @@ Highlight regexp or strings in your buffer with =M+s h= good for analyzing logfi *** u/Motor_Mouth_ [[https://www.reddit.com/r/emacs/comments/t3_1eghspj/comment/t1_lg6q2rq][🔗]] *Votes* 8 -For users of [rg.el](https://github.com/dajva/rg.el) (emacs interface to ripgrep) there is [rga](https://github.com/phiresky/ripgrep-all) (ripgrep-all) a wrapper around ripgrep that "enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc." You can set the rg executable in the configuration of rg.el like so: ~(setq rg-executable (executable-find "rga")~ to enable search in multiple document types. +For users of [[https://github.com/dajva/rg.el][rg.el]] (emacs interface to ripgrep) there is [[https://github.com/phiresky/ripgrep-all][rga]] (ripgrep-all) a wrapper around ripgrep that "enables it to search in pdf, docx, sqlite, jpg, movie subtitles (mkv, mp4), etc." You can set the rg executable in the configuration of rg.el like so: ~(setq rg-executable (executable-find "rga")~ to enable search in multiple document types. + +*** u/JDRiverRun [[https://www.reddit.com/r/emacs/comments/t3_1de1hkf/comment/t1_l8d30q3][🔗]] +*Votes* 8 + +A few people have asked about my code to change cursor color when repeat-mode is active (i.e. while you are repeating a command). I rely on it. See [[https://gist.github.com/jdtsmith/a169362879388bc1bdf2bbb977782d4f][this gist]] for the details. *** u/AdjointFunctor [[https://www.reddit.com/r/emacs/comments/t3_1cmzd47/comment/t1_l359pqx][🔗]] *Votes* 8 I (re) discovered rectangle mode recently. Very useful when deleting lots of indents. C-x spc then make the region. https://emacsredux.com/blog/2014/01/01/a-peek-at-emacs-24-dot-4-rectangular-selection/ -*** u/pt-guzzardo [[https://www.reddit.com/r/emacs/comments/t3_1chgsxe/comment/t1_l2cv5cx][🔗]] +*** u/demosthenex [[https://www.reddit.com/r/emacs/comments/t3_1b7uj43/comment/t1_ktogga6][🔗]] *Votes* 8 -#+BEGIN_SRC elisp -(defun copy-source-for-reddit () - (interactive) - (let ((contents (buffer-substring (point) (mark)))) - (with-temp-buffer - (insert contents) - (mark-whole-buffer) - (indent-rigidly (point) (mark) 4 t) - (mark-whole-buffer) - (kill-ring-save 0 0 t)))) - -#+END_SRC -A handy little snippet for exporting code to reddit markdown. Takes the region, prepends four spaces to each line, and then copies it to the kill ring to be pasted in your browser, without modifying the original buffer. +M-x ielm Use the repl while learning elisp coding. I had no idea! *** u/Icy_Thought [[https://www.reddit.com/r/emacs/comments/t3_1aw6xkc/comment/t1_kriu3ye][🔗]] *Votes* 8 Two tricks that helped me make my workflow a lot better: -1. ~(setq process-adaptive-read-buffering nil)~ makes [EAT](https://codeberg.org/akib/emacs-eat) a lot quicker! -2. ~(setq eglot-events-buffer-size 0)~, ~(fset #'jsonrpc--log-event #'ignore)~ and [eglot-booster](https://github.com/jdtsmith/eglot-booster) makes eglot A LOT quicker! +1. ~(setq process-adaptive-read-buffering nil)~ makes [[https://codeberg.org/akib/emacs-eat][EAT]] a lot quicker! +2. ~(setq eglot-events-buffer-size 0)~, ~(fset #'jsonrpc--log-event #'ignore)~ and [[https://github.com/jdtsmith/eglot-booster][eglot-booster]] makes eglot A LOT quicker! *** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_1afd05g/comment/t1_kob6a5m][🔗]] *Votes* 8 @@ -515,7 +515,7 @@ I use this often when working on large files. You can bookmark up to 9 places in It works like this: ~C-c 0~ creates a bookmark and ~C-c <1-9>~ jumps into a bookmark. I've written about this on my old blog. I still use this from time to time. -[Faster buffer bookmarking in Emacs](https://jcubic.wordpress.com/2012/01/25/faster-buffer-bookmarking-in-emacs/). +[[https://jcubic.wordpress.com/2012/01/25/faster-buffer-bookmarking-in-emacs/][Faster buffer bookmarking in Emacs]]. *** u/ImJustPassinBy [[https://www.reddit.com/r/emacs/comments/t3_1c64gcj/comment/t1_l01n03t][🔗]] *Votes* 8 @@ -528,7 +528,7 @@ Just found out about the variable ~confirm-kill-emacs~. Never again will I quit :END: *** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_10qo7vb/comment/t1_j6rmvvf][🔗]] -*Votes* 32 +*Votes* 31 When you have an active region, ~undo~ will only undo changes in that region instead of the whole file. @@ -537,15 +537,6 @@ When you have an active region, ~undo~ will only undo changes in that region ins With an active region, you can freely toggle between rectangle mark mode and normal, you don't need to get rid of your active region to switch between the two. -*** u/AndreaSomePostfix [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh][🔗]] -*Votes* 19 - -org-mode is amazing! - -I discovered \~org-copy-visible\~ the other day, when I wanted to send somebody only the outline of my notes. - -That function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful! - *** u/WorldsEndless [[https://www.reddit.com/r/emacs/comments/t3_12rlq4a/comment/t1_jgwlxuw][🔗]] *Votes* 18 @@ -558,6 +549,15 @@ I'm a big user of ~ffap~. I use this function with ~M-x~ each time I want to ope But this week I discovered ~ffap-bindings~. This function replaces some key bindings to use ~ffap~ when it makes sense. For example, it replaces ~find-file~ with ~find-file-at-point~, so the usual keybindings are enriched at no cost. +*** u/AndreaSomePostfix [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf167qh][🔗]] +*Votes* 18 + +org-mode is amazing! + +I discovered \~org-copy-visible\~ the other day, when I wanted to send somebody only the outline of my notes. + +That function (which is bound to C-c C-x v by default) let you copy just the outline for the selected region: very useful! + *** u/WorldsEndless [[https://www.reddit.com/r/emacs/comments/t3_1758wua/comment/t1_k4g09iw][🔗]] *Votes* 16 @@ -578,9 +578,22 @@ From ~consult-grep~ documentation, command line options can be passed to grep, s #+END_SRC I have just discovered this, and it made my day. -*** u/leothrix [[https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z][🔗]] +*** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc][🔗]] *Votes* 14 +Plain old ~query-replace~ has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain ~y~/~n~: + +~!~: replaces all remaning matches + +~u~: undo last replacement + +~E~: changes replacement string on the fly + +And many more you can see using ~?~. + +*** u/leothrix [[https://www.reddit.com/r/emacs/comments/t3_13jvhp7/comment/t1_jl5zu6z][🔗]] +*Votes* 13 + For ~use-package~ users (which I assume is many of us), did you know that profiling is easy to do? I'm not talking about ~esup~, but a built-in capability that makes it very straightforward to find places to optimize your ~init.el~ for significantly faster start times. Enable ~use-package-compute-statistics~ right after you load ~use-package~: @@ -592,7 +605,7 @@ Enable ~use-package-compute-statistics~ right after you load ~use-package~: Restart emacs, and then invoke ~use-package-report~. You'll get a table of the load times for each package that ~use-package~ manages. I discovered this and found an immediate way to cut my startup time in half by fixing a few packages that weren't deferred properly by adding the right ~:hook~ keyword. *** u/geza42 [[https://www.reddit.com/r/emacs/comments/t3_11lqkbo/comment/t1_jbe06qv][🔗]] -*Votes* 14 +*Votes* 13 You can toggle vertico's height between 15 and "almost full frame" with this. When vertico is invoked, it will always have a height of 15. But if you have a lot of matches, and like to have a better overview, press the binding, and vertico will show a full frame of matches. This is useful for example when ~consult-buffer~ presents a lot of buffers. @@ -630,29 +643,16 @@ Another useful feature is to kill buffers in ~consult-buffer~ without manually i I'm not sure whether these two can be achieved out-of-the box, but I didn't find these functionalities, so I created them. *** u/ayy_ess [[https://www.reddit.com/r/emacs/comments/t3_18hc301/comment/t1_kdobd72][🔗]] -*Votes* 13 +*Votes* 12 I recently discovered ~(setq read-minibuffer-restore-windows nil)~ which resolves my frustration that quitting the minibuffer would discard any changes to the window layout while the minibuffer was open. For example, by default, ~M-x C-h k k C-g~ quits the just opened help buffer. I'm sure to have missed many more QOL improvements from NEWS. -*** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jc9t4tc][🔗]] -*Votes* 13 - -Plain old ~query-replace~ has many cool features, first of all it respects the active region (if it's active it will only query for replacements in the active region). There are many useful keys in addition to plain ~y~/~n~: - -~!~: replaces all remaning matches - -~u~: undo last replacement - -~E~: changes replacement string on the fly - -And many more you can see using ~?~. - *** u/eleven_cupfuls [[https://www.reddit.com/r/emacs/comments/t3_10ktqj0/comment/t1_j5umed8][🔗]] *Votes* 12 I jump into the built-in Elisp files a lot to see how things work. The indentation there is GNU standard, which uses a mix of tabs and spaces for alignment. The tabs have to be rendered as 8 spaces wide for the alignment to work, and I don't actually want that setting anywhere else. Since the files on Mac are inside the application bundle, I don't want to just add a .dir-locals.el file next to them, either. -[Directory classes](https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html) to the rescue! My config makes a new directory variable class, ~builtin-elisp~, with a list saying that ~emacs-lisp-mode~ should use a ~tab-width~ of 8. Then it applies that class to the Elisp files in the application bundle: +[[https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html][Directory classes]] to the rescue! My config makes a new directory variable class, ~builtin-elisp~, with a list saying that ~emacs-lisp-mode~ should use a ~tab-width~ of 8. Then it applies that class to the Elisp files in the application bundle: #+BEGIN_SRC elisp (use-package elisp-mode @@ -667,8 +667,21 @@ I jump into the built-in Elisp files a lot to see how things work. The indentati #+END_SRC And now when I visit one of those files, the alignment is always correct. +*** u/leothrix [[https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8dlt4c][🔗]] +*Votes* 10 + +Need to remove an element from a list when you're tinkering with elisp? + +Sometimes when I'm adding and removing elements from hooks or variables like ~completion-at-point-functions~ I'll often need to tinker with the symbols I've added. You could evaluate some form somewhere, but I like to be lazy and just: + +#+BEGIN_SRC elisp +M-x remove-hook + +#+END_SRC +And you've got an interactive interface (using ~completing-read~) for removing arbitrary elements from any list-like variable. It's _technically_ for altering hooks, but you can abuse it to fool around with lists, too. + *** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_15sjm3k/comment/t1_jwff8bw][🔗]] -*Votes* 11 +*Votes* 10 I've been slowly accumulating cases for "flexing" the thing at point as a more general ~capitalize-word~ replacement: @@ -704,39 +717,29 @@ E.g. capitalize or decapitalize the next word, increment number at point." #+END_SRC I bind it to ~M-c~. -*** u/leothrix [[https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8dlt4c][🔗]] +*** u/gusbrs [[https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts][🔗]] *Votes* 10 -Need to remove an element from a list when you're tinkering with elisp? - -Sometimes when I'm adding and removing elements from hooks or variables like ~completion-at-point-functions~ I'll often need to tinker with the symbols I've added. You could evaluate some form somewhere, but I like to be lazy and just: - -#+BEGIN_SRC elisp -M-x remove-hook - -#+END_SRC -And you've got an interactive interface (using ~completing-read~) for removing arbitrary elements from any list-like variable. It's _technically_ for altering hooks, but you can abuse it to fool around with lists, too. +I was converting some old ~.odt~ notes files to ~.org~ today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: ~repunctuate-sentences~. I have no idea if this is new or has always been there. It is new to me. It uses ~query-replace-regexp~, so it's the same experience. And also can be configured for exclusions with ~repunctuate-sentences-filter~. Neat! -*** u/frosch03 [[https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a][🔗]] +*** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv][🔗]] *Votes* 10 -Very useful, but I keep forgetting it: - -If you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: ~C-x -~ - -And if you want to balance these two buffers again just use ~C-x +~ +I work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice: -*** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz][🔗]] -*Votes* 10 +#+BEGIN_SRC elisp +(defun default-to-main-project (dir) + (or dir *main-project-dir*)) -Put the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press) +(advice-add 'projectile-ensure-project :override #'default-to-main-project) -Win - Alt - Ctrl - Space - Ctrl - Alt - Win +#+END_SRC +I lose some of the functionality of ~projectile-ensure-project~, but I never used it anyway. *** u/AnugNef4 [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_ja41lso][🔗]] *Votes* 10 -How I got my Info Directory node ~C-h i~ to display all my installed .info files living under ~/opt/homebrew~ on an M1 Mac. I run emacs-plus@29 from [d12frosted on github](https://github.com/d12frosted/homebrew-emacs-plus). +How I got my Info Directory node ~C-h i~ to display all my installed .info files living under ~/opt/homebrew~ on an M1 Mac. I run emacs-plus@29 from [[https://github.com/d12frosted/homebrew-emacs-plus][d12frosted on github]]. init.el snippet @@ -773,20 +776,10 @@ Do you want a key binding to wrap the selection in some kind of delimiter? Here' #+END_SRC This setups up ~C-S-w~ to be a prefix map, ~insert-pair-map~. The only key binding in ~insert-pair-map~ is for ~[t]~, which means it is the default key binding and any key after the prefix will run the same command: ~insert-pair~. Now, ~insert-pair~ looks at which key was used to invoke it and if it is an opening delimiter it inserts both it and the corresponding closing delimiter (and if the region is active it insert the opening delimiter at the start and the closing delimiter at the end, wrapping the region). -*** u/Netherus [[https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7][🔗]] -*Votes* 9 - -Just recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me. - -*** u/gusbrs [[https://www.reddit.com/r/emacs/comments/t3_14l3jn8/comment/t1_jpwn2ts][🔗]] -*Votes* 9 - -I was converting some old ~.odt~ notes files to ~.org~ today, and one of the things I wanted to do was to add two spaces after end of sentence periods for proper sentence navigation. So there I was figuring out a general enough regexp for the nth time and, of course, I regretted not having taken note of this the last time. So I decided to do some searching for a good regexp and write it down this time, since this was obviously shared by someone somewhere. And it turns out Emacs has us covered, and I never knew: ~repunctuate-sentences~. I have no idea if this is new or has always been there. It is new to me. It uses ~query-replace-regexp~, so it's the same experience. And also can be configured for exclusions with ~repunctuate-sentences-filter~. Neat! - *** u/BunnyLushington [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhrzybp][🔗]] *Votes* 9 -I found myself debugging [JWTs](https://jwt.io) earlier this week and whomped up a little function to decode them from a region into a help buffer. +I found myself debugging [[https://jwt.io][JWTs]] earlier this week and whomped up a little function to decode them from a region into a help buffer. #+BEGIN_SRC elisp (defun ii/decode-jwt (start end &optional jwt) @@ -811,22 +804,61 @@ I'd forgotten about ~with-output-to-temp-buffer~ which is pretty handy. The ~t~ (This should be obvious but note that the JWT is not validated or verified. This is intended for debugging only and the JWT should not be trusted.) -*** u/sauntcartas [[https://www.reddit.com/r/emacs/comments/t3_12cd23k/comment/t1_jf3ohpv][🔗]] +*** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mo1bz][🔗]] *Votes* 9 -I work with multiple Git repositories in my day job, but one in particular occupies 95% of my time. I've often wished I could set up Projectile so that if I run one of its commands while not in any repo, it will behave as if I'd changed to that main repo first. I couldn't find a built-in way to do that, but got the effect I wanted with some advice: +Put the control keys next to space, mimicking mac's command key (which is effectively used as the equivalent of ctrl yet next to the space it's easier to press) -#+BEGIN_SRC elisp -(defun default-to-main-project (dir) - (or dir *main-project-dir*)) +Win - Alt - Ctrl - Space - Ctrl - Alt - Win -(advice-add 'projectile-ensure-project :override #'default-to-main-project) +*** u/pathemata [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mpo5y][🔗]] +*Votes* 9 +Does anyone have an ~aspell~ setup with multiple dictionaries? + +When I try ~--extra-dict~ option I get an error: ~Expected language "en" but got "de"~. + +*** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_18mplfa/comment/t1_ke5xr5j][🔗]] +*Votes* 8 + +This makes stack-outputs of debug-buffers much more readable: + +#+BEGIN_SRC elisp +(setopt debugger-stack-frame-as-list t) #+END_SRC -I lose some of the functionality of ~projectile-ensure-project~, but I never used it anyway. + +*** u/vjgoh [[https://www.reddit.com/r/emacs/comments/t3_18149ql/comment/t1_kahspwz][🔗]] +*Votes* 8 + +I used to have a problem where eglot would decide that many mid-hierarchy directories were the project root and spin up a separate instance of clangd for each one (sometimes 10 or 12 total). This was almost certainly due to using emacs' built-in ~project~ to handle project discovery. At that point, I switched to lsp-mode because I generally find ~project~ to be impenetrable and poorly documented compared to projectile. + +I was forced to go back to eglot, however, because lsp-mode has been failing to parse things well for a while. + +Long story short, here's how you force ~project~ to find the actual project root if the automatic detection doesn't work. With this, eglot started working great, didn't spin up 10 instances of clangd, and has generally been ticking over just fine. + +~(setq project-vc-extra-root-markers '(".project.el" ".projectile" ".dir-locals.el"))~ + +*** u/Netherus [[https://www.reddit.com/r/emacs/comments/t3_17qh1hn/comment/t1_k8c4mz7][🔗]] +*Votes* 8 + +Just recently found out M-u makes the next word upper case, and the same for M-l for lower case. Maybe nothing fancy, but it's kinda handy for me. + +*** u/AP145 [[https://www.reddit.com/r/emacs/comments/t3_16hh7u4/comment/t1_k1803gl][🔗]] +*Votes* 8 + +I used to always get confused why people say that the default Emacs key bindings hurt their pinky's, but then I realized that I don't touch type and thus I don't have to stretch my fingers anywhere for the default key bindings. Ironically my ineptitude at typing has saved me from repetitive stress injuries. + +*** u/frosch03 [[https://www.reddit.com/r/emacs/comments/t3_15yxdz3/comment/t1_jxekm3a][🔗]] +*Votes* 8 + +Very useful, but I keep forgetting it: + +If you have two buffers open in one frame, where one contains just a few lines and otherwise just uses up a lot of space, you can shrink that buffer down just right by using: ~C-x -~ + +And if you want to balance these two buffers again just use ~C-x +~ *** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_11rq2gl/comment/t1_jca66k0][🔗]] -*Votes* 9 +*Votes* 8 I'm once again reminded of the utility of ~read-key~ for small functions where one wants a nicer interface for choosing an alternative than universal arguments; taking an optional prompt, it simply reads a key from the keyboard and returns it. @@ -850,15 +882,20 @@ For example, I recently wanted a function that prints a set of predefined dates insert))) #+END_SRC -*** u/pathemata [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8mpo5y][🔗]] -*Votes* 9 +*** u/w0ntfix [[https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_jajfxc9][🔗]] +*Votes* 8 -Does anyone have an ~aspell~ setup with multiple dictionaries? +turning off org-elements cache speeds up input latency for me (found from profiling): -When I try ~--extra-dict~ option I get an error: ~Expected language "en" but got "de"~. +#+BEGIN_SRC elisp +(setq org-element-use-cache nil) + + +#+END_SRC +it seems (at least on my org 9.6.1) to update the cache after calls to ~org-self-insert-command~ (so, a lot!) *** u/SlowValue [[https://www.reddit.com/r/emacs/comments/t3_112t0uo/comment/t1_j8u1ebf][🔗]] -*Votes* 9 +*Votes* 8 I put a couple of similar functions on my ~~ key (with all combinations of modifier keys) and tend to forget the meanings of those combinations. @@ -904,43 +941,6 @@ Then calling the command ~my-show-help-on-some-keys~, shows following message in #+END_SRC Remark: I know that ~which-key~ exists, but I'm already above that level of knowledge and don't need ~which-key~ anymore. -*** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_18mplfa/comment/t1_ke5xr5j][🔗]] -*Votes* 8 - -This makes stack-outputs of debug-buffers much more readable: - -#+BEGIN_SRC elisp -(setopt debugger-stack-frame-as-list t) -#+END_SRC - -*** u/vjgoh [[https://www.reddit.com/r/emacs/comments/t3_18149ql/comment/t1_kahspwz][🔗]] -*Votes* 8 - -I used to have a problem where eglot would decide that many mid-hierarchy directories were the project root and spin up a separate instance of clangd for each one (sometimes 10 or 12 total). This was almost certainly due to using emacs' built-in ~project~ to handle project discovery. At that point, I switched to lsp-mode because I generally find ~project~ to be impenetrable and poorly documented compared to projectile. - -I was forced to go back to eglot, however, because lsp-mode has been failing to parse things well for a while. - -Long story short, here's how you force ~project~ to find the actual project root if the automatic detection doesn't work. With this, eglot started working great, didn't spin up 10 instances of clangd, and has generally been ticking over just fine. - -~(setq project-vc-extra-root-markers '(".project.el" ".projectile" ".dir-locals.el"))~ - -*** u/AP145 [[https://www.reddit.com/r/emacs/comments/t3_16hh7u4/comment/t1_k1803gl][🔗]] -*Votes* 8 - -I used to always get confused why people say that the default Emacs key bindings hurt their pinky's, but then I realized that I don't touch type and thus I don't have to stretch my fingers anywhere for the default key bindings. Ironically my ineptitude at typing has saved me from repetitive stress injuries. - -*** u/w0ntfix [[https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_jajfxc9][🔗]] -*Votes* 8 - -turning off org-elements cache speeds up input latency for me (found from profiling): - -#+BEGIN_SRC elisp -(setq org-element-use-cache nil) - - -#+END_SRC -it seems (at least on my org 9.6.1) to update the cache after calls to ~org-self-insert-command~ (so, a lot!) - *** u/Nondv [[https://www.reddit.com/r/emacs/comments/t3_108zin2/comment/t1_j4ct1y1][🔗]] *Votes* 8 @@ -994,7 +994,7 @@ So the flow is: *** u/swhalemwo [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhtis87][🔗]] *Votes* 8 -recently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [generate org macros from my ~R~ script](https://emacs.stackexchange.com/questions/14647/use-code-variable-in-org-mode-continuous-text), [display their values rather than the macro text](https://notes.alexkehayias.com/emacs-inline-macro-in-the-buffer/), and pass ~org-macro-templates~ to ~consult--read~ to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on! +recently started writing a report with a lot of numbers, many of which will change in later versions. I wanted to save myself the work of updating them all by hand, so I learned that I can [[https://emacs.stackexchange.com/questions/14647/use-code-variable-in-org-mode-continuous-text][generate org macros from my ~R~ script]], [[https://notes.alexkehayias.com/emacs-inline-macro-in-the-buffer/][display their values rather than the macro text]], and pass ~org-macro-templates~ to ~consult--read~ to select and insert them with a few keystrokes. took me a couple of hours but hopefully will save them later on! *** u/sebasTEEan [[https://www.reddit.com/r/emacs/comments/t3_12zaqju/comment/t1_jhwipv8][🔗]] *Votes* 8 @@ -1053,7 +1053,7 @@ In a presentation this morning, I wanted to show a file, but it contained sensit *** u/AffectionateAd8985 [[https://www.reddit.com/r/emacs/comments/t3_17vp0o1/comment/t1_k9g3i9s][🔗]] *Votes* 8 -In eshell, ~cd =xxx~ behaves like ~z xxx~ in [zoxide](https://github.com/ajeetdsouza/zoxide), jump to recent directory matching ~xxx~ pattern. +In eshell, ~cd =xxx~ behaves like ~z xxx~ in [[https://github.com/ajeetdsouza/zoxide][zoxide]], jump to recent directory matching ~xxx~ pattern. *** u/desquared [[https://www.reddit.com/r/emacs/comments/t3_11ey9ft/comment/t1_janipaz][🔗]] *Votes* 8 @@ -1085,7 +1085,7 @@ To get the link target -- the note, the abbreviation, and so on -- to display in *** u/elimik31 [[https://www.reddit.com/r/emacs/comments/t3_118sowc/comment/t1_j9jgfhg][🔗]] *Votes* 8 -The [texdoc](https://github.com/TeX-Live/texdoc/wiki/Tab-completion) CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the ~TeX-documentation-texdoc~ command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [tab-completion](https://github.com/TeX-Live/texdoc/wiki/Tab-completion), which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with ~completing-read~ and ~call-process~ to call the terminal command I created my own ~my-texdoc~ command with interactive candidate selection. It's available as [github gist here](https://gist.github.com/meliache/e645bf50c6aeac8e6e58b92c6bddac20), but I can also paste the code: +The [[https://github.com/TeX-Live/texdoc/wiki/Tab-completion][texdoc]] CLI program provided by TeXLive allows opening the documentation of LaTeX packages given a package name as its argument (requires having the documentation installed locally). It is available from AUCTeX via the ~TeX-documentation-texdoc~ command, which I find useful. However, it requires typing out the package name by hand (though it uses symbol-at-point as the default). Recently I found that the texdoc wiki contains a snippet how to add [[https://github.com/TeX-Live/texdoc/wiki/Tab-completion][tab-completion]], which showed me where to get a list of installed TeXLive package names. I ported this to emacs lisp, and combined with ~completing-read~ and ~call-process~ to call the terminal command I created my own ~my-texdoc~ command with interactive candidate selection. It's available as [[https://gist.github.com/meliache/e645bf50c6aeac8e6e58b92c6bddac20][github gist here]], but I can also paste the code: #+BEGIN_SRC elisp (defun my-texdoc--get-package-list () @@ -1244,7 +1244,7 @@ I just learned that in eshell, $$ is replaced with the output from the last comm *** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imi3kzz][🔗]] *Votes* 20 -Update from a couple of weeks ago: after some grinding, I've set the parsing of past comments from this thread to auto update on a weekly basis here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md) +Update from a couple of weeks ago: after some grinding, I've set the parsing of past comments from this thread to auto update on a weekly basis here: [[https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md][https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md]] I've also fixed the broken highlighting of some code snippets, and hopefully parsed all past threads. There's 200+ comments there (sorted by upvotes), so ctrl-f ing e.g. \~magit\~ may help you if you're looking for something specific @@ -1307,7 +1307,7 @@ Easy peasy! *** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_v2by7z/comment/t1_iauyzbl][🔗]] *Votes* 17 -It's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [post about it](https://blog.markhepburn.com/posts/understanding-use-package-optimisations/). There's a few posts around suggesting features of ~use-package~ to optimise startup, but none of them really explained how they tied back to ~autoload~, ~eval-after-load~, etc so I was trying to encourage people to dig out ~macroexpand~ and find out. +It's not worth a separate post, but after spending some pleasant yak-shaving time optimising my startup using use-package, I wrote a [[https://blog.markhepburn.com/posts/understanding-use-package-optimisations/][post about it]]. There's a few posts around suggesting features of ~use-package~ to optimise startup, but none of them really explained how they tied back to ~autoload~, ~eval-after-load~, etc so I was trying to encourage people to dig out ~macroexpand~ and find out. *** u/AffectionateAd8985 [[https://www.reddit.com/r/emacs/comments/t3_sd10q9/comment/t1_hu9xfed][🔗]] *Votes* 17 @@ -1392,7 +1392,7 @@ For example, here is a simple setup for Python which includes Pyright's type che ~(python-mode "pyright-langserver" "-w" "--stdio"))) #+END_SRC -Now all that's left is mypy. Flymake originally used a ["Proc"](https://www.gnu.org/software/emacs/manual/html_mono/flymake.html#The-legacy-Proc-backend) method for creating checkers which existing mypy ones use. So for a bonus tip & trick [I've written a mypy checker in the new style](http://github.com/com4/flymake-mypy). It can be enabled when using eglot like this: +Now all that's left is mypy. Flymake originally used a [[https://www.gnu.org/software/emacs/manual/html_mono/flymake.html#The-legacy-Proc-backend]["Proc"]] method for creating checkers which existing mypy ones use. So for a bonus tip & trick [[http://github.com/com4/flymake-mypy][I've written a mypy checker in the new style]]. It can be enabled when using eglot like this: #+BEGIN_SRC elisp (use-package flymake-mypy @@ -1648,7 +1648,7 @@ I started using ~god-mode~, but I found it hard to get used to it at first: ther I wrote up a ~god-mode~\-specific ~describe-key~, which translates ~god-mode~ key-sequences into commands and shows their usual description. I think it's a great way to get familiar with how the package handles keys, and it allows users to invoke ~describe-key~ without leaving god-mode (previously, most keys would just show information about the generic ~god-mode-self-insert-command~) -I also reached out to the package's maintainers, and this feature (after some tweaking) [just got added to the master branch](https://github.com/emacsorphanage/god-mode). It was a great way to get familiar with ~god-mode~ code and its behavior, and I'm happy to have made my first contribution to an Emacs package. +I also reached out to the package's maintainers, and this feature (after some tweaking) [[https://github.com/emacsorphanage/god-mode][just got added to the master branch]]. It was a great way to get familiar with ~god-mode~ code and its behavior, and I'm happy to have made my first contribution to an Emacs package. *** u/kickingvegas1 [[https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_innk62a][🔗]] *Votes* 10 @@ -1819,7 +1819,7 @@ Any suggestions would be appreciated! *** u/PriorOutcome [[https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_ikrx30z][🔗]] *Votes* 9 -I've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: [https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md](https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md) +I've parsed and prettified some of the comments (I think I'm missing some, but hopefully should be fixed soonish) from past weekly tips and tricks thread here: [[https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md][https://github.com/LaurenceWarne/reddit-emacs-tips-n-tricks/blob/master/out.md]] If you fancy procrastinating for a bit today... @@ -1916,7 +1916,7 @@ Though it's not very accurate when using ~text-scale-adjust~, as line width is n \** u/attento_redaz [[https://www.reddit.com/r/emacs/comments/t3_wqjare/comment/t1_iku77h0][🔗]] \*Votes* 9 -Using [zotra](https://github.com/mpedramfar/zotra), [citar](https://github.com/emacs-citar/citar) and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with "org-biblatex bibliographies" which are basically like [org-bibtex](http://gewhere.github.io/org-bibtex) but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable ~#+bibliography: my-org-biblatex-file.org~ declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp. +Using [[https://github.com/mpedramfar/zotra][zotra]], [[https://github.com/emacs-citar/citar][citar]] and some parts of the Org-cite ecosystem I hacked together a highly experimental but pretty comfortable environment for working with "org-biblatex bibliographies" which are basically like [[http://gewhere.github.io/org-bibtex][org-bibtex]] but with biblatex entries represented as headings with suitable properties instead of bibtex. I have a function which retrieves a biblatex entry corresponding to an url using zotra and adds a corresponding Org heading with the biblatex fields as properties, and the entry becomes available in Citar as soon as I save the document. Citing these entries then works anywhere, even in the same document with a suitable ~#+bibliography: my-org-biblatex-file.org~ declaration. Exporting the citations also works with the CSL exporter, no conversion is necessary to a proper biblatex bibliography file (but can be easily done if one needs biblatex-based export). Since the bibliography is an Org document, tagging, agenda commands, column view etc. can all be used with the bibliography entries. In a way it's frightening how much can be achieved building on already existing stuff and with a few lines of Emacs Lisp. *** u/luiggi_oasis [[https://www.reddit.com/r/emacs/comments/t3_zred55/comment/t1_j14grej][🔗]] *Votes* 8 @@ -1955,7 +1955,7 @@ Is there a package/piece of code out there to: 2. execute arbitrary code 3. close frame on completion -Kind of like [emacs-everywhere](https://github.com/tecosaur/emacs-everywhere/) but for arbitrary code. +Kind of like [[https://github.com/tecosaur/emacs-everywhere/][emacs-everywhere]] but for arbitrary code. *** u/WorldsEndless [[https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_inqralq][🔗]] *Votes* 8 @@ -2013,14 +2013,14 @@ Pure awesomeness, thanks a lot for Magit/ Magit forge ! \** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_uxcm6i/comment/t1_i9xcaoa][🔗]] \*Votes* 8 -[arxiv-citation](https://github.com/slotthe/arxiv-citation) from my [last post](https://old.reddit.com/r/emacs/comments/ufvg93/my_phd_research_workflowemacs_inside/) is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)! +[[https://github.com/slotthe/arxiv-citation][arxiv-citation]] from my [[https://old.reddit.com/r/emacs/comments/ufvg93/my_phd_research_workflowemacs_inside/][last post]] is now on MELPA! Give it a spin if you're in the habit of downloading or citing papers from the arXiv (if you're doing maths, these citations will even become actual journal citations, if possible)! -On that note, I've written a little bit about [calling Emacs from XMonad](https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html). The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful. +On that note, I've written a little bit about [[https://tony-zorman.com/posts/2022-05-25-calling-emacs-from-xmonad.html][calling Emacs from XMonad]]. The post itself isn't really Emacs related and so I don't think it warrants a crosspost in this subreddit, but I figured perhaps there was the odd XMonad user here who may find it helpful. *** u/diamondnbond [[https://www.reddit.com/r/emacs/comments/t3_us7zae/comment/t1_i928gaj][🔗]] *Votes* 8 -[I Recently discovered engine-mode.](https://github.com/DiamondBond/emacs/blob/master/config.org#initialize-engine-mode) +[[https://github.com/DiamondBond/emacs/blob/master/config.org#initialize-engine-mode][I Recently discovered engine-mode.]] \** u/mmarshall540 [[https://www.reddit.com/r/emacs/comments/t3_un4wf8/comment/t1_i88sp07][🔗]] \*Votes* 8 @@ -2029,7 +2029,7 @@ Here's a little solution to a minor complaint about `isearch` that I think is fa # The Problem -TLDR: See [this old StackExchange question](https://emacs.stackexchange.com/questions/32373/go-to-start-of-search-string-after-ret) +TLDR: See [[https://emacs.stackexchange.com/questions/32373/go-to-start-of-search-string-after-ret][this old StackExchange question]] Often, I'll want to go to a precise location in a buffer to correct a typo. If that location is behind point (as it usually is if I notice the typo shortly after entering it), then `isearch-backward` works great. You press "C-r" and type some characters starting with your target until the location becomes the current result. As soon as the cursor jumps to your target location, you can use an editing command like "C-t", which exits isearch automatically for you. Or you can press "C-m" to exit isearch-mode and then start inserting text at that location. Wonderful! @@ -2084,7 +2084,7 @@ Now I can undo in selected region. Like magic. \** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_x27yc9/comment/t1_imjs86m][🔗]] \*Votes* 8 -I don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [rapidly capture ideas](https://tony-zorman.com/posts/orgmode-prompt/2022-08-27-xmonad-and-org-mode.html) by using XMonad's org-mode integration! +I don't think this is worth it as a top-level post, since it's more geared towards XMonad users who also happen to use Emacs, but at least a few folks here might appreciate how easy it is to [[https://tony-zorman.com/posts/orgmode-prompt/2022-08-27-xmonad-and-org-mode.html][rapidly capture ideas]] by using XMonad's org-mode integration! *** u/agumonkey [[https://www.reddit.com/r/emacs/comments/t3_w3gx6o/comment/t1_ih3s9fl][🔗]] *Votes* 8 @@ -2099,7 +2099,7 @@ A great functionality for calculating some schedule events is `org-evaluate-time *** u/meedstrom [[https://www.reddit.com/r/emacs/comments/t3_ydsjfy/comment/t1_itwo67r][🔗]] *Votes* 8 -I had the [defrepeater](https://github.com/alphapapa/defrepeater.el) package for a while, but didn't realize you could use it this elegantly! +I had the [[https://github.com/alphapapa/defrepeater.el][defrepeater]] package for a while, but didn't realize you could use it this elegantly! #+BEGIN_SRC elisp (global-set-key [remap transpose-lines] (defrepeater #'transpose-lines)) @@ -2110,7 +2110,7 @@ Something similar is actually in the readme, but I guess I glossed over it back *** u/khourhin [[https://www.reddit.com/r/emacs/comments/t3_x7zfs2/comment/t1_inp54pm][🔗]] *Votes* 8 -Just discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. [https://github.com/DamienCassou/desktop-environment](https://github.com/DamienCassou/desktop-environment) +Just discovered 'desktop-environment-mode', really useful, particularly if you are using EXWM and want to get back functional standard keys. [[https://github.com/DamienCassou/desktop-environment][https://github.com/DamienCassou/desktop-environment]] Thanks Damien ! @@ -2267,12 +2267,12 @@ Combined, this allows to extend the day past midnight, with things like agenda v *Votes* 16 I just found out that Magit can backup changes of uncommitted files automatically. Here's the link to online manual: -[Magit Wip Modes](https://magit.vc/manual/magit/Wip-Modes.html#Wip-Modes). +[[https://magit.vc/manual/magit/Wip-Modes.html#Wip-Modes][Magit Wip Modes]]. *** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_mujxm7/comment/t1_gv8jxz5][🔗]] *Votes* 16 -I use, and love, [transient](https://github.com/magit/transient). I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to ~s-w~. I use [buffer-move](https://github.com/lukhas/buffer-move) for rearranging windows in a frame. +I use, and love, [[https://github.com/magit/transient][transient]]. I have a ton of commands set up, but the below command is for window manipulation. Personally, I bind it to ~s-w~. I use [[https://github.com/lukhas/buffer-move][buffer-move]] for rearranging windows in a frame. #+BEGIN_SRC elisp (define-transient-command transient-window () @@ -2376,7 +2376,7 @@ From: http://pragmaticemacs.com/emacs/scrolling-and-moving-by-line/ *** u/Tatrics [[https://www.reddit.com/r/emacs/comments/t3_n9q662/comment/t1_gxpeh9v][🔗]] *Votes* 14 -I'm slowly working on an alternative shell: [https://github.com/TatriX/tshell](https://github.com/TatriX/tshell) +I'm slowly working on an alternative shell: [[https://github.com/TatriX/tshell][https://github.com/TatriX/tshell]] Instead of using repl-like interface, all the commands go to one buffer (and file if you want) and output goes to another buffer. Like if you put your elisp code in \*scratch\* buffer and then evaluate it with \~C-x C-e\~. @@ -2387,7 +2387,7 @@ Let me know what is your first impression, what can be improved and what do you *** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_mg98ki/comment/t1_gstteeo][🔗]] *Votes* 14 -I just discovered the [selected](https://github.com/Kungsgeten/selected.el) package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode. +I just discovered the [[https://github.com/Kungsgeten/selected.el][selected]] package, which is brilliant. It creates a keymap that becomes active any time you have an active region. I have bindings for next-line, previous-line, rectangle-mark-mode, end-of-line, upcase-dwim, exchange-point-and-mark, etc. It makes editing and acting on the active region super easy. Sort of like god-mode or Vim's visual mode. *** u/vatai [[https://www.reddit.com/r/emacs/comments/t3_ojzv53/comment/t1_h5584no][🔗]] *Votes* 13 @@ -2497,7 +2497,7 @@ You can pop this up in a separate frame using: (setq TeX-error-overview-setup 'separate-frame) #+END_SRC -Related docs are [here](https://www.gnu.org/software/auctex/manual/auctex/Error-overview.html). +Related docs are [[https://www.gnu.org/software/auctex/manual/auctex/Error-overview.html][here]]. This totally changes the way you can handle errors messages. @@ -2564,7 +2564,7 @@ One of the most useful bindings for me: *** u/Stefan-Kangas [[https://www.reddit.com/r/emacs/comments/t3_pxqvtm/comment/t1_hf1gzs2][🔗]] *Votes* 10 -Read [SICP](https://mitpress.mit.edu/sites/default/files/sicp/index.html). Preferably in Info, installable through MELPA or: [https://github.com/webframp/sicp-info](https://github.com/webframp/sicp-info) +Read [[https://mitpress.mit.edu/sites/default/files/sicp/index.html][SICP]]. Preferably in Info, installable through MELPA or: [[https://github.com/webframp/sicp-info][https://github.com/webframp/sicp-info]] *** u/Stefan-Kangas [[https://www.reddit.com/r/emacs/comments/t3_pxqvtm/comment/t1_hexdfiq][🔗]] *Votes* 10 @@ -2685,7 +2685,7 @@ Usually I switch to ~foobar.hpp~, kill the necessary part, switch to ~foobar.cpp *** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_q76kok/comment/t1_hghp1e4][🔗]] *Votes* 9 -Checkout [Topsy Mode](https://github.com/alphapapa/topsy.el), it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup. +Checkout [[https://github.com/alphapapa/topsy.el][Topsy Mode]], it creates a header at the top of your buffer to show the name of the first function outside of your visual range. It makes scrolling through code much easier because you get an additional visual queue of your location in the buffer. It's one of those things that you never knew you wanted. It takes about 15 seconds to setup. *** u/oantolin [[https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8utmh2][🔗]] *Votes* 9 @@ -2776,7 +2776,7 @@ Call it with M-x, insert the name of the function you want to declare (with comp *** u/tryptych [[https://www.reddit.com/r/emacs/comments/t3_qgrpte/comment/t1_hicheof][🔗]] *Votes* 8 -A colleague just showed me Intellij's "[compare with clipboard](https://www.jetbrains.com/help/idea/comparing-files-and-folders.html#clipboard)" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections. +A colleague just showed me Intellij's "[[https://www.jetbrains.com/help/idea/comparing-files-and-folders.html#clipboard][compare with clipboard]]" feature: it's fairly neat, you select a region, invoke compare-with-clipboard and get a diff of the two selections. It didn't take me long to implement something similar: @@ -2799,7 +2799,7 @@ It's not ideal though. In particular, is there a better way to insert the "clip \** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_pk6akd/comment/t1_hc3bikc][🔗]] \*Votes* 8 -I'm using [orderless](https://github.com/oantolin/orderless) for completion but I also want to walk through files with initials only, to do something like [like this](https://imgur.com/a/CJg8MGw) for example. It only requires to ignore the case and ask the minibuffer to use initials. +I'm using [[https://github.com/oantolin/orderless][orderless]] for completion but I also want to walk through files with initials only, to do something like [[https://imgur.com/a/CJg8MGw][like this]] for example. It only requires to ignore the case and ask the minibuffer to use initials. #+BEGIN_SRC elisp (use-package orderless @@ -3071,12 +3071,12 @@ Here's the code, maybe there can be a lot of improvements: \** u/poinkalum [[https://www.reddit.com/r/emacs/comments/t3_p28rl5/comment/t1_h8rdjx9][🔗]] \*Votes* 8 -If you follow master, you can use the very useful command ~execute-extended-command-for-buffer~ by using ~M-X~ (with a capital "X"), that implements the behaviour described in [this blog post by Lars](https://lars.ingebrigtsen.no/2021/02/16/command-discovery-in-emacs/). It will only show commands that are relevant to the current major mode. +If you follow master, you can use the very useful command ~execute-extended-command-for-buffer~ by using ~M-X~ (with a capital "X"), that implements the behaviour described in [[https://lars.ingebrigtsen.no/2021/02/16/command-discovery-in-emacs/][this blog post by Lars]]. It will only show commands that are relevant to the current major mode. \** u/slinchisl [[https://www.reddit.com/r/emacs/comments/t3_pt2xws/comment/t1_hdtoivy][🔗]] \*Votes* 8 -I've been playing around with Emacs 28's [repeat-mode](https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp?id=12409c9064c386a496dcbdca76b790108f6c1cad) a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function: +I've been playing around with Emacs 28's [[https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp?id=12409c9064c386a496dcbdca76b790108f6c1cad][repeat-mode]] a bit. It allows for not having to press modifiers when executing several conceptually similar actions in a row. Sadly, the ergonomics of defining these repeat maps are not quite there yet, so I wrote a small macro (my first one ever, actually!) to define the map and set the appropriate symbol property for the function: #+BEGIN_SRC elisp (defmacro defrepeatmap (symbol &optional pairs docstring) @@ -3190,7 +3190,7 @@ I will make some more improvements in the coming days, so if I split the window \** u/nicholas_hubbard [[https://www.reddit.com/r/emacs/comments/t3_rr330u/comment/t1_hqlp0en][🔗]] \*Votes* 8 -Here is a consult source for [perspective.el](https://github.com/nex3/perspective-el) +Here is a consult source for [[https://github.com/nex3/perspective-el][perspective.el]] #+BEGIN_SRC elisp (defvar consult--source-perspective @@ -3473,7 +3473,7 @@ I tend to have a lot of function that is defined solely to be added to a hook. T # 27.1 do GC if no frame has focus -I am porting my [config](https://github.com/laurynas-biveinis/dotfiles) from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [MatthewZMD's config](https://github.com/MatthewZMD/.emacs.d) I think: +I am porting my [[https://github.com/laurynas-biveinis/dotfiles][config]] from 26.3 to 27.1, which had the tweak to do GC whenever a frame loses focus, originally from [[https://github.com/MatthewZMD/.emacs.d][MatthewZMD's config]] I think: #+BEGIN_SRC elispelisp (add-hook 'focus-out-hook #'garbage-collect) #+END_SRC @@ -3680,7 +3680,7 @@ After a while I extended org-export to get a shortcut (~C-e C-s o M~) to automat *** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_ixjcau/comment/t1_g69no38][🔗]] *Votes* 9 -org-variable-pitch.el users might want to give [~valign~](https://github.com/casouri/valign) a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add ~org-link~ to ~org-variable-pitch-fixed-faces~ because valign-mode handles variable pitch links neatly in tables. +org-variable-pitch.el users might want to give [[https://github.com/casouri/valign][~valign~]] a look. It aligns your tables nicely, even with pictures (e.g. LaTeX previews) and links. The significance in context of OVP specifically is that you don't need to add ~org-link~ to ~org-variable-pitch-fixed-faces~ because valign-mode handles variable pitch links neatly in tables. If you don't use OVP but use e.g. latex fragments in tables or just pictures, this one is still very helpful. @@ -3804,11 +3804,11 @@ I posted this in the emacsclient thread, but I think it deserves to live here as The emacsclient / server system is great. If you have it listening on tcp and port forward that when connecting to remote machine it adds another level of power. -I use [emacs-vterm](https://github.com/akermu/emacs-libvterm) for a terminal inside emacs, so I've got a lot of commands remapped. Like ~man~ runs ~emacsclient ... man ..~, which opens the man page in the "other" buffer, so it doesn't interrupt my flow. I use "scroll-other-window" to navigate the man page while I still have my prompt. ~magit~, ~dired~, and others map to their ~emacsclient~ equivalents. +I use [[https://github.com/akermu/emacs-libvterm][emacs-vterm]] for a terminal inside emacs, so I've got a lot of commands remapped. Like ~man~ runs ~emacsclient ... man ..~, which opens the man page in the "other" buffer, so it doesn't interrupt my flow. I use "scroll-other-window" to navigate the man page while I still have my prompt. ~magit~, ~dired~, and others map to their ~emacsclient~ equivalents. I've written wrapper script for e/emacs client that I've come to call ~e~, because it saves keystrokes -#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/) +#### [[https://gitlab.com/zackallison/e-emacs/][The full repo is here e-emacs.sh]] It does the standard things you would expect, starts emacs if it's not already started, open a file in a new buffer / window / terminal and optionally wait for you to finish or have the shell continue. @@ -3820,7 +3820,7 @@ Or the poor man's blog system: ~e -t header_template.html body_template.html foo See the repo for more examples and to download. The notes of getting it working on remote machines aren't the cleanest. If you have any suggestions or features that would make your life easier let me know; submit an issue or comment here. -#### [The full repo is here e-emacs.sh](https://gitlab.com/zackallison/e-emacs/) +#### [[https://gitlab.com/zackallison/e-emacs/][The full repo is here e-emacs.sh]] ~~I really should post this on one of the share your stuff posts. But I get distracted.~~ There, I did it. @@ -3842,7 +3842,7 @@ https://imgur.com/a/zvfLpdH \** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfxbwgy][🔗]] \*Votes* 8 -I tried [marginalia](https://github.com/minad/marginalia) with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings. +I tried [[https://github.com/minad/marginalia][marginalia]] with light annotation and selectrum, it works well. It displays commands' keybindings in the minibuffer. It's especially useful for modes I don't use daily and for which I haven't memorized the keybindings. *** u/martinslot [[https://www.reddit.com/r/emacs/comments/t3_kdgv43/comment/t1_gfwlm9q][🔗]] *Votes* 8 @@ -3873,7 +3873,7 @@ When I have multiple buffers opened and I switch from another program to emacs I *** u/ji99 [[https://www.reddit.com/r/emacs/comments/t3_hqxm5v/comment/t1_fy0xduj][🔗]] *Votes* 8 -Hippie-expand google search suggestions. Completely inspired from [shell-parse.el](https://github.com/malloc47/shell-parse.el/blob/master/shell-parse.el). +Hippie-expand google search suggestions. Completely inspired from [[https://github.com/malloc47/shell-parse.el/blob/master/shell-parse.el][shell-parse.el]]. I've added ~try-expand-google-completion~ to the bottom of my ~hippie-expand-try-functions-list~ @@ -3941,24 +3941,24 @@ The advice below quiets this warning, and inserts a dash whenever space is press *** u/karthink [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqfc1wi][🔗]] *Votes* 8 -AucTex users: You're missing out if you don't use [CDLatex](https://github.com/cdominik/cdlatex). It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is _always available_, not just during snippet entry. It's difficult to explain, so here are some demos: +AucTex users: You're missing out if you don't use [[https://github.com/cdominik/cdlatex][CDLatex]]. It's primarily a fast input tool for LaTeX, sort of like snippet templates. The difference between setting up Yasnippet templates for LaTeX and CDLatex is that CDLaTeX's TAB key to jump past stuff is _always available_, not just during snippet entry. It's difficult to explain, so here are some demos: -1. [Fast input with cdlatex and preview.el](https://gfycat.com/heavenlynegligiblehoiho) -2. [Fast input with keys displayed](https://gfycat.com/safeidolizedlangur) +1. [[https://gfycat.com/heavenlynegligiblehoiho][Fast input with cdlatex and preview.el]] +2. [[https://gfycat.com/safeidolizedlangur][Fast input with keys displayed]] -I wrote a longer post explaining [how I set up AucTex](https://www.reddit.com/r/emacs/comments/g8ecpj/advice_for_auclatex_what_keybinds_do_you_find/foo64ge/) recently. +I wrote a longer post explaining [[https://www.reddit.com/r/emacs/comments/g8ecpj/advice_for_auclatex_what_keybinds_do_you_find/foo64ge/][how I set up AucTex]] recently. CDLaTeX was written by Carsten Dominik, the author of Org-mode and reftex. Thus Org ships with an ~org-cdlatex~ minor-mode that makes these features available in org-mode. *** u/[deleted] [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqczes1][🔗]] *Votes* 8 -[A beginers guide to emacs 24 or later by sasha chua](https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png) this helped me tremendously to get started with emacs. +[[https://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png][A beginers guide to emacs 24 or later by sasha chua]] this helped me tremendously to get started with emacs. *** u/ji99 [[https://www.reddit.com/r/emacs/comments/t3_gi70ye/comment/t1_fqcycvb][🔗]] *Votes* 8 -A rudimentary interface for the fabulous [Links web browser](http://links.twibright.com/user_en.html): +A rudimentary interface for the fabulous [[http://links.twibright.com/user_en.html][Links web browser]]: #+BEGIN_SRC elisp (defun links-browser (&optional link new-window)