Skip to content

How to set up Emacs to open read-only depending on file location

bravotan profile image Keisuke URAGO twitter logo github logo ・1 min read

In order to prevent accidental editing of a file when opening a library of virtual environments such as virtualenv, if you change the Emacs setting, you can open it automatically in read-only state without executing C-x C-q.

An example of setting targeting pyenv's directory is as follows.

(add-hook 'find-file-hook
          (lambda ()
            (dolist (pattern '("~/.pyenv/versions/.*"
                               ;; add here
              (if (string-match (expand-file-name pattern) buffer-file-name)
twitter logo DISCUSS
markdown guide
Classic DEV Post from Aug 6 '19

What to put in your portfolio as a beginner web dev

Keisuke URAGO profile image
Programmer, Freelancer in Japan. I often use Python(Django, Scrapy, PyQt, etc.). I interested in web technologies. I am currently recovering from a mild depression. So I trying to work when I can.