How to ignore emacs temp files in Jekyll? - emacs

I have Jekyll blog and when I run jekyll serve, and I'm editing the post in GNU Emacs I got this output:
Regenerating: 2 file(s) changed at 2020-02-28 09:05:34
_posts/2018-10-20-pytania-rekrutacyjne-css.markdown
_posts/.#2018-10-20-pytania-rekrutacyjne-css.markdown
...done in 13.517243884 seconds.
is it possible to ignore files that starts with .#. I assume it would be twice as fast to generate the html page.
I've tried this:
exclude:
-
README.md
-
.\#*
-
_posts/.\#*
but this don't work, it regenerate when I save _config.yml (as .#_config.yml) the same as with posts.
I would like to ignore every Emacs file in my Jekyll project.

Files with a .# prefix are lockfiles. They prevent separate Emacs instances from editing the same file at the same time. See https://www.gnu.org/software/emacs/manual/html_node/emacs/Interlocking.html. Personally, I set (setq create-lockfiles nil) because I rarely run more than one Emacs, and I have (global-auto-revert-mode 1). auto-revert-mode will watch for a file to be changed and automatically reload it (or tell you it has changed if there are unsaved changes).
Also take a look at https://github.com/emacscollective/no-littering to move autosave and backup files to a common place instead of next to whatever file you're editing.

Probably only the message is confusing. It says 2 files changed, which is correct. It does not say 2 files regenerated. My config does not even exclude .#-files. I get the same message, but no .#-file is generated. Check the _site folder. And check the time to regenerate the output file
touch _posts/2018-10-20-pytania-rekrutacyjne-css.markdown # still around 14 sec?
touch _posts/.#2018-10-20-pytania-rekrutacyjne-css.markdown # should be close to zero?

Related

emacs as an external editor for other applications (Houdini, Joplin)

I am trying to use emacs as an editor with other applications which allow people to open text in an editor (Sublime in this case), save it, and see it updated in the application. For example, in Houdini, a 3D software, I can type code in an external editor (in this case, Sublime), modify, save... and see it update in the application (Houdini). When I use emacs, it doesn't work. As an example, here I am adding a line of text using Sublime in Houdini:
Once I save and close, the text is updated in Houdini, and I can continue working:
Try as I might, I can't get this to work in emacs. I am sure the file has the same name, and when I save, it confirms the right file path.
What am I missing? I have run into the same problem with an application called Joplin: Sublime works, emacs does not.
A wild guess: Emacs has different behaviour when saving files than Sublime, and Houdini gets confused by that.
When you save a file in Emacs, Emacs creates a backup of the previous contents of the file, suffixing the file name with a tilde. By default it does this by renaming the existing file to the backup name, and then writing the contents to the real filename, thereby creating a new file.
(You can observe this by running ls -i before and after: the backup file will have the inode number that the main file had previously. Note that Emacs doesn't make backups after the first save during the same editor session, so you might need to restart Emacs or kill the buffer with C-x k to see this.)
I suspect that Houdini keeps the file open while Emacs is editing it, and so when you save the file from Emacs, the file that Houdini has open is actually the backup file.
You can configure Emacs to make backups by copying instead of renaming by setting the variable backup-by-copying to t. Add this to your ~/.emacs file (creating it if it doesn't exist):
(setq backup-by-copying t)

How does emacs compile the file and edit it?

There is this feature in emacs. Whenever you compile your code (filename: hello.cpp) run the program and then you edit your code then emcas will store you previous unedited code in another file named hello.cpp~
. hello.cpp~ will always contain first code you compile and whenever you write you edit your code in emacs it will produce file name .#hello.cpp. It automatically remove .#hello.cpp when you save that code but hello.cpp~ will remain same. .#hello.cpp file contain info. such as username#DESKTOP-FN20BRU.13000:1597860074. So anybody can please explain me this working process of emacs?
Emacs does the following when you edit a file filename
#: when you modify the file (in memory), Emacs creates a # file (on disk) and keeps updating it with your changes, until you save the edited version. This draft, on disk, can be recovered in case Emacs or the computer crash before you had time to save your changes.
~: as soon as you save the edited version, Emacs renames first your old version on disk (the one when you opened Emacs) adding a trailing ~ to the filename giving filename~ (it does this only the first time you save within the current session), then it overwrites filename with the modified version, and finally removes the # draft on disk.
Then, when you make further changes, another # file is created, etc.

Open cscope results in the same buffer

This might seem to be a very very stupid question.
But for the past few years I have been using vim and cscope on the terminal, with some screen to make life a bit bearable.
I have just started to learn emacs and it is much more satisfying to use it.
Problem using emacs:
Every time I do M-x find-c-symbol, I get a new buffer with a bunch of files, but I don't know how to open the file at the exact line number.
I googled a lot and found this to open file under cursor: M-x ffap
but this opens at the first line. Can some emacs expert help me??
Thanks
I've got both Emacs 23.x and 24.x installed, both setup with working cscope and xcscope installs. Neither has a "find-c-symbol" function, but there is a "cscope-find-this-symbol", which is what I assume you're actually using.
I'm going to assume you're using a GUI version, and not the text-only version, and that you're actually getting the *cscope* buffer automatically being opened and created (since that's what it sounds like from your description).
For a simple search, I'll get results that look like this:
Finding symbol: debug
Database directory: /home/user/emacs_tags/modular/
-------------------------------------------------------------------------------
*** /home/user/code/modular/frontend/common/controller.test/src/MainTest.cpp:
<global>[73] #ifdef debug
-------------------------------------------------------------------------------
Database directory: /home/user/emacs_tags/rrsdk/
-------------------------------------------------------------------------------
*** /home/user/code/rrsdk/fs/apps/busybox/src/shell/ash.c:
<global>[303] #define debug optlist[15 + ENABLE_ASH_BASH_COMPAT]
*** /home/user/code/rrsdk/bootloader/u-boot/src/board/mcc200/auto_update.c:
<global>[53] #undef debug
<global>[55] #define debug(fmt,args...) printf (fmt ,##args)
<global>[57] #define debug(fmt,args...)
-------------------------------------------------------------------------------
Search complete. Search time = 22.44 seconds.
Assuming your results look similar (they should), there are two multiple target areas in the result. Each file line (the lines starting with ***) is a target to the start of that file. Each individual result is also a target area. If you click on one of the lines that lists a specific match (or put your cursor on it and press enter), it will attempt to jump to the specific line matching the result. If it's not jumping to the specific line correctly it usually means your code has changed since the last time the cscope index file was generated.
I'm not sure how you're using the cscope tool, but you can setup xcscope to auto-index on every change to keep the file up to date, but it really only works for smaller code bases where you can keep the cscope.out files in the top level directory and provide it with a full file list for the files to index. Most people I've talked to use the cscope tool by hand in an external script to manually index/re-index every once in a while and then just interface to the existing cscope database(s) using the emacs tools (mine takes about 4 hours to generate the cscope database for a project that includes the Linux kernel as a sub-part).

Bookmark+ using a temporary file, despite having asked for a specific file

After typing C-x r l I get a buffer called *Bookmark List*
In this buffer I see:
Bookmark file:
/tmp/bmkp-temp/19236bkt
If I open help (i.e. press h), I see:
Bookmark file: /tmp/bmkp-temp-19236bkt
Sorted:
Filtering: none
Marked: 0
Omitted: 0
Autosave bookmarks: no
Autosave list display: yes
This is even though I have the following in my .emacs file:
(setq bookmark-file "~/.emacs.d/bookmarks")
(setq bookmark-default-file "~/.emacs.d/bookmarks")
(setq bmkp-default-bookmark-file "~/.emacs.d/bookmarks")
(setq bmkp-last-as-first-bookmark-file nil)
Why is it using a different bookmark file from the one I specified?
I also noticed that when I load Emacs the following happens:
Emptying bookmark file `/tmp/bmkp-temp-23808OMn'...
Saving file /tmp/bmkp-temp-23808OMn...
Wrote /tmp/bmkp-temp-23808OMn
Emptying bookmark file `/tmp/bmkp-temp-23808OMn'...done
...
Helm completion enabled
Emptying bookmark file `/tmp/bmkp-temp-23808bWt'...
Saving file /tmp/bmkp-temp-23808bWt...
Wrote /tmp/bmkp-temp-23808bWt
Emptying bookmark file `/tmp/bmkp-temp-23808bWt'...done
...
Emacs goes on a spree deleting temporary bookmark files. ?
Perhaps you were trying to use "bookmark-file bookmarks"? Or anyways, accidently hit C-x p x?
These are claimed to correspond, at EmacsWiki: Bookmark Plus / Bookmark-File Bookmarks, where they say, "bmkp-set-bookmark-file-bookmark, bound to C-x p x". For my Emacs, this is not true.
By typing C-x p C-h, I can check key-bindings that start with C-x p. I find
C-x p x is bound to bmkp-toggle-autotemp-on-set, and
C-x p y is bound to bmkp-set-bookmark-file-bookmark.
Then, the link should say C-x p y instead.
It looks like something, somewhere (e.g. check your .emacs file) has turned on bmkp-temporary-bookmarking-mode. When that mode is on, any bookmarks you create are for the current session only -- they are not saved to your bookmark file.
And that means that your bookmark-file location settings are ignored. (Note, BTW, that bmkp-default-bookmark-file is a function, not a variable -- it is not something that you set. And you don't need all of those bookmark-file settings; some are redundant: old names from old versions of Emacs bookmarking.)
I don't know why you are getting multiple temporary bookmark-file creations and saves. You didn't provide a complete recipe. You should get only one such. This is all I see in *Messages* in this regard, for instance:
Emptying bookmark file `c:/DOCUME~1/me/LOCALS~1/Temp/bmkp-temp-5348su1'...
Saving file c:/Documents and Settings/me/Local Settings/Temp/bmkp-temp-5348su1...
Wrote c:/Documents and Settings/me/Local Settings/Temp/bmkp-temp-5348su1
Emptying bookmark file `c:/DOCUME~1/me/LOCALS~1/Temp/bmkp-temp-5348su1'...done
It also appears that you have a lot of stuff going on (Helm etc.). When trying to understand or debug a problem, it helps to narrow things down as much as possible. Who can tell what other interactions might be involved here?
All of that said, my advice would be to not start out using the temporary bookmarking mode. I would not suggest you use that until you are quite familiar with Bookmark+. You can use temporary bookmarks without using this mode.
Here is the doc about using temporary bookmarks:
http://www.emacswiki.org/cgi-bin/wiki/BookmarkPlus#toc55
Finally, as Stefan suggested, please follow up by email. It's a lot easier for debugging/discussing things in detail.
Thx -- Drew
Update 2019-04-21:
I think what might have happened is that you quit Emacs with bmkp-temporary-bookmarking-mode enabled. Although Bookmark+ (correctly) does not save the file of temporary bookmarks it was not preventing the recording of bmkp-last-as-first-bookmark-file from being updated to point to the temporary file. In your next Emacs session that temporary file (if it still existed) was loaded because of bmkp-last-as-first-bookmark-file.
That should be OK now. Enabling bmkp-temporary-bookmarking-mode now resets bmkp-last-as-first-bookmark-file to nil, so if you quit with the temp mode still enabled, then when you load your bookmark file in a new session the file that is read is the value of bookmark-default-file. (The value of bookmark-default-file is never changed, except by your
customizations.)
It's quite an old question, but since I had just the same problem and the other answers didn't help me I'll post my solution:
I'm using desktop files from desktop.el and the temporary mode was set there in the desktop file! Removing that setting from all my desktop files fixed the problem.
This might be handy:
find ~ -name .emacs.desktop -print0 | xargs -0 grep -l bmkp-temporary-bookmarking-mode

emacs: force ido-mode to forget history

I wonder if I can keep ido from not remembering my history and only show completions for files that are in the current directory when I am searching for a file. I understand that this history feature is useful at times, but I often end up editing the incorrect file because I think I am editing file called 'abc.txt' in the current directory but in fact I am editing the file by the same name in another one that I previously visited (often happens when there is not an 'abc.txt' in the current directory, as I mistakenly assume). From reading the ido.el file I thought to set in my .emacs file (also evaluated these expressions in running emacs instance):
(custom-set-variables
'(ido-enable-last-directory-history nil)
'(ido-record-commands nil)
)
and deleted a file called .ido.last in ~/, but still it remembers some previous files I've visited before making these changes. How can I purge my previous history, and I am not entirely sure what the difference between the two variables above are but seems to have done the trick to keep ido from remembering files I visit in the future?
Thanks for your help!
Deleting ~/.ido.last and setting the variables as above appears to keep ido from searching files visited in the past.
Edit: Actually, the full customization for this task would be
(custom-set-variables
'(ido-enable-last-directory-history nil)
'(ido-record-commands nil)
'(ido-max-work-directory-list 0)
'(ido-max-work-file-list 0))
This happens to me all the time. Given I am in directory /path/to/dir and I try to edit abc.txt, (ido-find-file) will "helpfully" pop me over to /somewhere/else/abc.txt if /path/to/dir/abc.txt doesn't exist and /somewhere/else/abc.txt does.
In this situtation, CTRL-F in the minibuffer when in the middle of an (ido-find-file) reverts to the usual behavior of (find-file), so I can force Emacs to edit /path/to/dir/abc.txt, dammit.
Setting ido-auto-merge-work-directories-length to -1 disables automatic directory switching.