elisp

Emacs custom background color by mode

≯℡__Kan透↙ 提交于 2020-01-29 13:11:11
问题 I use emacs to edit a number of file types, and would like an easy visual queue to tell .c files from .vhd or .py files, for instance. How can I add a custom background color to the major mode for that language? 回答1: You can do this via hooks. Among other things you can hook is when a new major mode starts. Put something like this into your .emacs file, and emacs will set your background color to purple every time you go into Python mode. (add-hook 'python-mode-hook (lambda () (set-background

Unset key binding in emacs

纵饮孤独 提交于 2020-01-27 23:04:09
问题 For example, in the codes of zen-coding, the "C-j" shadows the normal behavior of "C-j" ( newline-and-indent ) (define-key zencoding-mode-keymap (kbd "C-j") 'zencoding-expand-line) Then how can I unset this keybinding and use C-j for newline-and-indent again? I tried this, but it doesn't work: (add-hook 'html-mode-hook (lambda () (progn (zencoding-mode) (local-set-key (kbd "C-j") 'newline-and-indent)))) Does anyone have ideas about this? 回答1: The general way to unbind a key (for any keymap)

Unset key binding in emacs

拜拜、爱过 提交于 2020-01-27 23:00:52
问题 For example, in the codes of zen-coding, the "C-j" shadows the normal behavior of "C-j" ( newline-and-indent ) (define-key zencoding-mode-keymap (kbd "C-j") 'zencoding-expand-line) Then how can I unset this keybinding and use C-j for newline-and-indent again? I tried this, but it doesn't work: (add-hook 'html-mode-hook (lambda () (progn (zencoding-mode) (local-set-key (kbd "C-j") 'newline-and-indent)))) Does anyone have ideas about this? 回答1: The general way to unbind a key (for any keymap)

How to decode name of month into an integer

南楼画角 提交于 2020-01-25 06:17:07
问题 I'm trying to write a function that will let me choose (interactively) the month and year for org-agenda-month-view -- which uses a format of 201312 ( without double-quotes) for December 2013 . I would like to use either words ( December ) or numbers ( 12 ) for the month, but need some assistance (please) to decode the name of the month into an integer -- something like (if (not (integer-p month)) (setq month (decode-name-of-month month))) . Also, any pointers on how to consolidate my two

Emacs Setting which-function-mode

守給你的承諾、 提交于 2020-01-24 10:30:12
问题 I would like to have which-function-mode on by default when I open up Emacs. I've added the following lines to my .emacs file. (setq which-func-mode t) (setq which-function-mode t) When I open up a .cpp file and navigate to the body of a function, I'm not seeing the function name in the status bar at the bottom like I should. If I then run M-x which-function-mode, the message is "Which-Function mode disabled" so it looks like the line in my .emacs file takes but is not quite working. Am I

Emacs lisp: Translate characters to standard ASCII transcription

北城以北 提交于 2020-01-24 08:45:27
问题 I am trying to write a function, that translates a string containing unicode characters into some default ASCII transcription. Ideally I'd like e.g. Ångström to become Angstroem or, if that is not possible, Angstrom . Likewise α=χ should become a=x (c?) or similar. Does Emacs have such built-in capabilities? I know I can get the names and similar of characters ( get-char-code-property ) but I know no built-in transcription table. The purpose is to translate titles of entries into meaningfully

Emacs lisp: Translate characters to standard ASCII transcription

老子叫甜甜 提交于 2020-01-24 08:45:09
问题 I am trying to write a function, that translates a string containing unicode characters into some default ASCII transcription. Ideally I'd like e.g. Ångström to become Angstroem or, if that is not possible, Angstrom . Likewise α=χ should become a=x (c?) or similar. Does Emacs have such built-in capabilities? I know I can get the names and similar of characters ( get-char-code-property ) but I know no built-in transcription table. The purpose is to translate titles of entries into meaningfully

Emacs: Matching parenthesis when cursor is ON closing parenthesis

£可爱£侵袭症+ 提交于 2020-01-24 00:48:08
问题 {It has been asked before: Emacs: highlight matching paren when cursor is on it, not after it but none of the answers are satisfactory} I am using mic-paren with following .emacs settings (although the problem exists with all similar emacs packages, so it seems to be some kind of default emacs behavior) (paren-activate) (setq paren-match-face 'highlight) (setq paren-sexp-mode t) which highlight the all the text between two parenthesis. It works well when the cursor is ON opening parenthesis

“wrong-type-argument” on an Emacs function I've written

倾然丶 夕夏残阳落幕 提交于 2020-01-23 11:39:57
问题 I'd like my tab key to do the following: If I'm in the minibuffer, use word completion. Otherwise, if a region is selected, indent it. Otherwise, indent the line at the point (using tab-to-tab-stop). Here's the code, some of which is based on fragments I've found elsewhere on the Internet: (defun my-tab () "If region is selected, indent it and keep it selected, else indent current line." (interactive) (if (use-region-p) (increase-left-margin (region-beginning) (region-end) nil) (tab-to-tab

“wrong-type-argument” on an Emacs function I've written

本秂侑毒 提交于 2020-01-23 11:39:51
问题 I'd like my tab key to do the following: If I'm in the minibuffer, use word completion. Otherwise, if a region is selected, indent it. Otherwise, indent the line at the point (using tab-to-tab-stop). Here's the code, some of which is based on fragments I've found elsewhere on the Internet: (defun my-tab () "If region is selected, indent it and keep it selected, else indent current line." (interactive) (if (use-region-p) (increase-left-margin (region-beginning) (region-end) nil) (tab-to-tab