elisp

Emacs region highlighting

六眼飞鱼酱① 提交于 2019-12-30 09:58:09
问题 Is there a way to highlight a string in a text (but not ALL such strings) in a buffer where font-lock-mode is on. Let's imagine I have a buffer with SQL mode and I want to highlight a string in it. The following code does not work (set-text-properties 10 20 '(face hi-yellow)) When I call (font-lock-mode -1) it works, but all sql highlighting disappears. There must be a solution because it's possible to select a region and it will be highlighted but I can't figure out how to do it

Emacs 23, OS X, multi-tty and emacsclient

我只是一个虾纸丫 提交于 2019-12-30 06:49:12
问题 How can I get emacs 23 working nicely in multi-tty mode on OS X? I've added (server-start) to my .emacs, and have discovered that running /Applications/Emacs.app/Contents/MacOS/bin/emacsclient -n ~/myfile.txt will open it in my emacs.app, but it doesn't bring emacs to the front. So, how can I get emacs.app to come to the front when I run emacsclient? (I've considered writing a function that puts the current frame to the front every time a file is opened, or maybe writing an Applescript to do

Emacs 23, OS X, multi-tty and emacsclient

限于喜欢 提交于 2019-12-30 06:49:05
问题 How can I get emacs 23 working nicely in multi-tty mode on OS X? I've added (server-start) to my .emacs, and have discovered that running /Applications/Emacs.app/Contents/MacOS/bin/emacsclient -n ~/myfile.txt will open it in my emacs.app, but it doesn't bring emacs to the front. So, how can I get emacs.app to come to the front when I run emacsclient? (I've considered writing a function that puts the current frame to the front every time a file is opened, or maybe writing an Applescript to do

Most efficient method of activating an Emacs function with an applescript

半世苍凉 提交于 2019-12-30 05:11:58
问题 Is there a better method to activate a function in Emacs with an applescript instead of opening the minibuffer to launch the function? There is a delay that is needed to take my finger off of the control key to launch the applescript with a keyboard shortcut (so that Emacs doesn't register it as a command), and there is another delay after typing the name of the function into the minibuffer. Ideally, I'd like to tell Emacs under-the-hood to run a particular function without opening the

How can I emulate Vim's * search in GNU Emacs?

孤人 提交于 2019-12-29 11:46:17
问题 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 are in the middle of the word when you press *. I've cooked up a bit of elisp to do something similar: (defun find-word-under-cursor (arg) (interactive "p") (if

Why are fixnums in Emacs only 29 bits?

爷,独闯天下 提交于 2019-12-29 08:37:08
问题 And why don't they change it? Edit: The reason ask is because I'm new to emacs and I would like to use Emacs as a "programmer calculator". So, I can manipulate 32-bit & 64-bit integers and have them behave as they would on the native machine. 回答1: Emacs-Lisp is a dynamically-typed language. This means that you need type tags at runtime. If you wanted to work with numbers, you would therefore normally have to pack them into some kind of tagged container that you can point to (i.e. “box” them),

If frame named “xyz” exists, then switch to that frame

瘦欲@ 提交于 2019-12-29 07:16:09
问题 Could someone please give me hand with a function that detects whether a frame named "xyz" exists, and if so, then switch to that frame. I'm using frame-cmds to give each frame a user-defined name: http://www.emacswiki.org/emacs/frame-cmds.el I would imagine it is similar to a buffer, but I'm not finding anything on Google. Here is the buffer function: (defun buffer-exists (bufname) (not (eq nil (get-buffer bufname)))) (defun lawlist-switch-to-buffer-xyz () (interactive) (if (buffer-exists

Emacs: Preventing gud & pdb from controlling windows

霸气de小男生 提交于 2019-12-28 18:04:29
问题 I'm using pdb to debug Python programs and am unhappy with it's behaviour. I have the screen divided into multiple emacs windows, and when I execute pdb, it (randomly?) replaces one of the windows with the output of the *gud* debugger. Also, when a breakpoint is encountered, even if the debugging buffer is already visible in a window, it usually puts this buffer into another window, and replaces another of my windows with the contents of the source file. (incidentally I like that it jumps to

Add times in buffer

社会主义新天地 提交于 2019-12-25 13:47:26
问题 Suppose I have an emacs buffer which contains times in the format minutes'seconds'' and in the format minutes' as well as seconds'' for example 5'30'', 6'15'', 10' and 1''. Is it possible to add all times in the buffer automatically with output (in the minibuffer) in the format minutes'seconds'' (here = 21'46'')? 回答1: Is this what you want? (defun add-times () (interactive) (let ((minutes 0) (seconds 0)) (save-excursion (goto-char (point-min)) (while (re-search-forward "\\([0-9]+\\)'\\('\\)?"

Why am I getting “The authenticated user has not installed the app with client id” error when using the Google Drive API natively?

社会主义新天地 提交于 2019-12-25 08:29:54
问题 I'm working on a Google Drive interface for Emacs. The concept is that Emacs could provide a platform-agnostic way to load, modify and save text documents stored in Google Drive. I've registered my app and can authenticate with OAuth2 and get a file listing with the Docs List API, but when I try to execute an Insert with the Google Drive API, I see an error: "The authenticated user has not installed the app with client id ..." Reading further, it seems I need to publish my Emacs application