Blog

Last edit

Summary: bez kalendarza

Deleted:

< month:+0


For the English part of the blog, see Content AND Presentation.

2018-10-14 Magit and C-u i

Last time I mentioned that I use multiple backup copies of my .env file. One problem with that approach was they they cluttered my Git status (or the magit-status window). I could put the relevant pattern in my .gitignore file, but I didn’t want to bother other programmers in the team with peculiarities of my personal setup.

Well, quite unsurprisingly, Git does support ignoring files without putting them in .gitignore. You can use the file .git/info/exclude, which has the same format as .gitignore, but is not committed to the repository.

One grip I had was that I knew that Magit supported ignoring files by putting the point over them and pressing i (magit-gitignore). But this puts them in .gitignore, not in .git/info/exclude. I thought “well, it’s the second time in my life when I need some feature of Git that Magit doesn’t support”.

Or is it? I decided to try C-u i, and wow, here it is! Had I read the docstring, I would knew that. Interestingly, this seems not to be mentioned in the manual. This might mean that skimming through the Magit sources and looking at the docstrings might reveal more little gems like that!

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

2018-10-06 The version-control variable

As many of us know, Emacs has a habit (annoying for most people, I guess) of making backup copies of files it saves.

Happily, it doesn’t kick in in version-controlled files (and most of my files fall into this category nowadays).

But there are situations when I actually do want the backup copies. One of them is the .env file I have in a few projects, which contains some settings which must not be committed to a VC repository (like credentials), but breaking those settings must be really avoided.

I often resorted to looking into .env~ because of that, but sometimes an error became apparent after some more time. Then, the last version may be inadequate, since the working version was one of the previous ones.

Again happily, Emacs has you covered. You can set Emacs variable version-control to t, and then Emacs starts to make numbered backups, like .env.~1~, .env.~2~, .env.~3~ etc. (You might want to use file-local variables to set this variable for an individual file, either manually, or by means of add-file-local-variable or add-file-local-variable-prop-line command.)

Of course, you probably don’t want to have more than, say, 5–10 of those, so Emacs has two more variables: kept-old-versions and kept-new-versions, whose names are pretty self-explanatory. They default to 2, so you might want to increase that if you are a bit paranoiac.

Also, Emacs will by default ask you each time it is going to delete old backup files. If you don’t want to be bothered by that, you may set delete-old-versions to t.

Actually, there is more to backup files than that. For instance, you can use a completely different naming scheme for them. Consult the manual for more details – as usual, it is extensive and well-written.

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

2018-09-30 add-dir-local-variable - conclusion

In the last two posts, I wrote about Emacs directory variables. Last week, the conclusion was that there is no easy way for add-dir-local-variable to use the dotted pair notation in the .dir-locals.el file.

Well, I was wrong again. This week, a patch was made (and documented) in Emacs which enables exactly that behavior. I just checked it, and it works great. (If you are interested in that kind of stuff, you can read the start of the discussion here, and it is continued here.)

Not to mention that last week, Eli Zaretskii introduced several fixes in the documentation to clarify a few things related to directory variables.

What can I say? It’s just amazing.

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

More...