elisp

How to run hook depending on file location

心已入冬 提交于 2019-12-21 17:19:26
问题 I am involved in python project where tabs are used, however i am not using them in every other code i write, it is vital to use them in that particular project. Projects are located in one directory under specific directories. I.E: \main_folder \project1 \project2 \project3 ...etc I have couple functions/hooks on file open and save that untabify and tabify whole buffer i work on. ;; My Functions (defun untabify-buffer () "Untabify current buffer" (interactive) (untabify (point-min) (point

How to get the start/end of the current buffer info with emacs/elisp?

时光总嘲笑我的痴心妄想 提交于 2019-12-21 13:05:11
问题 I have the following code that runs figlet that has input as a range. How can I modify this code to check if b or e is not specified, make b to the start of the current buffer, and e end of the current buffer? (defun figlet-region (&optional b e) (interactive "r") (shell-command-on-region b e "/opt/local/bin/figlet" (current-buffer) t) (comment-region (mark) (point))) (global-set-key (kbd "C-c C-x") 'figlet-region) ADDED Sean helped me to get an answer to this question (defun figlet-region (

Why is there no tail recursion optimization in Emacs lisp, not but like other scheme?

我的未来我决定 提交于 2019-12-21 12:44:31
问题 Emacs lisp is a dialect of LISP and especially Scheme. Most of scheme interpreters do have a optimization of Tail Recursion, but emacs lisp doens't. I searched the reason in `info elisp' for a while, but I fail to find it. P.S. Yes, there is other iteration syntax in elisp like `while', but I still cannot find a good reason why they didn't implement tail recursion like other scheme interpreters. 回答1: Emacs Lisp was created in the 1980's. The Lisp dialect that the Emacs author (Richard

Does (function) serve any purpose in Emacs?

你说的曾经没有我的故事 提交于 2019-12-21 11:29:53
问题 From the documentation of the function form: Like `quote', but preferred for objects which are functions. In byte compilation, `function' causes its argument to be compiled. `quote' cannot do that. So one would do #'(lambda ...) to enable byte compilation of the lambda form. On the other hand, as mentioned in the manual, That is no longer necessary. The lambda form has one other effect: it tells the Emacs evaluator and byte-compiler that its argument is a function, by using function as a

Emacs/GDB: always display source in specific window with gdb-many-windows

若如初见. 提交于 2019-12-21 10:06:01
问题 I use GDB in Emacs 24 with gdb-many-windows set to t , usually in its own frame. I like to have a separate editing frame. It looks like this (apologies for my crude ASCII diagram): +-------------+-------------+ | gdb | locals | +-------------+-------------+ | source | I/O | | | | +-------------+-------------+ | stack | breakpoints | +-------------+-------------+ This works pretty well except for one big problem. Whenever gdb needs to display a different source buffer, e.g., after up/down/step

Emacs: how to get the default theme?

强颜欢笑 提交于 2019-12-21 07:38:58
问题 I've been using the default theme with about 10 faces changed via custom-set-faces for a while now. But from time to time I want to try out a couple of the custom themes out there. The problem is that they set much more than 10 faces and there's no way to get back to my previous setup once I've loaded a custom theme. Just to clarify: I start Emacs with my customization of the default theme (load "faces") . All is good. load-theme wombat . All is good. (load "faces") again: everything is a

Why use #' before function arguments in emacs-lisp?

佐手、 提交于 2019-12-21 07:03:17
问题 I'm familiar with Emacs Lisp, but not Common (or any other) Lisp. Some Lisp programmers suggest (e.g. A basic function for emacs) that it's good to use #' in front of function arguments in Lisp code. For example: (mapc #'my-fun '(1 2 3)) In Emacs Lisp, I believe that this is equivalent to (mapc 'my-fun '(1 2 3)) From the elisp manual, section 12.7. The read syntax #' is a short-hand for using function . The following forms are all equivalent: (lambda (x) (* x x)) (function (lambda (x) (* x x)

Hiding markup elements in org-mode

前提是你 提交于 2019-12-21 06:47:50
问题 There are plenty structural markup elements in org-mode like *bold* or /italic/ , but they are visible in the org-mode text, which is good, if the file is intended for export, and bad, if it is intended for semi-WYSIWYG editing. I want to hide these markup symbols, so the *bold* becomes bold , just like links hide their square brackets. Is that possible in org-mode out of the box? If not, then please suggest an elisp code, that can solve this problem. 回答1: Try: (setq org-hide-emphasis-markers

org--agenda-prefix-format %? does not work

ぐ巨炮叔叔 提交于 2019-12-21 06:04:11
问题 Currently, I have my global TODO list shown as follows thanks to erikstokes: (org-agenda-prefix-format " %i %?-12(concat \"[ \"(org-format-outline-path (list (nth 1 (org-get-outline-path)))) \" ]\") "))) which outputs: for org layout: However, as you can see, for Task A, even though there is nothing in the project, it still shows up on the list. describe-variable for org-agenda-prefix-format says : If the first character after `%' is a question mark, the entire field will only be included if

Emacs defadvice on python-mode function

让人想犯罪 __ 提交于 2019-12-21 05:03:41
问题 In python-mode, there is a function called py-execute-region which sends a highlighted region of code to the Python buffer for evaluation. After evaluation, the cursor is in the Python buffer, but I would prefer that it remain in the script buffer so I can continue producing more code. I wrote a simple advising function: (defadvice py-execute-region (after py-execute-region-other-window activate) """ After execution, return cursor to script buffer """ (other-window 1) ) But this does not do