elisp

emacs lexical scoping and quoted variable name

末鹿安然 提交于 2019-12-13 01:05:35
问题 I was experimenting with interplay between Emacs lexical scoping (new feature of Emacs 24) and add-to-list and found the interplay confusing and I don't know how to make sense of it. Here is a minimal example, except I use set instead of add-to-list . ( set is similar to add-to-list in that it usually takes a quoted variable name) (eval '(progn (setq a "global") (let ((a "apple")) (defun my-print-a () (print a) (set 'a "by set") (print a)) (setq a "mature apple")) (let ((a "banana")) (my

How to replace “(” with “\(” in the regexp, Emacs/elisp flavor?

和自甴很熟 提交于 2019-12-12 19:15:29
问题 Question as title. More specifically, I'm rather tired of having to type \( , etc. every time I want a parenthesis in Emacs's (interactive) regexp functions (not to mention the \\( in code). So I wrote something like (defadvice query-replace-regexp (before my-query-replace-regexp activate) (ad-set-arg 0 (replace-regexp-in-string "(" "\\\\(" (ad-get-arg 0))) (ad-set-arg 0 (replace-regexp-in-string ")" "\\\\)" (ad-get-arg 0))))) in hope that I can conveniently forget about emacs's idiosyncrasy

Comments for Function in Emacs

只谈情不闲聊 提交于 2019-12-12 18:07:53
问题 I'm looking for a way to generate and insert header comment blocks above my functions in Emacs (in any mode), with the default contents of the comment automatically based on the function's signature (i.e. the correct number of @param place-holders). Doxymacs is a nice candidate. But I prefer another way works without the necessary libs. Can anyone recommend some others ways for adding smart comments for functions in Emacs? Thanks. Edit: Now I found this: http://nschum.de/src/emacs/doc-mode/,

Emacs: default dir for (interactive “f”)

好久不见. 提交于 2019-12-12 17:19:16
问题 I am writing a simple hacky solution to switch between «projects» (sets of buffers and frames (X windows)) on top of DesktopAid. I made a procedure to write a project file: (defun project-save-as (project-filename) "Save the current session to a new project session file." (interactive "FProject file to write: ") (copy-file project-default project-filename t) ; New project is the new current project. (write-cur-project-file project-filename) (set-variable 'cur-project-filename project-filename

Advice only applies in all cases after function calling advised function is re-evaluated

巧了我就是萌 提交于 2019-12-12 16:21:34
问题 In my .emacs file, I have: (defadvice narrow-to-region (around test activate) (message "advice") ad-do-it) When I call narrow-to-region, the advice runs and prints 'advice' before narrowing. When I call narrow-to-defun, it does not. I found where narrow-to-defun is defined - in lisp.el, and re-evaluated the function. At this point, the advice started running. What could cause this? 回答1: The problem is, apparently, due to byte-compilation and therefore the inability to advise the narrowing

Emacs: Keybinding to TAB breaks autocompletion in minibuffer

风流意气都作罢 提交于 2019-12-12 15:28:22
问题 Simply put, I just set a keybinding on the TAB key, but now when I push TAB in the minibuffer to auto-complete a command, it fails with the following message: The mark is not set now, so there is no region . In other words, I only need my TAB keybinding when my cursor is in the buffer (not the minibuffer). In my example below, how can I set my tab to indent when I am in text/fundamental mode in the buffer without losing autocompletion while in the mini-buffer? I have the following functions

emacs bind key to the insertion of another

谁都会走 提交于 2019-12-12 15:10:38
问题 I have paredit-forward and paredit-backward bound to > and < respectively. This means if I want to type "something->something-else" I instead type "something-" the cursor is teleported to another part of the screen, and finish typing with "something-else". My solution to this is to use C-. and C-, to insert them. I tried this: (define-key key-translation-map (kbd "C-.") (kbd ">")) (define-key key-translation-map (kbd "C-,") (kbd "<")) The previous command results in the another paredit

Why does haskell mode step on s-lower-camel-case and how does it do it?

六眼飞鱼酱① 提交于 2019-12-12 14:34:08
问题 I have prepared a minimal working example to check that other dependancies have not interfered with this. The test function is: (defun test-haskell-problems () (interactive) (insert (s-lower-camel-case "other_string"))) And a full reproduction of the problem (with package installation) occurs with this: (setq package-list '( s haskell-mode )) (when (>= emacs-major-version 24) (require 'package) (package-initialize) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/

Elisp, alist and strings; type confusion

随声附和 提交于 2019-12-12 13:23:23
问题 I'm trying to publish an org-project as html, and automate the task with the following org project definition: (defconst home (file-name-directory (or load-file-name buffer-file-name))) (require 'org-publish) (setq org-publish-project-alist '( ;; add all the components here ;; *notes* - publishes org files to html ("org-notes" :base-directory (concat home "org/") :base-extension "org" ; Filename suffix without dot :publishing-directory (concat home "../public_html/") :recursive t ; includes

Interactive Spell Checking Programs Available for emacs

南楼画角 提交于 2019-12-12 11:50:44
问题 I recently switched to emacs24 and upgraded to Ubuntu 12.04. I can't seem to get hunspell working correctly again. I find hunspell to be better than aspell generally. Hunspell only wants to use the Australian dictionary and not English US dictionary or freezes up my system. With aspell I have no problem switching dictionaries or running flyspell mode. My question is how do people have setup interactive spelling in emacs24?? Still using ispell and flyspell or any other setups preferred. Are