elisp

A basic function for emacs

☆樱花仙子☆ 提交于 2019-12-11 12:47:23
问题 I have never written an emacs function before and was wondering if anyone could help me get started. I would like to have a function that takes a highlighted region parses it (by ",") then evaluates each chunk with another function already built into emacs. The highlighted code may look something like this: x <- function(w=NULL,y=1,z=20){} (r code), and I would like to scrape out w=NULL , y=1 , and z=20 then pass each one a function already included with emacs. Any suggestions on how to get

Smarter `ff-find-other-file`

我是研究僧i 提交于 2019-12-11 12:14:31
问题 I'm working on a project where the source is organised in the following directory structe: ./source/include ./source/include/analysis ./source/include/tools ./source/include/utils ./source/include/utils/stream ./source/include/utils/string [...] ./source/src ./source/src/analysis ./source/src/tools ./source/src/utils ./source/src/utils/stream ./source/src/utils/string [...] Where each subdirectory of ./source/include/ (including ./source/include/ ) contains header files. Similarly every

Per newsgroup timezone in Date: header

若如初见. 提交于 2019-12-11 12:06:22
问题 How to configure emacs/gnus to use per newsgroup time zone in posted messages? I would like to use CET time zone in pl.* newsgroups and UCT in general newsgroups. 回答1: I would use message-header-setup-hook or message-send-hook with this function: (defvar date-rewrite-rules '(("pl" . return-time-string-in-CET) ("." . return-time-string-in-UTC))) (defun rewrite-date-based-on-newsgroup () (save-excursion (save-restriction (widen) (goto-char 0) (narrow-to-region 0 (search-forward mail-header

Losing cursor location with save-excursion after replace-match

自作多情 提交于 2019-12-11 11:30:21
问题 In this answer, I use a regular expression search/replace to convert from one type of ruby block to another. However, after the function ruby-flip-containing-block-type is done, the point is moved to the beginning of the replaced text, even though there is a save-excursion around the function. I even tried saving the point to a register and jumping back to it after the flip. The saved point is relocated to the beginning of my changes. After some google searches, I think the problem lies with

Using a defstruct database with remove-if-not

两盒软妹~` 提交于 2019-12-11 11:29:00
问题 I'm trying to adapt this defstruct example by adding the select- functions described in the book: Practical Common Lisp. I'm running the code in Emacs using the Common Lisp package. The select-by-first does not return anything. In the Lisp book, the author does not use defstruct so I must need to do something slightly different? (defun select-by-first (first-name) (remove-if-not #'(lambda (employee) (equal (getf employee :first-name) first-name)) *emp-db*)) (select-by-first "steve") The

Org-mode: using special properties in the drawer

戏子无情 提交于 2019-12-11 11:23:31
问题 Org manual says special properties "should not be used as keys in the properties drawer" . However i want to use org-mode on a more high level and i want to put all special properties in the :PROPERTIES: drawer. This can be used for many reasons, for example, i can write an external parser, that can understand org-mode files, that consist of only entries with properties, without needing to know about TODO, tags, priorities and their syntax in the headline. This should change the behavior of

How is sharp quote (#') different from symbol-function?

↘锁芯ラ 提交于 2019-12-11 10:59:25
问题 To me these operators seem to do the same thing. Both take a symbol and return the function associated with it. Is there any difference? elisp evaluation returns the following: (defun foo (x) (+ 1 x)) foo (foo 3) 4 #'foo Which I don't understand either. Furthermore is there a difference between common lisp and elisp? I'm learning from resources on either. 回答1: Common Lisp : SYMBOL-FUNCTION can't retrieve functions from lexically bound functions. FUNCTION references the lexically bound

Emacs — remove an overlay `after-string` with a variable value

梦想的初衷 提交于 2019-12-11 10:35:36
问题 What is the proper way, please, to remove after-string overlays with variable values? When using C-u C-x = , it only shows up as after-string without stating what the value is. For example, once I lay an overlay using (overlay-put (make-overlay (point) (point)) 'after-string my-concatenated-string) , I would like to be able to delete it without programming Emacs to remember every single my-concatenated-string that was previously used in the buffer -- there might be a few different ones on

elisp: read file into list of lists

久未见 提交于 2019-12-11 10:23:59
问题 I need to read a file contents into a two-dimensional list, split by newlines and spaces. For example, a b c d needs to become (list (list "a" "b") (list "c" "d")) Currently I only know how to read the contents into a simple list determined by newlines. Whenever I need to use an element from that list, I have to split it by spaces everytime, but preferably this should be done only once beforehand. 回答1: Like this: (with-current-buffer (find-file-noselect "~/foo") (mapcar (lambda (x) (split

Enter Beg End parameters automatically in Evil-Visual-Mode

偶尔善良 提交于 2019-12-11 08:46:01
问题 I see some functions like evil-change or evil-delete are take in the beginning and end of a visual region in evil-visual-state. I've looked at the source code in "evil-commands.el" of these functions but their 'beg' and 'end' parameters just seem to come out of nowhere. And some (such as the one below) aren't even interactive. Why this is and how I can do the same thing in my own methods? Below is just an example of one of the methods I looked at: ;; Defined in ~/.emacs.d/elpa/evil-20170712