elisp

Algorithm to calculate the target-year of the target-month — 12 month *Calendar*

点点圈 提交于 2019-12-12 02:34:25
问题 GOAL : The goal of this thread is to create a mathematical formula to replace the long-hand solution by @lawlist in the function lawlist-target-year-function (below). NOTE : The solution to this thread is somewhat similar, but will nevertheless be different, than the algorithm written by @AShelly in a related thread: https://stackoverflow.com/a/21709710/2112489 STORY PROBLEM There now exists a 12-month calendar in Emacs that scrolls forwards and backwards one month (or more) at a time. A

How to set an element in a multi-dimensional array in elisp

梦想的初衷 提交于 2019-12-12 02:15:24
问题 I am working with someone using elisp and we have been struggling to use multi-dimensional arrays. The problem is that if we try to set a value using (setf (elt (elt m-array 0) 0) 5)) We end up getting something like this [[0 0 0 5] [0 0 0 5] [0 0 0 5] [0 0 0 5]] which is not what we want. Now Common Lisp has the support we need to get around this. Unfortunately though, we are only able to work with elisp. My question is, given that we only have elisp, how can we work around this such that we

Lisp: quoting a list of symbols' values

ε祈祈猫儿з 提交于 2019-12-12 00:27:47
问题 How do I create a quoted list in Lisp that uses the symbols' values in the list, rather than the symbols themselves? For example, take two variables foo and bar , foo = "hello" and bar = "world" . How do I get a list that contains "hello" "world" from these two variables. The best thing I can think of is this: ;; This is Emacs Lisp (let ((foo "hello") (bar "world")) (message (prin1-to-string '(foo bar))) ;; prints "(foo bar)" But this is wrong. What's the right way to do this? 回答1: Never mind

Incorporate variable name into `dolist` cycle and change its value

て烟熏妆下的殇ゞ 提交于 2019-12-11 20:26:02
问题 I am trying to incorporate the name of a buffer-local variable into the dolist cycle, and change the value of that buffer-local variable. setq and setq-local reject all of the variable name variations that I have tried. In the dolist cycle, the variable name is (car (car (cdr test))) . The same variable name will be used in more than one buffer, with each buffer having a different value. This project is related two (2) other recent threads of mine, but I believe this is a somewhat unique

Emacs: apply minor mode for all major modes [duplicate]

拟墨画扇 提交于 2019-12-11 20:22:01
问题 This question already has an answer here : How to enable a non-global minor mode by default, on emacs startup? (1 answer) Closed 5 years ago . I use the minor mode writeroom which I have set to be global, but this setting only makes the mode global for all text-modes. I can specify more modes in the settings. But is there something I can write to enable this minor mode for all major modes? 回答1: Add a hook to find-file : (add-hook 'find-file-hook #'writeroom-mode) Substitute #'writeroom-mode

ELisp: cl-loop for “Symbol's value as variable is void”

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 14:37:02
问题 I'm trying to loop over a pair of lists using (cl-loop for ..) but I keep getting "Symbol's value as variable is void: mode" when the code executes at startup (and with eval-buffer ), but not when evaluating it with eval-region . ;; clean up the modeline (require 'diminish) (defmacro diminish-after-load (file mode) "After loading FILE, execute `diminish' on MODE." `(eval-after-load ,file '(diminish ,mode))) (require 'cl-lib) (cl-loop for file in '("eldoc" "rainbow-mode" "hideshow" "flyspell"

local keymap for emacs outline-minor-mode

自古美人都是妖i 提交于 2019-12-11 14:15:29
问题 I want to set the outline-minor-mode for init.el file and when TAB key is pressed on the lines starting with ; the function outline-toggle-children should be called in order to fold and expand the sub headings. Below is the code for hook. But it does not work for the "TAB" key binding as expected. (add-hook 'emacs-lisp-mode-hook (lambda () (if (equal (buffer-name) "init.el") (progn (outline-regexp "^;+") (outline-minor-mode 1) (local-set-key (kbd "TAB") ; this does not work (lambda () (if

In emacs, how to execute external command not as a emacs process?

泪湿孤枕 提交于 2019-12-11 13:58:58
问题 For some external program (not all), I want the program running independently outside Emacs, after executing the command. In another word, if I close Emacs, the external program can still run. PS: my operating system is windows. 回答1: I think (w32-shell-execute "start" "myprog" "args") should do the trick. 来源: https://stackoverflow.com/questions/14335853/in-emacs-how-to-execute-external-command-not-as-a-emacs-process

How to speed-up a custom mode-line face change function in Emacs

柔情痞子 提交于 2019-12-11 13:07:05
问题 The following function named my-modeline-face-function causes Emacs to pause for approximately one-half to one full second, and I'm looking for some suggestions please to significantly increase the speed. It doesn't seem like much, but this function is used a lot. For example, every time I enable multiple-cursors mode (aka mc-mode), I end up twiddling my thumbs before I can get down to business -- the same thing happens when exiting multiple-cursors mode. Adding (redisplay t) at the tail end

Emacs Lisp nested function - void-variable error

社会主义新天地 提交于 2019-12-11 12:49:06
问题 I want to make a timer, like this one: (defun dumb (y) (defun P () (print y)) (run-with-timer 0 5 'P)) (dumb 5) Then Emacs gives me this error: Error running timer `P': (void-variable y) I guess the problem is that in the (defun P () (print y)) line, the variable y is not evaluated, so when I run (dumb 5) , the function P tries to print y , which is undefined, instead of a literal 5 . But I don't know how to solve it. Any idea? 回答1: First, defun is for defining functions in the global scope.