I'm trying to write simple Emacs function to convert ids between C style ones and camelCase ones (i.e. c_style <-> cStyle). But for some reason, Emacs built in downcase function leaves the word intact. M-x downcase-word works fine so I completely lost. Any ideas are welcome.
(defun toggle-id-style ()
"Toggle between C-style ids and ca...
I customize Emacs a lot. Recently, I added something to my .emacs configuration that sporadically pegs my CPU at 100%, but I really don't know what it is.
If I press C-g a bunch of times, eventually I'll get a message below the minibuffer asking me if I want to auto save my files and then if I want to abort emacs entirely. If I keep sa...
I implemented a small function, which parses an SQL INSERT statement and highlights a column value when a cursor is on a column name and vice versa.
Then I wanted to add a possibility to quickly jump between column name and column value. I used push-mark in my implementation, so I can jump with C-x C-x (exchange-point-and-mark). It wor...
Hi,
I would like to write a function which takes action if a give buffer name already exists. For example:
(if (buffer-exists "my-buffer-name")
; do something
)
Does elisp have a function that will check the for the existence of a buffer similar to how my made up "buffer-exists" function does?
Thanks
...
I've recently started using ido-mode, which, overall, is pretty nice. But one thing seems especially broken, and I'm wondering if there's a setting (ha) buried in there to fix it.
ido-switch-buffer doesn't seem to care about buried buffers. That is, if I use bury-buffer, and then ido-switch-buffer, the first choice is often the one I ...
In Vim the * key in normal mode searches for the word under the cursor. In GNU Emacs the closest native equivalent would be:
C-s C-w
But that isn't quite the same. It opens up the incremental search mini buffer and copies from the cursor in the current buffer to the end of the word. In Vim you'd search for the whole word, even if you ...
This works:
(+ 1 2 3)
6
This doesn't work:
(+ '(1 2 3))
This works if 'cl-*' is loaded:
(reduce '+ '(1 2 3))
6
If reduce were always available I could write:
(defun sum (L)
(reduce '+ L))
(sum '(1 2 3))
6
What is the best practice for defining functions such as sum?
...
I'd like to find elisp's analog of:
sum(n for n in numbers if n % 2) # Python
numbers.select { |n| n % 2 != 0 }.inject { |a, b| a + b } # Ruby
Imperative way:
(defun oddp (number)
(not (= (mod number 2) 0)))
(defun sum-odd-with-dolist (list)
(let ((acc 0))
(dolist (item list acc)
(if (oddp item)
(setq acc (+ ...
I spend a lot of my time in emacs, and for the most part it's wonderful. But one thing really drives me nuts when I'm deep in it, and that's control over which window various new buffers are opened in. When I do find-file, it always opens in the current window, and this is what I like. But tons of other modes like to split my windows for...
I'm trying to create a function on the fly that would return one constant value.
In JavaScript and other modern imperative languages I would use closures:
function id(a) {
return function() {return a;};
}
but Emacs lisp doesn't support those.
I can create mix of identity function and partial function application but it's not sup...
I edit my StackOverflow answers and questions with ViewSourceWith
and Emacs. Often, I include code and StackOverflow formatting rules
say that it must be indented by four spaces to be recognized as
such. Doing it by hand or even with macros is painful.
I searched in SO's previous postings but found nothing.
Starting from the Python mod...
I know there's got to be a built-in function to decode a URL-encoded string (query string) in Emacs Lisp, but for the life of me I can't find it today, either in my lisp/ folder or with google.
Anybody remember what it's called?
...
I frequently find myself typing on a line, when I realize I need(ed) a variable definition (or something similar) on the line above. What I would like is to
press C-return from anywhere on a line and have the cursor move to a newly inserted blank line above, with correct indentation (or at least the same as the original line).
be able...
I'm trying to write a macro in emacs lisp to create some 'helper functions'
Ultimately, my helper functions will be more useful that what I have here. I realize that there may be better/ more intuitive ways to accomplish the same thing (please post) but my basic question is why won't this work/ what am I doing wrong
(defmacro deftext (...
I have the following code
(defun avg-damp(f)
#'(lambda(x) (/ (+ (funcall f x) x) 2.0)))
A call
(funcall (avg-damp #'(lambda(v) (* v v))) 10)
returns 55.0 (the correct value) in SBCL but crashes with the following stack in emacs lisp
Debugger entered--Lisp error: (void-variable f)
(funcall f x)
(+ (funcall f x) x)
(/ (...
Often, when I switch branches in git, if the files are open in emacs, then emacs asks if I want to revert them (as it thinks they've changed on disk) even though the contents are identical.
Firstly I'd like to find a way for emacs to not ask me about it at all if the contents on disk are identical to those in the buffer.
Secondly I'd l...
Is there a way to build up an email message from a region or buffer, set up a recipient and then send a message in elisp code?
I've configured emacs to send mail via my gmail account and I'd like to be able to send myself emails from elisp programs. The command used is message-mail.
...
There are a bunch of applications out there that integrate Emacs with external processes. GDB is one that comes to mind. I can control GDB from emacs and then get feedback on the screen.
I'd like to do something in that direction with my application.
Here's what I want:
establish a connection between me and emacs. I'd probably start ...
I like Emacs to highlight tab characters using the trailing-whitespace face, which I set to be a slightly grayer version of my background color. That way, all whitespace that I consider unwanted (tab characters and trailing whitespace) will have a slightly gray background.
This is the code I use:
(add-hook 'font-lock-mode-hook
'(lamb...
I'd like to re-format all my source files using the Google formatting function for emacs: google-c-style.el (see here).
How can I apply this function to all my source files at once, so that they are all formatted and indented correctly according to the Google style?
...