elisp

How to get C-x C-e to display the result in octal and hexadecimal by default?

与世无争的帅哥 提交于 2019-12-11 08:28:42
问题 When I hit C-x C-e on a numeric expression a second time, the mini-buffer displays the result in octal and hexadecimal. This is documented here Is there a way to get the result in hex and octal on the first C-x C-e ? 回答1: You can get that behavior with this advice. Note, I made it also work for eval-print-last-sexp (aka C-j ). Just remove that from the list if you don't want that behavior. (defadvice eval-expression-print-format (around eepf-tweak-output activate) "tweak output when this

Paragraph filling for org-mode inside latex environment

旧时模样 提交于 2019-12-11 07:55:50
问题 I started using org-mode to write mathematical papers so I make a heavy use of latex environments such as proof , theorem , lemma , etc. For example I often write \begin{proof} a very long proof follows \end{proof} The problem is that in org-mode the fill-paragraph (or M-q ) doesn't work inside latex environments. This complicates my life because some proofs can be very long, reaching several pages when compiled to pdf, and I am unable to efficiently format them in org-mode. I couldn't find

Elisp sentinel on process waiting for input

删除回忆录丶 提交于 2019-12-11 06:34:30
问题 I made a function, compiling the current latex file: ;close the *async pdflatex* window, when pdflatex finishes (defun latex-sentinel (process event) (message event) (cond ((string-match-p "finished" event) (progn (kill-buffer "*async pdflatex*") (message "pdflatex done") (delete-other-windows))))) (defun latex-compile () "Runs pdflatex on current file" (interactive) (let* ((file-name (shell-quote-argument (buffer-file-name))) (process (start-process-shell-command "pdflatex" "*async pdflatex*

is it possible to preprocess the input string before isearch-forward in Emacs

岁酱吖の 提交于 2019-12-11 05:31:48
问题 For example, if I type " foo spam " after the prompt of isearch-forward , how can I advice some functions in isearch.el to convert the string to " foo[.?:,!]?[ \n]spam " before search? Basically I want to search for the two adjacent words in the text. I know I can use isearch-forward-regexp to do that, but it's painful and error-prone to type out the regexp directly and I have many strings of that kind to search. I tried to understand code in isearch.el but failed. hope some Emacs gurus could

Initiating selection in replacement for Emacs' forward-word

时光毁灭记忆、已成空白 提交于 2019-12-11 04:21:47
问题 I want to replace Emacs' default forward-word and backward-word to operate more like Visual Studio's - which I find better suited to Perl programming. I first tried hacking the syntax table, without achieving the effect I wanted. Then I came up with the following: (defconst perl-movement-stop-chars "a-zA-Z$@%_0-9'") (defconst perl-movement-stop-pattern (concat "[" perl-movement-stop-chars "]")) (defconst non-perl-movement-stop-pattern (concat "[^" perl-movement-stop-chars "]")) (defun perl

Elisp internal variable scoping for a minor mode (setq/make-local-variable/let)

倾然丶 夕夏残阳落幕 提交于 2019-12-11 03:59:51
问题 I've written this little minor mode to get the TAB key to continue indenting after the major mode has performed the initial indent behaviour and/or to force indentation when the major mode thinks no indent is necessary. It has been pointed out to me that the combination setq and make-local-variable can probably be simplified into a let scope. Given that this needs to work across multiple buffers concurrently, how would one change this to use let instead of make-local-variable ? ;;; dwim-tab

EMACS rebinding C-spc disable highlight of selected region

时光毁灭记忆、已成空白 提交于 2019-12-11 03:14:39
问题 EMACS 24.1. I need to Rebind Ctrl-space to a custom function that: go to end of line delete trailing spaces if any set the Mark (as normal Ctrl-space ) This is my code not working: (define-key global-map [?\C- ] 'my-set-mark-command) (defun my-set-mark-command() (interactive) (end-of-line) (delete-char (* -1 (skip-chars-backward "\t\s")));;delete trailing spaces (set-mark-command nil)) When no trailing spaces it works normally: start to select and highlight the region. When trailing spaces:

Temporarly disable adding of newlines in Emacs

孤街浪徒 提交于 2019-12-11 02:49:33
问题 I've enabled require-final-newline , because I usually want Emacs to add newlines to my files where it's missing. But there are some cases, where I want Emacs to remove the newline (like when editing a yasnippet that should not produce a newline, see emacs + latex + yasnippet: Why are newlines inserted after a snippet?). Is there a way to achieve this temporarly (like enabling a mode or something), without having to change .emacs and restarting Emacs? 回答1: In addition to what @eldrich

Elisp interactive function with input history

耗尽温柔 提交于 2019-12-11 02:48:44
问题 there is a bunch of interactive functions which take string input as an argument: (defun zb/run-cmd-X (arg1 argN) (interactive "Marg1: Marg2: ") ;;; some logic How to make each of such functions zb/run-cmd-1 .. zb/run-cmd-N have own independent history of input arguments arg1...argN ? And it would be perfect if this history was persistent between Emacs launches (ideally somewhere in an external file; for sync). Is there any ready solution for this? Thanks 回答1: Basically you want to read the

Strange characters in ansi-term in emacs

风流意气都作罢 提交于 2019-12-11 02:39:32
问题 I wrote a c++ program and when I compiled it using g++ in ansi-term, I got some strange characters displayed: If required, the error was that i hadn't declared the variable n. How can I correct this? 回答1: Ah! Tested this... (setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8-unix) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8) and problem solved!!! 回答2: Looks like the gcc output contains UTF-8 "smart quotes" and your