TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What are your best Emacs tips?

9 点作者 Decabytes大约 1 年前

3 条评论

phba大约 1 年前
Here is a very specific tip for doing literate programming with org-mode:<p>Usually you put a code block like this in the .org file and generate the actual source file with M-x org-babel-tangle.<p><pre><code> #+begin_src emacs-lisp :tangle &quot;init.el&quot; (setq make-backup-files nil) #+end_src </code></pre> The file name doesn&#x27;t have to be a string constant, you can also call an Elisp function: (the org-prefix is recommended or you will have issues with HTML export)<p><pre><code> #+begin_src emacs-lisp :tangle (org-my-tangle) (setq make-backup-files nil) #+end_src </code></pre> The function could look like this: (&quot;no&quot; means don&#x27;t tangle this block)<p><pre><code> (defun org-my-tangle () (if my-flag &quot;init.el&quot; &quot;no&quot;)) </code></pre> Or like this: (a more complex example using named, optional parameters)<p><pre><code> (defun org-my-tangle (&amp;rest args) (let ((file (or (plist-get args :file) &quot;init.el&quot;)) (sys (plist-get args :sys))) (if (or (null sys) (eq sys system-type)) file &quot;no&quot;))) </code></pre> This will tangle to init.el on any system:<p><pre><code> #+begin_src emacs-lisp :tangle (org-my-tangle) (setq make-backup-files nil) #+end_src </code></pre> This will tangle to init.el on Linux:<p><pre><code> #+begin_src emacs-lisp :tangle (org-my-tangle :sys &#x27;gnu&#x2F;linux) (setq make-backup-files nil) #+end_src </code></pre> This will tangle to foo.el on Windows:<p><pre><code> #+begin_src emacs-lisp :tangle (org-my-tangle :file &quot;foo.el&quot; :sys &#x27;windows-nt) (setq make-backup-files nil) #+end_src </code></pre> I use this approach for example to generate different Emacs configurations for different platforms and use cases (private, work, ...) all from a single org file.
评论 #40200444 未加载
kickaha大约 1 年前
Incremental gains.<p>Get the basics, then follow your nose to the features you want to try. Before you know it you&#x27;ll be writing your own stuff and sharing it.<p>The community is the best around.
wegwerff大约 1 年前
Uncommonly useful: I have a file with two functions that I want to not just see side-by-side, but with a diff.<p>`C-x 4 c&#x27; runs the command clone-indirect-buffer-other-window Now you can narrow both buffers to the two different functions (mark and C-x n n) and do M-x ediff-buffers to get a diff<p>See also <a href="https:&#x2F;&#x2F;karthinks.com&#x2F;software&#x2F;batteries-included-with-emacs&#x2F;#indirect-buffers--m-x-make-indirect-buffer" rel="nofollow">https:&#x2F;&#x2F;karthinks.com&#x2F;software&#x2F;batteries-included-with-emacs...</a><p>Also, rectangles: <a href="https:&#x2F;&#x2F;karthinks.com&#x2F;software&#x2F;more-batteries-included-with-emacs&#x2F;#easier-rectangle-editing--m-x-cua-selection-mode" rel="nofollow">https:&#x2F;&#x2F;karthinks.com&#x2F;software&#x2F;more-batteries-included-with-...</a>