elisp

In emacs can you evaluate an elisp expression and replace it with the result?

For example if I have the text: Sum of items is (+ 1 2 3) I want to move to the end of the line, evaluate the expression and replace it with the result, so that it reads: Sum of items is 6 ...

How can I execute a SQL query in emacs lisp?

I want to execute an SQL query and get its result in elisp: (let ((results (do-sql-query "SELECT * FROM a_table"))) (do-something-with results)) I'm using Postgres, and I already know all of my connection information (host, username, password, db et al) I just want to execute the query and get the result back, synchronously. ...

How do I get emacs to write to read-only files automatically?

I am finding myself editing a lot of files that are read-only. I usually hit C-x C-q to call toggle-read-only. Then I hit C-x C-s to save and get, File foo.txt is write-protected; try to save anyway? (y or n) After hitting y, the file is saved and the permissions on the file remain read-only. Is there a way to shorten this process ...

How to advise primitives in Emacs

I was trying to answer another SO question when I hit upon some very odd behavior. Here's my little test case: (make-variable-buffer-local (defvar my-override-mode-on-save nil "Can be set to automatically ignore read-only mode of a file when saving.")) (defadvice file-writable-p (around my-overide-file-writeable-p act) "override...

Emacs: Using and initializing CEDET

Hi, I'm using Emacs with CEDET and auto complete for code completion. Originally I set up CEDET so it loads at Emacs start up every time. However, this took quite a long time, so i thought it would be clever to load it just if needed, i.e. - in my case - when entering C++-Mode. So I moved the original function into a lambda that is ...

Emacs custom background color by mode

I use emacs to edit a number of file types, and would like an easy visual queue to tell .c files from .vhd or .py files, for instance. How can I add a custom background color to the major mode for that language? ...

How do I bind <Print Screen> to a macro in emacs?

I would like to be able to hit <Print Screen> in emacs and trigger a commit in a git repository. My lisp is pretty rusty and know this is broken, but don't know where: ( defun tip-local-write nil "Write to store" ( interactive ) ( save-buffer ) ( change-directory "~/tip" ) ( shell-command "git commit -m checkpoint ." ) ...

Emacs lisp question

Hi, I want this function to compile the contents of the current buffer(a C file) and show the output(a.out) if the compilation succeeded (defun c-shell-compile () (interactive) (save-buffer) (if (equal (shell-command (concat "gcc " (buffer-file-name))) "(Shell command succeeded with no output)") (shell-comman...

How to get C-x C-e to display the result in octal and hexadecimal by default?

When I hit C-x C-e on a numeric expression a second time, the mini-buffer displays the result in octal and hexadecimal. This is documented here Is there a way to get the result in hex and octal on the first C-x C-e? ...

viper elisp loop until event

So, in vim, in insert mode, there is C-o which puts you in command mode until a cursor movement. I find this to be very convenient to move around while in insert mode. I know of no equivalent in emacs viper. This question is how to elisp this. Basically it would be something like this (define-key viper-insert-global-user-map (kbd "C-o"...

Emacs 23.2 with ECB 2.40 | File error: Cannot open load file, semantic-ctxt

How I can use the Emacs Code Browser v2.40 with my fresh installed Emacs 23.2 (Debian distro) In my init.el I have: (semantic-mode) (add-to-list 'load-path "~/.emacs.d/plugins/ecb-2.40") (require 'ecb) When I run Emacs, I get an Error message on statrup: File error: Cannot open load file, semantic-ctxt I have read CEDET suite...

query-replace for macros in emacs?

I use the builtin f3/f4 bindings in emacs a lot to record and repeat macros, and find it to be a very powerful and useful feature, especially when combined with search. However, I noticed recently that whenever I do a query-replace (M-S-5 by default) that recording my macro stops! Is there a way to prevent this? I know that query-replace...

Wrong type error in dbus method (GNU Emacs)

Hi all, I am writing an elisp file to integrate GNU Emacs with Zeitgeist over dbus. Because of the lack of good documentation on dbus in emacs and my lack of experience with advanced elisp, I am coming up with the following error in my method zeitgeist-send: Wrong type argument: D-Bus, (zeitgeist-event-timestamp) I have tried cor...

[emacs] retain window configuration for nav-mode?

I often have my emacs frame split vertically so that I have R or Python running in the lower window and a script open in the upper window. When I invoke nav-mode, this configuration is lost. I wonder if there is an easy fix to have nav-mode retain this vertical-split configuration when it opens its own window to the left. ...

What does the double minus (--) convention in function names mean in Emacs Lisp

I've been reading through a number of Emacs Lisp packages and have come across the convention of some functions being declared with -- after the library prefix, e.g.: (defun eproject--combine-regexps (regexp-list) I'm wondering if this a convention for declaring "private" functions to the library but so far I haven't found anything in...

Emacs: Define macro in comment and automatically execute it.

Hello, I'm using Emacs/AucTeX for editing LaTeX files. In some of my LaTeX files, I have defined some "file-specific" command (e.g. \todo{...} in one file, \compute{...} in another, and so on), so I can keep track of what open problems I have in my documents. The Emacs command highlight-regexp does quite a good joob in highlightning al...

Do I need to know Emacs Lisp in order to use GNU/Emacs

Hello, Recently, I began studying GNU/Emacs. Was very easy to use program. Studied its structure. Tuned nice color for me. Configure it to class on C programming. Everything seemed normal. But now the question arose of GNU/Emacs lisp. Should I really spend time to study Emacs Lisp if I did not develop itself Emacs and will only use it l...

In Emacs, how can I have the same buffer open in multple frames (when using ido/iswitch)?

In emacs, I'd like to open the same buffer in multiple frames. Before I used ido, this was easy: I'd just switch to the buffer in one frame with C-x b, then focus a different frame in my window manager, and then open the buffer in that other frame too (with C-x b again.) But, now that I use ido for fuzzy completion in C-x b, when I try t...

How to produce a string of double-quote with emacs lisp?

I need to produce a string with emacs lisp, in which, there must contain double-quote '"'. By studying the string syntax of emacs lisp, I thought "\"" would represent such double-quote. But to my surprise, I the following expression (concat "\"") produced "\"" the '\' being not desired. Please teach me how I can produce a pure double...

How can I know if I run emacs or aquamacs at the .emacs file?

I want to make different environment between Cocoa emacs and Aquamacs. They both read ~/.emacs, so I tried something like this. (unless (symbolp 'aquamacs-version) ; code for emacs ) But it doesn't seem to work. How can I know if I run emacs or aquamacs? ...