是什么在你的.emacs?(What's in your .emacs?)

2019-07-21 14:27发布

我沿着我失去了我的.emacs的方式切换电脑最近几次,和地方。 我试图重新建立起来,但是当我在这,我想我会拿起其他人用其他的好配置。

所以,如果你使用Emacs,什么在的.emacs?

矿井现在是相当贫瘠,只包含:

  1. 全球字型锁模式! (global-font-lock-mode 1)
  2. 我的个人喜好相对于缩进,制表符和空格。
  3. 使用cperl模式,而不是perl的模式。
  4. 快捷方式,用于编译。

你认为什么是有用的?

Answer 1:

使用终极点文件的网站 。 添加您”的.emacs'在这里。 阅读别人的”的.emacs'。



Answer 2:

我最喜欢的片段。 在Emacs眼睛糖果最终的:

;; real lisp hackers use the lambda character
;; courtesy of stefan monnier on c.l.l
(defun sm-lambda-mode-hook ()
  (font-lock-add-keywords
   nil `(("\\<lambda\\>"
   (0 (progn (compose-region (match-beginning 0) (match-end 0)
        ,(make-char 'greek-iso8859-7 107))
      nil))))))
(add-hook 'emacs-lisp-mode-hook 'sm-lambda-mode-hook)
(add-hook 'lisp-interactive-mode-hook 'sm-lamba-mode-hook)
(add-hook 'scheme-mode-hook 'sm-lambda-mode-hook)

所以你看即下面编辑口齿不清/计划时:

(global-set-key "^Cr" '(λ () (interactive) (revert-buffer t t nil)))


Answer 3:

我有这样的改变yesno提示yn提示:

(fset 'yes-or-no-p 'y-or-n-p)

我有这些在没有这么多的“大张旗鼓”这是我从拿到启动Emacs 这个问题 。

(setq inhibit-startup-echo-area-message t)
(setq inhibit-startup-message t)

而史蒂夫·耶格的功能来重命名你与它对应的缓冲区一起编辑文件:

(defun rename-file-and-buffer (new-name)
  "Renames both current buffer and file it's visiting to NEW-NAME."
  (interactive "sNew name: ")
  (let ((name (buffer-name))
 (filename (buffer-file-name)))
    (if (not filename)
 (message "Buffer '%s' is not visiting a file!" name)
      (if (get-buffer new-name)
   (message "A buffer named '%s' already exists!" new-name)
 (progn
   (rename-file name new-name 1)
   (rename-buffer new-name)
   (set-visited-file-name new-name)
   (set-buffer-modified-p nil))))))


Answer 4:

有一两件事可以证明是非常有用的:它变得太大之前,请尝试将其分割成不同的任务,多个文件:我的.emacs只是将我的负载路径和负载一堆文件 - 我有我的所有模式 - 在特定的设置mode-configs.el ,在键绑定keys.el ,等等



Answer 5:

我的.emacs只有127线,这里是最有用的小片段:

;; keep backup files neatly out of the way in .~/
(setq backup-directory-alist '(("." . ".~")))

这使得*〜文件,我觉得杂乱了目录进入一个特殊的目录,在这种情况下。〜

;; uniquify changes conflicting buffer names from file<2> etc
(require 'uniquify)
(setq uniquify-buffer-name-style 'reverse)
(setq uniquify-separator "/")
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers

这将设置uniquify从而改变那些丑陋的文件,你会得到<2>等缓冲名时,多个文件具有相同的名称为使用尽可能多的,因为它有该文件的全路径的更加简洁明确的名称。

这就是它......剩下的就是,我敢肯定每个人都知道非常标准的东西。



Answer 6:

这是不是整个套件和kaboodle,但它是一些比较有用的片段我收集的:

(defadvice show-paren-function (after show-matching-paren-offscreen
                                      activate)
  "If the matching paren is offscreen, show the matching line in the                               
echo area. Has no effect if the character before point is not of                                   
the syntax class ')'."
  (interactive)
  (let ((matching-text nil))
    ;; Only call `blink-matching-open' if the character before point                               
    ;; is a close parentheses type character. Otherwise, there's not                               
    ;; really any point, and `blink-matching-open' would just echo                                 
    ;; "Mismatched parentheses", which gets really annoying.                                       
    (if (char-equal (char-syntax (char-before (point))) ?\))
        (setq matching-text (blink-matching-open)))
    (if (not (null matching-text))
        (message matching-text))))

;;;;;;;;;;;;;;;
;; UTF-8
;;;;;;;;;;;;;;;;;;;;
;; set up unicode
(prefer-coding-system       'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;; This from a japanese individual.  I hope it works.
(setq default-buffer-file-coding-system 'utf-8)
;; From Emacs wiki
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
;; Wwindows clipboard is UTF-16LE 
(set-clipboard-coding-system 'utf-16le-dos)


(defun jonnay-timestamp ()
  "Spit out the current time"
  (interactive)
  (insert (format-time-string "%Y-%m-%d")))

(defun jonnay-sign ()
  "spit out my name, email and the current time"
  (interactive)
  (insert "-- Jonathan Arkell (jonathana@criticalmass.com)")
  (jonnay-timestamp))


;; Cygwin requires some seriosu setting up to work the way i likes it
(message "Setting up Cygwin...")
(let* ((cygwin-root "c:")
       (cygwin-bin (concat cygwin-root "/bin"))
       (gambit-bin "/usr/local/Gambit-C/4.0b22/bin/")
       (snow-bin "/usr/local/snow/current/bin")
       (mysql-bin "/wamp/bin/mysql/mysql5.0.51a/bin/"))
   (setenv "PATH" (concat cygwin-bin ";" ;
                          snow-bin ";" 
                          gambit-bin ";"
                          mysql-bin ";"
                          ".;")  
           (getenv "PATH"))
   (setq exec-path (cons cygwin-bin exec-path)))

(setq shell-file-name "bash")
(setq explicit-shell-file-name "bash")

(require 'cygwin-mount)
(cygwin-mount-activate)
(message "Setting up Cygwin...Done")


; Completion isn't perfect, but close
(defun my-shell-setup ()
   "For Cygwin bash under Emacs 20+"
   (setq comint-scroll-show-maximum-output 'this)
   (setq comint-completion-addsuffix t)
   (setq comint-eol-on-send t)
   (setq w32-quote-process-args ?\")
   (make-variable-buffer-local 'comint-completion-addsuffix))

(setq shell-mode-hook 'my-shell-setup)
(add-hook 'emacs-startup-hook 'cygwin-shell)


; Change how home key works
(global-set-key [home] 'beginning-or-indentation)
(substitute-key-definition 'beginning-of-line 'beginning-or-indentation global-map)


(defun yank-and-down ()
  "Yank the text and go down a line."
  (interactive)
  (yank)
  (exchange-point-and-mark)
  (next-line))

(defun kill-syntax (&optional arg)
  "Kill ARG sets of syntax characters after point."
  (interactive "p")
  (let ((arg (or arg 1))
    (inc (if (and arg (< arg 0)) 1 -1))
    (opoint (point)))
    (while (not (= arg 0))
      (if (> arg 0)
      (skip-syntax-forward (string (char-syntax (char-after))))
    (skip-syntax-backward (string (char-syntax (char-before)))))
      (setq arg (+ arg inc)))
    (kill-region opoint (point))))

(defun kill-syntax-backward (&optional arg)
  "Kill ARG sets of syntax characters preceding point."
  (interactive "p")
  (kill-syntax (- 0 (or arg 1))))

(global-set-key [(control shift y)] 'yank-and-down)
(global-set-key [(shift backspace)] 'kill-syntax-backward)
(global-set-key [(shift delete)] 'kill-syntax)


(defun insert-file-name (arg filename)
  "Insert name of file FILENAME into buffer after point.
  Set mark after the inserted text.

  Prefixed with \\[universal-argument], expand the file name to
  its fully canocalized path.

  See `expand-file-name'."
  ;; Based on insert-file in Emacs -- ashawley 2008-09-26
  (interactive "*P\nfInsert file name: ")
  (if arg
      (insert (expand-file-name filename))
      (insert filename)))

(defun kill-ring-save-filename ()
  "Copy the current filename to the kill ring"
  (interactive)
  (kill-new (buffer-file-name)))

(defun insert-file-name ()
  "Insert the name of the current file."
  (interactive)
  (insert (buffer-file-name)))

(defun insert-directory-name ()
  "Insert the name of the current directory"
  (interactive)
  (insert (file-name-directory (buffer-file-name))))

(defun jonnay-toggle-debug ()
  "Toggle debugging by toggling icicles, and debug on error"
  (interactive)
  (toggle-debug-on-error)
  (icicle-mode))


(defvar programming-modes
  '(emacs-lisp-mode scheme-mode lisp-mode c-mode c++-mode 
    objc-mode latex-mode plain-tex-mode java-mode
    php-mode css-mode js2-mode nxml-mode nxhtml-mode)
  "List of modes related to programming")

; Text-mate style indenting
(defadvice yank (after indent-region activate)
  (if (member major-mode programming-modes)
      (indent-region (region-beginning) (region-end) nil)))


Answer 7:

我有很多其他的已经被提及,但这些都是在我看来绝对必要的:

(transient-mark-mode 1) ; makes the region visible
(line-number-mode 1)    ; makes the line number show up
(column-number-mode 1)  ; makes the column number show up


Answer 8:

你可以看这里: http://www.dotemacs.de/

而我的.emacs是相当长的把它放在这儿一样,所以它将使答案不太可读。 无论如何,如果你希望我可以将它发送给您。

此外,我会建议你阅读本: http://steve.yegge.googlepages.com/my-dot-emacs-file



Answer 9:

下面是我在成为依赖一些关键映射:

(global-set-key [(control \,)] 'goto-line)
(global-set-key [(control \.)] 'call-last-kbd-macro)
(global-set-key [(control tab)] 'indent-region)
(global-set-key [(control j)] 'join-line)
(global-set-key [f1] 'man)
(global-set-key [f2] 'igrep-find)
(global-set-key [f3] 'isearch-forward)
(global-set-key [f4] 'next-error)
(global-set-key [f5] 'gdb)
(global-set-key [f6] 'compile)
(global-set-key [f7] 'recompile)
(global-set-key [f8] 'shell)
(global-set-key [f9] 'find-next-matching-tag)
(global-set-key [f11] 'list-buffers)
(global-set-key [f12] 'shell)

其他一些杂物,多为C ++开发:

;; Use C++ mode for .h files (instead of plain-old C mode)
(setq auto-mode-alist (cons '("\\.h$" . c++-mode) auto-mode-alist))

;; Use python-mode for SCons files
(setq auto-mode-alist (cons '("SConstruct" . python-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("SConscript" . python-mode) auto-mode-alist))

;; Parse CppUnit failure reports in compilation-mode
(require 'compile)
(setq compilation-error-regexp-alist
      (cons '("\\(!!!FAILURES!!!\nTest Results:\nRun:[^\n]*\n\n\n\\)?\\([0-9]+\\)) test: \\([^(]+\\)(F) line: \\([0-9]+\\) \\([^ \n]+\\)" 5 4)
            compilation-error-regexp-alist))

;; Enable cmake-mode from http://www.cmake.org/Wiki/CMake_Emacs_mode_patch_for_comment_formatting
(require 'cmake-mode)
(setq auto-mode-alist
      (append '(("CMakeLists\\.txt\\'" . cmake-mode)
                ("\\.cmake\\'" . cmake-mode))
              auto-mode-alist))

;; "M-x reload-buffer" will revert-buffer without requiring confirmation
(defun reload-buffer ()
  "revert-buffer without confirmation"
  (interactive)
  (revert-buffer t t))


Answer 10:

要刷新你从内Emacs编辑网页

(defun moz-connect()
  (interactive)
  (make-comint "moz-buffer" (cons "127.0.0.1" "4242"))
  (global-set-key "\C-x\C-g" '(lambda () 
                (interactive)
                (save-buffer)
                (comint-send-string "*moz-buffer*" "this.BrowserReload()\n"))))

结合使用http://hyperstruct.net/projects/mozlab



Answer 11:

你可以找到我的配置(无论是在HTML和在经tar归档)在我的网站 。 它包含了很多不同的模式设置



Answer 12:

此块是对我来说最重要的是:

(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

我从来没有去过那些之间的区别清楚,虽然。 天上掉馅饼,我猜...



Answer 13:

我尽量保持组织了我的.emacs。 配置始终处于进展中的工作,但我开始与整体结构来满足。

所有的东西是在~/.elisp ,目录是版本控制(我使用git,如果是利息)之下。 ~/.emacs仅指向~/.elisp/dotemacs它本身只是负荷~/.elisp/cfg/init 。 反过来这个文件通过进口各种配置文件require 。 这意味着,配置文件需要表现得像模式:他们进口他们依靠的东西,他们provide在文件的结尾自身,例如(provide 'my-ibuffer-cfg) 我前缀我的配置与定义的所有标识符my-

我组织配置,对于模式/主题/任务,而不是他们的技术含义,例如我没有所有的按键组合或面定义了一个独立的配置文件。

init.el定义了以下挂钩,以确保重新编译的Emacs配置文件保存时(编译elisp的加载速度快了很多,但我不想手动执行此步骤):

;; byte compile config file if changed
(add-hook 'after-save-hook
          '(lambda ()
                   (when (string-match
                          (concat (expand-file-name "~/.elisp/cfg/") ".*\.el$")
                          buffer-file-name)
           (byte-compile-file buffer-file-name))))

这是目录结构~/.elisp

~/.elisp/todo.org :组织模式文件中,我保持的东西,仍然需要做的(+愿望清单的项目)的轨道。

~/.elisp/dotemacs :链接目标的~/.emacs ,负荷~/.elisp/cfg/init

~/.elisp/cfg :我自己的配置文件。

~/.elisp/modes :即仅由一个单一的文件的模式。

~/.elisp/packages :用口齿不清,文档先进的模式和可能的资源文件。

我使用GNU Emacs的,该版本不具备封装的真正支持。 因此,我手动整理它们,通常是这样的: ~/.elisp/packages/foobar-0.1.3是软件包的根目录。 子目录lisp保存所有口齿不清文件和info是,文件中去。 ~/.elisp/packages/foobar是指向包的目前使用的版本,这样我不需要改变我的配置文件,当我更新的东西符号链接。 对于一些包我保持的~/.elisp/packages/foobar.installation文件围绕在我一直对安装过程的注意事项。 出于性能方面的原因,我编译所有的elisp文件在新安装的软件包,如果不是这种默认的情况下。



Answer 14:

这里有几个我自己的东西:

插入日期ISO 8601格式:

(defun insertdate ()
  (interactive)
  (insert (format-time-string "%Y-%m-%d")))

(global-set-key [(f5)] 'insertdate)

对于C ++程序员,创建一个类框架(类的名字将与没有扩展名的文件名):

(defun createclass ()
  (interactive)
  (setq classname (file-name-sans-extension (file-name-nondirectory   buffer-file-name)))
  (insert 
"/**
  * " classname".h 
  *
  * Author: Your Mom
  * Modified: " (format-time-string "%Y-%m-%d") "
  * Licence: GNU GPL
  */
#ifndef "(upcase classname)"
#define "(upcase classname)"

class " classname "
{
  public:
    "classname"();
    ~"classname"();

  private:

};
#endif
"))

自动创建右括号:

(setq skeleton-pair t)
(setq skeleton-pair-on-word t)
(global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe) 
(global-set-key (kbd "<") 'skeleton-pair-insert-maybe)


Answer 15:

我使用容易(e)中口齿不清处理和IDO模式迷你缓冲区完井paredit。



Answer 16:

这是很难回答这个问题,因为每个人都使用Emacs的非常不同的目的。

更进一步,一个更好的做法可能会亲吻你的dotemacs。 由于易于定制界面 ,广泛之间Emacs的模式支持,你应该存储在您所有的自定义custom-file (这可能是在您dotemacs一个单独的地方),并为dotemacs ,放在它只是负载路径设置,包要求,钩,和键绑定。 一旦你开始使用Emacs的入门套件 ,设置一个整体有用一堆可以从你的dotemacs删除了。



Answer 17:

见EmacsWiki的DotEmacs类别。 它提供了大量的链接,解决这个问题的网页。



Answer 18:

(put 'erase-buffer 'disabled nil)
(put 'downcase-region 'disabled nil)
(set-variable 'visible-bell t)
(set-variable 'tool-bar-mode nil)
(set-variable 'menu-bar-mode nil)

(setq load-path (cons (expand-file-name "/usr/share/doc/git-core/contrib/emacs") load-path))
 (require 'vc-git)
 (when (featurep 'vc-git) (add-to-list 'vc-handled-backends 'git))
 (require 'git)
 (autoload 'git-blame-mode "git-blame"
           "Minor mode for incremental blame for Git." t)


Answer 19:

我设置了一些方便的快捷键,网页和搜索使用webjump

(require 'webjump)
(global-set-key [f2] 'webjump)
(setq webjump-sites
      (append '(
        ("Reddit Search" .
         [simple-query "www.reddit.com" "http://www.reddit.com/search?q=" ""])
        ("Google Image Search" .
         [simple-query "images.google.com" "images.google.com/images?hl=en&q=" ""])
        ("Flickr Search" .
         [simple-query "www.flickr.com" "flickr.com/search/?q=" ""])
        ("Astar algorithm" . 
         "http://www.heyes-jones.com/astar")
        )
          webjump-sample-sites))

博客文章关于如何在这里工作

http://justinsboringpage.blogspot.com/2009/02/search-reddit-flickr-and-google-from.html

此外,我建议这些:

(setq visible-bell t) ; no beeping

(setq transient-mark-mode t) ; visually show region

(setq line-number-mode t) ; show line numbers

(setq global-font-lock-mode 1) ; everything should use fonts

(setq font-lock-maximum-decoration t)

我也摆脱一些多余的东西贵

  (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
  (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
  (if (fboundp 'menu-bar-mode) (menu-bar-mode -1)))


Answer 20:

一行修改负载路径一号线加载我的init库一号线加载我的emacs初始化文件

当然,“初始化文件的emacs”是相当多,每一个具体的东西,在一个确定的顺序加载。



Answer 21:

emacs的起动试剂盒作为碱,然后我已经添加.. vimpulse.elwhitespace.elyasnippettextmate.elnewsticker.el

在我的〜/ .emacs.d / $ USERNAME.el(dbr.el)文件:

(add-to-list 'load-path (concat dotfiles-dir "/vendor/"))

;; Snippets
(add-to-list 'load-path "~/.emacs.d/vendor/yasnippet/")
(require 'yasnippet)

(yas/initialize)
(yas/load-directory "~/.emacs.d/vendor/yasnippet/snippets")

;; TextMate module
(require 'textmate)
(textmate-mode 'on)

;; Whitespace module
(require 'whitespace)
(add-hook 'ruby-mode-hook 'whitespace-mode)
(add-hook 'python-mode-hook 'whitespace-mode)

;; Misc
(flyspell-mode 'on)
(setq viper-mode t)
(require 'viper)
(require 'vimpulse)

;; IM
(eval-after-load 'rcirc '(require 'rcirc-color))
(setq rcirc-default-nick "_dbr")
(setq rcirc-default-user-name "_dbr")
(setq rcirc-default-user-full-name "_dbr")

(require 'jabber)

;;; Google Talk account
(custom-set-variables
 '(jabber-connection-type (quote ssl))
 '(jabber-network-server "talk.google.com")
 '(jabber-port 5223)
 '(jabber-server "mysite.tld")
 '(jabber-username "myusername"))

;; Theme
(color-theme-zenburn)

;; Key bindings
(global-set-key (kbd "M-z") 'undo)
(global-set-key (kbd "M-s") 'save-buffer)
(global-set-key (kbd "M-S-z") 'redo)


Answer 22:

始终保存我的配置在SVN http://my-trac.assembla.com/ez-conf/browser/emacs.d



Answer 23:

看完这个,我想这将是很好的有一个简单的网站只为最好的.emacs修改。 随意张贴在这里进行表决:

http://dotemacs.slinkset.com/



Answer 24:

https://b7j0c.org/stuff/dotemacs.html



Answer 25:

我是新来的Emacs,在我的.emacs文件有

  • 压痕配置
  • 颜色主题
  • PHP模式,咖啡模式和JS2模式
  • IDO模式


Answer 26:

FWIW,我的.emacs是在这里:

http://svn.red-bean.com/repos/kfogel/trunk/.emacs



Answer 27:

很多东西: https://github.com/tavisrudd/emacs.d

EL-GET取得了管理IT和依赖关系轻松了许多: https://github.com/tavisrudd/emacs.d/blob/master/dss-init-el-get.el



Answer 28:

对于斯卡拉编码器

;; Load the ensime lisp code... http://github.com/aemoncannon/ensime
(add-to-list 'load-path "ENSIME_ROOT/elisp/")
(require 'ensime)
;; This step causes the ensime-mode to be started whenever ;; scala-mode is started for a buffer. You may have to customize this step ;; if you're not using the standard scala mode.
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
;; MINI HOWTO:  ;; Open .scala file. M-x ensime (once per project)


Answer 29:

我的emacs的配置已经长大了多年来相当大的,我有很多有用的东西,对我来说,但如果我有两个功能,它很可能会被那些人。

定义CX UP和DOWN CX移动当前一行或保持光标在正确的地方:

;Down/UP the current line
(global-set-key '[(control x) (up)] 'my-up-line)
(global-set-key '[(control x) (down)] 'my-down-line)
(defun my-down-line()
  (interactive)
  (let ((col (current-column)))
    (forward-line 1)
    (transpose-lines 1)
    (forward-line -1)
    (forward-char col)
    )
  )

(defun my-up-line()
  (interactive)
  (let ((col (current-column)))
    (transpose-lines 1)
    (forward-line -2)
    (forward-char col)
    )
  )


文章来源: What's in your .emacs?