elisp

How to delete variable/forms in Lisp?

被刻印的时光 ゝ 提交于 2019-12-09 08:43:59
问题 In Python we have the del statement for deleting variables. E.g: a = 1 del a What the equivalent of this in Lisp? (setq foo 1) ;; (del foo) ? 回答1: In Common Lisp. For symbols as variables: CL-USER 7 > (setf foo 42) 42 CL-USER 8 > foo 42 CL-USER 9 > (makunbound 'foo) FOO CL-USER 10 > foo Error: The variable FOO is unbound. See: MAKUNBOUND (defined) SLOT-MAKUNBOUND (defined) FMAKUNBOUND (defined) 回答2: Python names reside in namespaces, del removes a name from a namespace. Common Lisp has a

In Emacs, how do I display a message in the minibuffer with font face properties?

寵の児 提交于 2019-12-09 08:26:53
问题 I want to display a colored string of text in the minibuffer, but when I use the 'message' function, the text-properties of are stripped. 回答1: Works for me: (message "%s" (propertize "foo" 'face '(:foreground "red"))) You probably had (message (propertize ...)) , which interprets the propertized string as a format control string, hence stripped of its properties. 来源: https://stackoverflow.com/questions/2742435/in-emacs-how-do-i-display-a-message-in-the-minibuffer-with-font-face-properties

Getting a list of running Emacs timers

扶醉桌前 提交于 2019-12-09 05:04:22
问题 I've created a timer and stored a reference to it in Emacs with (setq my-timer-store (run-at-time "1 min" 900 'my-func)) I usually execute this elisp in the morning and then stop it from running overnight by executing (cancel-timer my-timer-store) Unfortunately I started the timer twice (without cancelling it in between) so I no longer have a reference to the first one I started and therefore I can't cancel it. Is there a way of listing all the running timers so I can clean up the one I left

Searching with intelligent bracket counting (Elisp)

≯℡__Kan透↙ 提交于 2019-12-09 04:14:30
I have the following function that deletes the LaTeX command surrounding the current cursor position: (defun remove-tex-cmd () (interactive) (save-excursion (let (cur-point beg-point end-point) (setq cur-point (point)) (catch 'notexcmd (if (not (re-search-backward "\\.*?{" nil t)) ; now the point is at the { (throw 'notexcmd nil)) (search-backward "\\" nil t) (setq beg-point (point)) (re-search-forward "}") (setq end-point (point)) (if (> end-point cur-point) (kill-region beg-point end-point)) (throw 'notexcmd nil))) (if 'notexcmd (message "no tex command at point")))) It works well except for

Render Markdown in Emacs buffer

試著忘記壹切 提交于 2019-12-09 04:03:43
问题 Is it possible to present Markdown rendered in an Emacs buffer using Emacs' own buffer text formatting capabilities? Emacs in graphical environments has rich text presentation capabilities (font styles, colors, links and even images) so it should be quite possible. Are there any existing implementations? Note that the idea is to have the rendered Markdown be native Emacs formatted text that can be navigated and operated on as any other text in Emacs. Therefore solutions that render to an

Emacs takes unbelievably long to start

帅比萌擦擦* 提交于 2019-12-09 03:05:07
问题 Yesterday, I :q 'd Vim to try Emacs for a while. I've started using Elisp (which is a hundred times better than VimScript), but even when I first installed it (via yum ), and had changed nothing, it took about 30 seconds to start, and still does (both GUI and -nw ). I checked the *Messages* buffer: Loading /usr/share/emacs/site-lisp/site-start.d/desktop-entry-mode-init.el (source)...done Loading /usr/share/emacs/site-lisp/site-start.d/rpmdev-init.el (source)...done The files seem to be

In post-command-hook, this-command for kill-word has turned into kill-region somehow

[亡魂溺海] 提交于 2019-12-08 21:08:46
问题 In my post-command-hook callback, when I do kill-word , the this-command var is kill-region - and not kill-word as expected. I guess that's because kill-word uses kill-region , but knowing exactly which command was used is essential to my script. Any way to get at that information somehow? Thanks 回答1: Turns out all the kill-commands change this-command to kill-region so they can interoperate on appending things to the kill ring. To get to the actual command, emacs has this-original-command -

How to calculate difference between two sets in emacs lisp,the sets should be lists

故事扮演 提交于 2019-12-08 19:40:11
问题 How to calculate the difference between two sets in Emacs Lisp? The sets should be lists. The programm should be very simple and short, or else I won't understand it. I'm a newbee. Thx 回答1: There is a set-difference function in the Common Lisp extensions: elisp> (require 'cl) cl elisp> (set-difference '(1 2 3) '(2 3 4)) (1) 回答2: When I write Elisp code that has lots of list data transformations, I use dash library, because it has loads of functions to work with lists. Set difference can be

Keep Emacs from scrolling past end of buffer

我的未来我决定 提交于 2019-12-08 19:20:44
问题 Is there anything I can add to my .emacs file to keep emacs from adding new lines when I scroll past the end of the buffer with my mouse or the scrollbar? I already have (setq next-line-add-newlines nil) but that seems to only be applying to when I am moving with the keyboard. I've done quite a few searches on the subject to no avail. Any tips are greatly appreciated! Thank you. 回答1: Check the value of the the variable next-line-add-newlines in the buffers/modes that it's misbehaving. You can

Insert whole month of dates in Emacs Lisp

对着背影说爱祢 提交于 2019-12-08 19:19:05
问题 I'm doing a bit of programming here and there in Emacs Lisp, but I'm not entirely sure how to go about certain things. I'm trying to insert a whole month of dates, each on a new line like the list below: January 01/01/09 Mon: 02/01/09 Tue: 03/01/09 Wed: etc How would I go about doing that? I've found how to format dates, but I can't find how to loop over a certain range of dates (in this instance to loop round a whole month and print a date for each day in the month). Has anyone got some