trying to fix

This commit is contained in:
Chris Cochrun 2022-01-03 12:41:35 -06:00
parent fa407dfeb6
commit e013d7569e
22945 changed files with 447936 additions and 0 deletions

View file

@ -0,0 +1,19 @@
<p>How does the process of script creation typically go? You create a file (e.g. <code class="language-plaintext highlighter-rouge">script.py</code>),
you write some code in it, and finally you make the file executable, so you can
run it directly (e.g. by typing <code class="language-plaintext highlighter-rouge">./script.py</code>). Turns out that Emacs has one very
specific helper for making a script executable, namely the function
<code class="language-plaintext highlighter-rouge">executable-make-buffer-file-executable-if-script-p</code>.</p>
<p>What the function does is to check if the buffer file has a shebang (e.g. <code class="language-plaintext highlighter-rouge">#!/bin/ruby</code>) in it and then it modifies its permissions, if necessary. The function is meant to be used
in a hook, most typically <code class="language-plaintext highlighter-rouge">after-save-hook</code>:</p>
<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">add-hook</span> <span class="ss">'after-save-hook</span>
<span class="ss">'executable-make-buffer-file-executable-if-script-p</span><span class="p">)</span>
</code></pre></div></div>
<p>Ive been using this little trick for ages, and I was reminded of it today
when I came across <a href="https://github.com/bbatsov/prelude/issues/1343">this Prelude issue</a>. I guess in some cases making a file executable automatically might be
undesirable, but Ive never ran into any issues myself.</p>
<p>Thats all I have for you today. Feel free to share other tips for working with
scripts in Emacs in the comments. Keep hacking!</p>