elisp

How to automatically decompress a custom compressed file when opened in emacs?

心已入冬 提交于 2019-12-22 08:03:07
问题 I know Emacs automatically opens compressed files like .tar.gz . I'm trying to figure how to achieve this with my own compression script rather than the standard ones. Following this link, I added the following to my Emacs init file (if (fboundp 'auto-compression-mode) (auto-compression-mode 0) (require 'jka-compr)) (add-to-list 'jka-compr-compression-info-list ["\\.customcom\\'" "custom compressing" "customcom" (-c) "custom decompressing" "customcom" (-d) nil t]) (auto-compression-mode 1)

elisp warning “reference to free variable”

北战南征 提交于 2019-12-22 07:40:11
问题 I am wandering how to get rid of the elisp warning. my setup is the following: I have init.el file which sets "emacs-root" variable: ;; root of all emacs-related stuff (defvar emacs-root (if (or (eq system-type 'cygwin) (eq system-type 'gnu/linux) (eq system-type 'linux) (eq system-type 'darwin)) "~/.emacs.d/" "z:/.emacs.d/" "Path to where EMACS configuration root is.")) then in my init.el I have ;; load plugins with el-get (require 'el-get-settings) in el-get-settings.el I am loading

Get the VC root in Emacs Lisp

[亡魂溺海] 提交于 2019-12-22 07:01:21
问题 In an Emacs Lisp function, I want to know the VC root of an arbitrary folder (if under source control), the same as something like vc-print-root-log does it. I'm trying to do it from outside the VC file/folder (though creating a temporary buffer to do this would be fine). I currently have a git-only solution through magit - (magit-get-top-dir dir-name) . I tried using (vc-deduce-backend) and the 'root command, but the variables that vc-deduce-backend checks seems to only be set in existing vc

improper exiting from indentation in emacs python-mode

ε祈祈猫儿з 提交于 2019-12-22 04:38:21
问题 I am using Emacs python-mode. I invoke it using this in my .emacs (add-to-list 'load-path "~/emacs/python-mode.el-6.0.3/") (autoload 'python-mode "python-mode" "Python Mode." t) (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) (add-to-list 'interpreter-mode-alist '("python" . python-mode)) (require 'python-mode) (add-hook 'python-mode-hook (lambda () (set-variable 'py-indent-offset 4) ;(set-variable 'py-smart-indentation nil) (set-variable 'indent-tabs-mode nil) (define-key py-mode

Executes a function until it returns a nil, collecting its values into a list

◇◆丶佛笑我妖孽 提交于 2019-12-22 04:24:50
问题 I got this idea from XKCD's Hofstadter comic; what's the best way to create a conditional loop in (any) Lisp dialect that executes a function until it returns NIL at which time it collects the returned values into a list. For those who haven't seen the joke, it's goes that Douglas Hofstadter's “eight-word” autobiography consists of only six words: “I'm So Meta, Even This Acronym” containing continuation of the joke: (some odd meta-paraprosdokian?) “Is Meta” — the joke being that the

Add/remove column spreadsheet features in Emacs?

不羁岁月 提交于 2019-12-22 01:36:26
问题 Given delimited data in the following format, how can I insert and delete columns? abc|efg|123|xyz123abc|yes xxx|bbb|cc|ddd|no Say, for example, that I wanted to add a 3rd column with a default value of 1 and remove the 4th column so the data would look like this: abc|efg|1|123|yes xxx|bbb|1|cc|no I was looking into org-mode tables as a starting point, however it puts extra spaces around the data. | abc | efg | 123 | xyz123abc | | xxx | bbb | cc | ddd | | | | | | 回答1: Well I just found out

Define an emacs command that calls another emacs command (preserving interactive stuff)

泄露秘密 提交于 2019-12-21 22:11:28
问题 How can I define an emacs command X that does something and then calls another emacs command Y and also copying the interactive interface of the command Y too? I want to define an altenative version of query-replace with temporarilly toggled value of case-fold-search: (defun alt-query-replace (a b c d e) (interactive) (let ((case-fold-search (not case-fold-search)) (query-replace a b c d e))) This doesn't work. When I call alt-query-replace, it says "wrong number of arguments". I want the

A smarter alternative to delete-window?

寵の児 提交于 2019-12-21 20:59:19
问题 Sometimes I get multiple windows open for the same buffer (or a similar one) and I have to differentiate whether or not the buffer in the window is the same as another before deciding to either kill it or delete the window. Is there a way in emacs to simply delete a window only if the buffer exists already in another? Ideally I would like the same function to also kill the buffer and the window if it is the only instance of the buffer in a window. 回答1: (defun delete-extra-windows ()

Emacs — modifying `fill-column-indicator.el` to display over whitespace

喜欢而已 提交于 2019-12-21 20:52:47
问题 I am looking for some assistance, please, to modify fill-column-indicator.el by Alp Aker so that the vertical line is visible over whitespace (regardless of whether whitespace-mode is active). Here is the link to the Github repository for the library: https://github.com/alpaker/Fill-Column-Indicator/blob/master/fill-column-indicator.el At the present time, the vertical line is not visible over whitespace. The following code, when combined with fill-column-indicator.el , creates a vertical

Create a new mode in Emacs

流过昼夜 提交于 2019-12-21 20:47:26
问题 I know nothing about Emacs Lisp (or any Lisp, for that matter). I want to do something that seems very simple, yet I have had no luck with online guides. I want to create "packet-mode.el" for .packet files. I want to do the following: Enable C++ mode Make packet a keyword, while leaving the rest of C++ mode unchanged (define-derived-mode packet-mode fundamental-mode (font-lock-add-keywords 'c++-mode `(("packet" . font-lock-keyword-face))) (c++-mode)) (add-to-list 'auto-mode-alist '("\\.packet