elisp

emacs: what is the purpose of (eval-and-compile...)?

I can read the documentation, so I'm not asking for a cut-n-paste of that. I'm trying to understand the motivation for this function. When would I want to use it? Thanks. ...

Change nil's to zeroes in elisp

Hi all I'd like to ask - what is the function doing nil conversion from nil's to zeroes in elisp? I'm a newbie and I think I am inventing the wheel with my code: (defun chgnull (x) (if (null x) 0 1)) (mapcar 'chgnull '(1 2 nil)) Search through Emacs sources by keyword "to zero" and such haven't shown anything relevant. ...

How to indent a buffer in ESS?

ESS allows us to indent a line and an expression. Is there a key binding for indenting a buffer? If not, can we create it? ...

How to set a key binding to make Emacs as transparent/opaque as I want?

I want to have a command in Emacs to make it as opaque/transparent as I want (refer to the fabulous question that pointed out that transparency is possible in Emacs, and the EmacsWiki page linked there which has the code I am using below). The EmacsWiki code sets "C-c t" to toggle the previously set transparency on and off: ;;(set-fram...

[emacs] make ibuffer-visit-buffer behave like ido-switch-to-buffer?

Is there a way to make ibuffer-visit-buffer behave like ido-switch-to-buffer (with raise-frame option)? If there is a window/frame containing the buffer I'd like emacs to take me there rather than opening the same buffer in the current window. I guess switch-to-buffer is remapped to ido-switch-to-buffer when ido-mode is turned on, so wou...

emacs delete directory recursively?

I was searching through for a way to copy/delete directory trees... dired seems to have dired-copy-file-recursive (though sans documentation) and a search on 'recursive' also returns: tramp-handle-dired-recursive-delete-directory is a compiled Lisp function in `tramp.el'. (tramp-handle-dired-recursive-delete-directory FILENAME) Recur...

How can you make an emacs macro wait for cscope query results?

I am trying to write a macro which calls cscope-find-functions-calling-this-function on each and every tag in a file displayed in the *Tags List* buffer (created by list-tags command). This should create a buffer which contains list of all functions calling a set of functions defined in a certain file. I just position the point at the s...

Is there such a thing as an "elisp bundle" for TextMate?

I started using Code Collector Pro to organise and save my Emacs codes, and this software requires TextMate bundles for syntax highlighting. They have a lisp bundle, but not an elisp bundle, at least not that I can see. I would think that the syntax highlighting would work under the lisp bundle, but for some reason it isn't happening. I...

emacs lisp spawning subprocesses with custom environmental variables

Basically I want to spawn a process changing its working directory. My idea was to spawn a process and set the PWD enviroment variable. There's a way to obtain something like that? (virtually I would like to change any of the environment variables for flexibility) ...

Getting emacs indentation to work correctly in major mode

Hi, I am writing a major-mode in emacs for a DSL I've created. I'm inheriting from fundamental-mode, which tabs out way far (6 tab stops, I think). I'd like to be able to define: (setq mydsl-tab-width 4) and have that work. ...

emacs lisp number crunching (actually, simple addition)

Hi, this is what I get when I try to do some calculations in emacs lisp... (+ 2082844800. 1274511600.0) => 1209872752.0 (+ 2082844800.0 1274511600.0) => 3357356400.0 Could anyone tell me what's going on and what's the difference between representing a floating-point number with . and .0 at the end? Thanks ...

Refactoring R code using ESS/R

I would like to know if it is possible to refactor R code in ESS. Using search and replace in Emacs does not seem to be a good alternative to it. ...

emacs lisp mapcar doesn't apply function to all elements?

Hi, I have a function that takes a list and replaces some elements. I have constructed it as a closure so that the free variable cannot be modified outside of the function. (defun transform (elems) (lexical-let ( (elems elems) ) (lambda (seq) (let (e) (while (setq e (car elems)) (setf (nth e seq) e) (setq ele...

uses for dynamic scope?

Hi, I've been getting my hands wet with emacs lisp, and one thing that trips me up sometimes is the dynamic scope. Is there much of a future for it? Most languages I know use static scoping (or have moved to static scoping, like Python), and probably because I know it better I tend to prefer it. Are there specific applications/instances ...

Accessing StackExchange API from Emacs

I am trying to access the StackExchange API from Emacs' elisp: (require 'url) (require 'json) (defvar url-http-end-of-headers) (defun read-json () (interactive) (with-current-buffer (url-retrieve-synchronously "http://api.stackoverflow.com/0.8/users/2386") (goto-char url-http-end-of-headers) (json-read))) M-x read-json resul...

How can I highlight different types of file in dired mode in Emacs?

In a nutshell, I want to have different faces for some types of file in dired mode. I don't think it matters, but I am using Aquamacs. The example I will use here is .tex files. If I can do it for .tex, then I can just apply the same structure to do create other faces for other types of files. From what I understand, I have to create a...

emacs exporting org file as PDF in batch mode

I'm trying to export a bunch of org mode files to PDF using emacs in batch mode. So far, only export to html seems to work. When I export to html I see the following - U:\tmp>d:\programs\emacs-23.1\bin\emacs.exe -batch --visit=Changelog.org --funcall org-export-as-html-batch OVERVIEW Exporting... Exporting... S...

Correct use of apply in Emacs Lisp?

I'm not sure whether the use of apply is recommended here. Is there a better/standard solution for setting the major mode dynamically? I couldn't find any other. Background: Whenever I get the X has auto save data; consider M-x recover-this-file message in Emacs, I wonder what the difference between the current file and the auto-sa...

Extend Emacs to edit encrypted text files

I am trying to add special handling to emacs to handle Triple-DES encrypted files (any file with extension .des3 is assumed to be a valid encrypted text file). My approach is to append to format-alist, like so: (setq format-alist (cons (list 'des3 "Triple-DES encrypted files" ".*\.des3" "show" "" t nil) fo...

check if current emacs buffer contains a string

I have a buffer open in emacs. I want a function that will return t if the current buffer contains the string, otherwise it returns nil. (defun buffer-contains-substring (string) ... ) ...