elisp

Distinguishing files with extensions, from hidden files and no extensions

六月ゝ 毕业季﹏ 提交于 2019-11-28 02:26:43
I'm having difficulty distinguishing files with extensions, from files without extensions, and hidden files. I'm using (file-name-extension (dired-get-file-for-visit)) in dired-mode, and the type of file extension determines what action to take -- e.g., open in Emacs, or open externally with a particular application. A hidden file (e.g., .hidden ) returns a value of nil instead of "hidden" . A file with no extension (e.g., foo ) also returns a value of nil . Can anyone suggest an alternative method to handle this? (let* ( (input-regexp '("odt" "wpd" "docx" "doc" "xls" "pdf" "tif" "bmp" "jpg"))

Emacs indent level global override

痞子三分冷 提交于 2019-11-28 01:22:14
问题 I want to set the indentation mode to tabs only, with a 4 character width for any mode. This seems like a trivial thing, but I have not had success. Every mode seems to have its own variables and options. I've tried doing this for Perl and R without success. Things that have not worked: (setq-default tab-width 4) (setq standard-indent 4) (setq-default r-indent-level 4) (setq perl-indent-level 4) (setq c-basic-offset 4) works for c-mode but nothing else. Am I forgetting something? Did I set

Alternative to forward-word / backward-word to include symbols — e.g., ***

陌路散爱 提交于 2019-11-28 01:13:05
My preferred method of indicating a location within a document that requires attention is with three asterisks *** . When it comes time to select the region containing the three asterisks using shift+right-word or shift+left-word , those functions skip over the three asterisks and move along to the next word. When I peeked inside bindings.el , I saw that left-word and right-word are adaptations of forward-word and backward-word , that are traceable to built-in functions in the C source code. Essentially, I'm looking for left-word and right-word that includes symbols such as three asterisks ***

How do I bind a key to “the function represented by the following key sequence”?

Deadly 提交于 2019-11-28 00:25:40
问题 I'm just starting to learn emacs (woohoo!) and I've been mucking around in my .emacs quite happily. Unfortunately, I don't know Lisp yet, so I'm having issues with the basics. I've already remapped a few keys until I fix my muscle memory: (global-set-key (kbd "<f9>") 'recompile) That's fine. But how can I tell a key to 'simulate pressing several keys'? For instance, I don't know, make <f1> do the same as C-u 2 C-x } (widen buffer by two chars). One way is to look up that C-x } calls shrink

Emacs key binding fallback

对着背影说爱祢 提交于 2019-11-27 23:48:44
I have a minor mode. If that mode is active and the user hits DEL, I want to do some action, but only if some condition holds. If the condition holds and the action is executed I want to do nothing more after that. But if the condition fails, I don't want to do anything and let the default DEL action execute. Not sure how I could solve this. But I guess I could do it in two ways: 1) I could rebind the DEL key to a function in the minor mode and then check if the conditions holds ot not. But then how do I know what the default command to DEL is? 2) I could add a pre command hook like this.

Eclipse-like Line Commenting in Emacs

感情迁移 提交于 2019-11-27 21:32:52
In Eclipse, highlighting multiple rows and pressing Ctrl+/ comments each of the lines of the selection. Emacs has a function comment-or-uncomment-region that is close what I want, but behaves differently if the region only partially covers the lines I'm trying to comment. Is there any way I make a function similar to comment-or-uncomment-region , but have it comment each of the lines of the region regardless of how the region is selected? In other words, I want the function to act as though the region occupies the whole line as long as the region includes that line, so it behaves as Eclipse's

How do I create an empty file in emacs?

风格不统一 提交于 2019-11-27 20:01:06
问题 How can I create an empty file from emacs, ideally from within a dired buffer? For example, I've just opened a Python module in dired mode, created a new directory, opened that in dired, and now need to add an empty __init__.py file in the directory. If I use C-x C-f __init__.py RET C-x C-s then emacs doesn't create the file because no changes have been made to it. I would have to type in the file, save it, delete my typing and then save it again for that to work. Thanks 回答1: Here's an

Latex, Emacs: automatically open *TeX Help* buffer on error and close it after correction of the error?

夙愿已清 提交于 2019-11-27 18:19:32
问题 I use the function TeX-parse-error defined by Ivan Andrus at the bottom of Emacs latexmk function throws me into an empty buffer in order to automatically open the *TeX Help* buffer when there was an error during the compilation ( C-c C-c ). After correcting an error and compiling again, the *TeX Help* buffer remains open (although the error has been corrected). Is there any way to adjust the function (unfortunately, I'm not experienced in elisp programming) so that the *TeX Help* buffer is

How do I set the size of Emacs' window?

核能气质少年 提交于 2019-11-27 16:49:16
I'm trying to detect the size of the screen I'm starting emacs on, and adjust the size and position the window it is starting in (I guess that's the frame in emacs-speak) accordingly. I'm trying to set up my .emacs so that I always get a "reasonably-big" window with it's top-left corner near the top-left of my screen. I guess this is a big ask for the general case, so to narrow things down a bit I'm most interested in GNU Emacs 22 on Windows and (Debian) Linux. Bryan Oakley If you want to change the size according to resolution you can do something like this (adjusting the preferred width and

emacs: is there a clear example of multi-line font-locking?

扶醉桌前 提交于 2019-11-27 16:04:52
问题 Some background, I'm comfortable with Emacs Lisp, and have written lots of lines of it. However I've never written a major mode, so I'm fairly new to how the font-locking mechanism works. For my current project, I'd like to add inlined javascript and css highlighting to html-mode . Currently, I do this with MMM-mode, but it's bulky and I don't use other features of it, so I'd just like to make a minor-mode or even just a hack that I can add to the sgml-mode-hook to just do the highlighting. I