elisp

Emacs Lisp, how to monitor changes of a file/directory

I'm looking for a way to check periodically if a files under a certain directory were changed from the last check (a functionality symilar to FAM daemon or to gio.monitor_directory). In emacs lisp. Are there any library/snippet that provide this functionality? If not, how can I implement such a function? ...

Scheme and Clojure don't have the atom type predicate - is this by design?

Common LISP and Emacs LISP have the atom type predicate. Scheme and Clojure don't have it. http://hyperpolyglot.wikidot.com/lisp Is there a design reason for this - or is it just not an essential function to include in the API? ...

How to get emacs to highlight and link file paths

Is there some emacs lisp code that would automatically find /nfs file paths in the buffer and highlight/link to them? So clicking on them would open that file? Example path: /nfs/foo/bar/file.txt ...

Popping an element from an association list in lisp (elisp)

I'm searching for a way to "pop" an element from an association list, in other words a "destructive" assoc: (setq alist '((a . 1) (b . 2)) (assoc-pop 'a alist) ;; -> (a . 1) ;; alist -> ((b . 2)) Are there any function in the elisp harness? What's the most elegant way to obtain a symilar functionality? (not sure about that this sort o...

Show Keys In Emacs Keymap Value

When I query the current value of the keymap it shows me something along these lines: Value: (keymap (S-mouse-2 . muse-follow-name-at-mouse-other-window) (mouse-2 . muse-follow-name-at-mouse) (33554445 . muse-follow-name-at-point-other-window) (S-return . muse-follow-name-at-point-other-window) (13 . muse-follow-name-at-point) (...

Unreadable buffer names in Emacs 23.2

I just upgraded from Emacs 21.2 to 23.2 (on Windows XP) and while I managed to tweak my .emacs to fit the new changes, I couldn't find a solution for the unreadable buffer names: Neither in the minibuffer, nor in the buffer menu can the characters be displayed normally. Instead, all I see are the infamous Unicode blank rectangles. Any ...

Emacs - random color theme every hour?

I know that to (funcall (car (nth (random (length color-themes)) color-themes))) gives me a random color theme on every Emacs startup; but I hardly restart Emacs. How do I cycle between random color themes, say, every hour? ...

Emacs modes for flex and bison, or removing auto indent for these modes?

Emacs has poor handling of auto-indentation in Flex and Bison. In fact, it seems to have no support for flex mode. So, how does an emacs user cope with these? I like VIm but I would prefer not to switch because I am much faster and more comfortable in Emacs. I had a third party elisp module for Bison a few months ago but when its inden...

Setting auto-mode-alist in emacs

I notice that the current auto-mode-alist entries all end with a single quote, for example ("\\.java\\'" . java-mode) What is the purpose of the single quote. I would have expected to see ("\\.java$" . java-mode) The reason I ask is that I am trying to get files with names matching regexp ^twiki\.corp.* to open in org-mode....

replace regexp r by R if cursor is not on r in emacs

Suppose you visit a file F in an emacs buffer B, let r and R be some replacement regular expressions. Now I want to replace all occurrences of strings r_i which matches r (in some region) by the corresponding replacement-string R_i defined by R such that the following conditions are fulfiled: if I save F, the above replacement must not...

Can some please explain this elisp regexp

Can some please explain the following regexp, which I found in ediff-trees.el as a specification for which files/directories to exclude from its comparison process. "\\`\\(\\.?#.*\\|.*,v\\|.*~\\|\\.svn\\|CVS\\|_darcs\\)\\'" Although I am somewhat familiar with regular expressions encountering this elisp string-based variant has throw...

Call to defmacro with a quoted symbol

I have this data structure (basically): (setq ssm-list '(tasklist ((id . "10525295") (name . "Inbox") (sort_order . "0")))) This works for getting the name: (defun ssm-list-get-prop (list prop) (cdr (assoc prop (car (cdr list))))) (ssm-list-get-prop slack-one-list 'name) What'd I like is to create a macro that will creat...

emacs lisp listing files with glob expansion

Are there any library or function that performs a bash-like glob expansion for emacs lisp? For example: (directory-files-glob "~/Desktop/*") > ("/home/user/Desktop/file1" "/home/user/Desktop/file2") If there isn't such a function are there any hint/suggestion on how to implement it? EDIT: I've found in the docs also an useful funct...

Where did dired-omit-toggle disappear in Emacs 23.2?

The challenge of upgrading from Emacs 21.2 to 23.2 continues... In my .emacs I have the very convenient: (global-set-key (quote [f4]) (quote dired-omit-toggle)) It used to work since Emacs 18... but it no longer works in Emacs 23.2: Lisp error: (void-function dired-omit-toggle) Any idea how I can replace this functionality in ...

Is there a function in elisp to apply a patch to a buffer?

I am working on an emacs mode for a review tool, and want to use ediff for viewing diffs... the problem is that the review tool only yields a diff, rather than old and new files. I'd like to put the old file in a buffer and apply a diff rather than copying the file, calling out to diff as a subprocess and loading it into a separate buffe...

writing lisp emacs key binding and cannot specify the <delete> character

Hello, For some reason I got the default M-del key binding for backward-kill-word mapped to a scan for matching brackets and resetting is not working, so I am trying to set the global key binding in lisp. So I wrote in ~/.emacs.d/init.el the lisp commands: (global-set-key (kbd "M-h") 'backward-kill-word) (global-set-key (kbd "M-<\dele...

PPRINT in Emacs Lisp?

Emacs Lisp does not seem to have a PPRINT function. How do you pretty print an S-EXP in elisp the way you can in Common Lisp? Thanks! ...

Run a process and get the result in clipboard (or kill ring) with elisp/emacs.

I use the following code to run "ls -l ./" and get the result in scratch buffer. (start-process "my-process" "*scratch*" "ls" "-l" "./") How can I get the result in clipboard or something (kill ring or whatever) so that I can easily copy the result whenever necessary? ...

Filtering result from running start-process in emacs/elisp.

I have the following code to run python and get the result in scratch buffer. (defun hello () "Test, just prints Hello, world to mini buffer" (interactive) (start-process "my-process" "*scratch*" "python" "/Users/smcho/Desktop/temp/hello.py") (message "Hello, world : I'm glad to see you")) (define-key global-map "\C-ck" 'hello)...

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

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...