elisp

Why is there blank space where there ought be line numbers in Emacs?

自古美人都是妖i 提交于 2020-01-13 19:02:53
问题 I'm using (global-linum-mode t) to present line numbers in Emacs. This works just fine up-until I use the ctrl + up / down commands ( forward-paragraph and backward-paragraph ) to navigate a buffer, at which point some line numbers are rendered incorrectly (see attached image). This occurs only when I use said commands to skip entire segments of code, and the issue immediately disappears (the line numbers are rendered correctly, that is) if I start navigating the buffer by other means. The

How to permanently enable the hs-minor-mode in emacs

China☆狼群 提交于 2020-01-13 07:55:35
问题 I am using thhs code in the .emacs file to permanently enable the hs-minor-mode and to change the shortcut: (setq-default hs-minor-mode t) (global-set-key (kbd "C-c C-h") (kbd "C-c @ C-h")) ;;hiding block of code (global-set-key (kbd "C-c C-r") (kbd "C-c @ C-s")) ;;revealing block of code But the mode is not activated automatically. what should i do? 回答1: If you want it to be truly global, this does the trick: (define-globalized-minor-mode global-hs-minor-mode hs-minor-mode hs-minor-mode)

elisp: call command on current file

陌路散爱 提交于 2020-01-12 14:00:31
问题 I want to set a key in emacs to perform a shell command on the file in the buffer, and revert the buffer without prompting. The shell command is: p4 edit 'currentfilename.ext' (global-set-key [\C-E] (funcall 'revert-buffer 1 1 1)) ;; my attempt above to call revert-buffer with a non-nil ;; argument (ignoring the shell command for now) -- get an init error: ;; Error in init file: error: "Buffer does not seem to be associated with any file" Completely new to elisp. From the emacs manual, here

Generate Org-mode objects programmatically

左心房为你撑大大i 提交于 2020-01-12 03:32:12
问题 I want to generate strings containing Org-mode text without actually hard-coding the syntax. For example i want to run a function such as (org-generate (org-generate-heading "heading" (org-generate-plain-list '("foo" "bar" "baz"))) and it will return: * heading - foo - bar - baz In other words, i want to create Org-mode documents of arbitrary complexity without micromanaging syntactic features like asterisks and indentation, only via calling functions with parameters, that return some Org

face font in c-mode when adding new keyword

笑着哭i 提交于 2020-01-11 13:05:15
问题 I am trying to customize some added words to be colored differently from the default face-font colors. This is what I am doing: (defconst lconfig-font-lock-faces (list '(font-lock-function-name-face ((((class color)) (:foreground "DarkBlue" :bold t)))) '(font-lock-constant-face ((((class color)) (:foreground "Black" :bold t)))) '(font-lock-builtin-face ((((class color)) (:foreground nil)))) '(font-lock-preprocessor-face ((((class color)) (:foreground nil)))) ) ) (autoload 'custom-set-faces

Emacs Lisp Buffer out of focus function?

无人久伴 提交于 2020-01-11 12:03:22
问题 Is there an emacs lisp function that will allow me to tell if a buffer is out of focus? I am trying to write a hook that will get rid of the semantics *possible completion's* buffer right after it is out of focus. Also is it possible to get rid of the *Messages* Buffer as well? I haven't found a function that would kill it. 回答1: Related to your second question, Also is it possible to get rid of the Messages Buffer as well . If you're using ido-mode (and everyone should be using it!), you can

Can you create interactive functions in an Emacs Lisp macro?

☆樱花仙子☆ 提交于 2020-01-10 14:35:05
问题 I'm trying to write a macro in emacs lisp to create some ‘helper functions.’ Ultimately, my helper functions will be more useful than 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 (functionname texttoinsert) `(defun ,(make-symbol (concatenate 'string "text-" functionname)) () (interactive) (insert-string ,texttoinsert))) (deftext "swallow"

Emacs: Search-Space for Find-Function

佐手、 提交于 2020-01-07 06:58:20
问题 Working on my first sbcl project in slime mode, I have trouble with setting up emacs properly for navigating within my code: Often, I would like to jump to the function definition (to any custom function within my source code) of a function. Therefore find-function seems to be a good starting point. Unfortunately, find-function never finds any of my functions : [No match]! My source code is located in a simple file like geometry.lisp with function definitions like: (defun get-right-normal

How to define an Emacs command that uses `replace-string` to replace a specific string [duplicate]

寵の児 提交于 2020-01-06 14:16:13
问题 This question already has answers here : How to define an Emacs command that uses `replace-string` for a specific string (2 answers) Closed 3 years ago . I need to remove ascii character 0253 and add a carriage return in it's place. In emacs I do M-x replace-string ý RET C-q C-j C-q C-j adds a carriage return. I do this often enough that I creating a custom defun would be much better. Here is what I have so far (defun remove-253 () "Removes ASCII Character 0253 and adds a carriage return in

How to invoke env from eLisp and escape the path to the target program properly?

£可爱£侵袭症+ 提交于 2020-01-06 08:37:30
问题 What I'm trying to do is as follows: (let ((pj-path (concat src haxe-project-generator))) (when (file-exists-p pj-path) (shell-command (concat "env " (haxe-build-env-vars <more arguments>) (format "'%s'" pj-path))))) I.e. I want to call a program pj-path in environment populated with some variables. In the line (format "'%s'" pj-path) I tried single and double quotes - but env doesn't do path expansion and if it is quoted, it will treat it as a string, not finding the file. However, if it is