mirror of https://github.com/sean-m/.emacs.d.git
Solved merge conflicts, I think
commit
2a0d3f0b82
|
@ -15,7 +15,7 @@ custom.el
|
|||
places
|
||||
.smex-items
|
||||
savefile/
|
||||
/prelude-modules.el
|
||||
|
||||
projectile-bookmarks.eld
|
||||
session*
|
||||
.cask
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
;;; erlang-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
|
||||
;;;### (autoloads (inferior-erlang erlang-compile erlang-shell erlang-find-tag-other-window
|
||||
;;;;;; erlang-find-tag erlang-mode) "erlang" "erlang.el" (20307
|
||||
;;;;;; 28822))
|
||||
;;; Generated autoloads from erlang.el
|
||||
|
||||
(autoload 'erlang-mode "erlang" "\
|
||||
Major mode for editing Erlang source files in Emacs.
|
||||
It knows about syntax and comment, it can indent code, it is capable
|
||||
of fontifying the source file, the TAGS commands are aware of Erlang
|
||||
modules, and the Erlang man pages can be accessed.
|
||||
|
||||
Should this module, \"erlang.el\", be installed properly, Erlang mode
|
||||
is activated whenever an Erlang source or header file is loaded into
|
||||
Emacs. To indicate this, the mode line should contain the word
|
||||
\"Erlang\".
|
||||
|
||||
The main feature of Erlang mode is indentation, press TAB and the
|
||||
current line will be indented correctly.
|
||||
|
||||
Comments starting with only one `%' are indented to the column stored
|
||||
in the variable `comment-column'. Comments starting with two `%':s
|
||||
are indented with the same indentation as code. Comments starting
|
||||
with at least three `%':s are indented to the first column.
|
||||
|
||||
However, Erlang mode contains much more, this is a list of the most
|
||||
useful commands:
|
||||
TAB - Indent the line.
|
||||
C-c C-q - Indent current function.
|
||||
M-; - Create a comment at the end of the line.
|
||||
M-q - Fill a comment, i.e. wrap lines so that they (hopefully)
|
||||
will look better.
|
||||
M-a - Goto the beginning of an Erlang clause.
|
||||
M-C-a - Ditto for function.
|
||||
M-e - Goto the end of an Erlang clause.
|
||||
M-C-e - Ditto for function.
|
||||
M-h - Mark current Erlang clause.
|
||||
M-C-h - Ditto for function.
|
||||
C-c C-z - Start, or switch to, an inferior Erlang shell.
|
||||
C-c C-k - Compile current file.
|
||||
C-x ` - Next error.
|
||||
, - Electric comma.
|
||||
; - Electric semicolon.
|
||||
|
||||
Erlang mode check the name of the file against the module name when
|
||||
saving, whenever a mismatch occurs Erlang mode offers to modify the
|
||||
source.
|
||||
|
||||
The variable `erlang-electric-commands' controls the electric
|
||||
commands. To deactivate all of them, set it to nil.
|
||||
|
||||
There exists a large number of commands and variables in the Erlang
|
||||
module. Please press `M-x apropos RET erlang RET' to see a complete
|
||||
list. Press `C-h f name-of-function RET' and `C-h v name-of-variable
|
||||
RET'to see the full description of functions and variables,
|
||||
respectively.
|
||||
|
||||
On entry to this mode the contents of the hook `erlang-mode-hook' is
|
||||
executed.
|
||||
|
||||
Please see the beginning of the file `erlang.el' for more information
|
||||
and examples of hooks.
|
||||
|
||||
Other commands:
|
||||
\\{erlang-mode-map}
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'erlang-find-tag "erlang" "\
|
||||
Like `find-tag'. Capable of retreiving Erlang modules.
|
||||
|
||||
Tags can be given on the forms `tag', `module:', `module:tag'.
|
||||
|
||||
\(fn MODTAGNAME &optional NEXT-P REGEXP-P)" t nil)
|
||||
|
||||
(autoload 'erlang-find-tag-other-window "erlang" "\
|
||||
Like `find-tag-other-window' but aware of Erlang modules.
|
||||
|
||||
\(fn TAGNAME &optional NEXT-P REGEXP-P)" t nil)
|
||||
|
||||
(autoload 'erlang-shell "erlang" "\
|
||||
Start a new Erlang shell.
|
||||
|
||||
The variable `erlang-shell-function' decides which method to use,
|
||||
default is to start a new Erlang host. It is possible that, in the
|
||||
future, a new shell on an already running host will be started.
|
||||
|
||||
\(fn)" t nil)
|
||||
(autoload 'run-erlang "erlang" "Start a new Erlang shell." t)
|
||||
|
||||
(autoload 'erlang-compile "erlang" "\
|
||||
Compile Erlang module in current buffer.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'inferior-erlang "erlang" "\
|
||||
Run an inferior Erlang.
|
||||
|
||||
This is just like running Erlang in a normal shell, except that
|
||||
an Emacs buffer is used for input and output.
|
||||
|
||||
The command line history can be accessed with M-p and M-n.
|
||||
The history is saved between sessions.
|
||||
|
||||
Entry to this mode calls the functions in the variables
|
||||
`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments.
|
||||
|
||||
The following commands imitate the usual Unix interrupt and
|
||||
editing control characters:
|
||||
\\{erlang-shell-mode-map}
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil nil ("erlang-pkg.el") (20307 28822 974247))
|
||||
|
||||
;;;***
|
||||
|
||||
(provide 'erlang-autoloads)
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; erlang-autoloads.el ends here
|
|
@ -0,0 +1,448 @@
|
|||
;;
|
||||
;; %CopyrightBegin%
|
||||
;;
|
||||
;; Copyright Ericsson AB 2009-2010. All Rights Reserved.
|
||||
;;
|
||||
;; The contents of this file are subject to the Erlang Public License,
|
||||
;; Version 1.1, (the "License"); you may not use this file except in
|
||||
;; compliance with the License. You should have received a copy of the
|
||||
;; Erlang Public License along with this software. If not, it can be
|
||||
;; retrieved online at http://www.erlang.org/.
|
||||
;;
|
||||
;; Software distributed under the License is distributed on an "AS IS"
|
||||
;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
;; the License for the specific language governing rights and limitations
|
||||
;; under the License.
|
||||
;;
|
||||
;; %CopyrightEnd%
|
||||
;;;
|
||||
;;; Purpose: Provide EUnit utilities.
|
||||
;;;
|
||||
;;; Author: Klas Johansson
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(defvar erlang-eunit-src-candidate-dirs '("../src" ".")
|
||||
"*Name of directories which to search for source files matching
|
||||
an EUnit test file. The first directory in the list will be used,
|
||||
if there is no match.")
|
||||
|
||||
(defvar erlang-eunit-test-candidate-dirs '("../test" ".")
|
||||
"*Name of directories which to search for EUnit test files matching
|
||||
a source file. The first directory in the list will be used,
|
||||
if there is no match.")
|
||||
|
||||
(defvar erlang-eunit-autosave nil
|
||||
"*Set to non-nil to automtically save unsaved buffers before running tests.
|
||||
This is useful, reducing the save-compile-load-test cycle to one keychord.")
|
||||
|
||||
(defvar erlang-eunit-recent-info '((mode . nil) (module . nil) (test . nil) (cover . nil))
|
||||
"Info about the most recent running of an EUnit test representation.")
|
||||
|
||||
;;;
|
||||
;;; Switch between src/EUnit test buffers
|
||||
;;;
|
||||
(defun erlang-eunit-toggle-src-and-test-file-other-window ()
|
||||
"Switch to the src file if the EUnit test file is the current
|
||||
buffer and vice versa"
|
||||
(interactive)
|
||||
(if (erlang-eunit-test-file-p buffer-file-name)
|
||||
(erlang-eunit-open-src-file-other-window buffer-file-name)
|
||||
(erlang-eunit-open-test-file-other-window buffer-file-name)))
|
||||
|
||||
;;;
|
||||
;;; Open the EUnit test file which corresponds to a src file
|
||||
;;;
|
||||
(defun erlang-eunit-open-test-file-other-window (src-file-path)
|
||||
"Open the EUnit test file which corresponds to a src file"
|
||||
(find-file-other-window (erlang-eunit-test-filename src-file-path)))
|
||||
|
||||
;;;
|
||||
;;; Open the src file which corresponds to the an EUnit test file
|
||||
;;;
|
||||
(defun erlang-eunit-open-src-file-other-window (test-file-path)
|
||||
"Open the src file which corresponds to the an EUnit test file"
|
||||
(find-file-other-window (erlang-eunit-src-filename test-file-path)))
|
||||
|
||||
;;; Return the name and path of the EUnit test file
|
||||
;;, (input may be either the source filename itself or the EUnit test filename)
|
||||
(defun erlang-eunit-test-filename (file-path)
|
||||
(if (erlang-eunit-test-file-p file-path)
|
||||
file-path
|
||||
(erlang-eunit-rewrite-filename file-path erlang-eunit-test-candidate-dirs)))
|
||||
|
||||
;;; Return the name and path of the source file
|
||||
;;, (input may be either the source filename itself or the EUnit test filename)
|
||||
(defun erlang-eunit-src-filename (file-path)
|
||||
(if (erlang-eunit-src-file-p file-path)
|
||||
file-path
|
||||
(erlang-eunit-rewrite-filename file-path erlang-eunit-src-candidate-dirs)))
|
||||
|
||||
;;; Rewrite a filename from the src or test filename to the other
|
||||
(defun erlang-eunit-rewrite-filename (orig-file-path candidate-dirs)
|
||||
(or (erlang-eunit-locate-buddy orig-file-path candidate-dirs)
|
||||
(erlang-eunit-buddy-file-path orig-file-path (car candidate-dirs))))
|
||||
|
||||
;;; Search for a file's buddy file (a source file's EUnit test file,
|
||||
;;; or an EUnit test file's source file) in a list of candidate
|
||||
;;; directories.
|
||||
(defun erlang-eunit-locate-buddy (orig-file-path candidate-dirs)
|
||||
(when candidate-dirs
|
||||
(let ((buddy-file-path (erlang-eunit-buddy-file-path
|
||||
orig-file-path
|
||||
(car candidate-dirs))))
|
||||
(if (file-readable-p buddy-file-path)
|
||||
buddy-file-path
|
||||
(erlang-eunit-locate-buddy orig-file-path (cdr candidate-dirs))))))
|
||||
|
||||
(defun erlang-eunit-buddy-file-path (orig-file-path buddy-dir-name)
|
||||
(let* ((orig-dir-name (file-name-directory orig-file-path))
|
||||
(buddy-dir-name (file-truename
|
||||
(filename-join orig-dir-name buddy-dir-name)))
|
||||
(buddy-base-name (erlang-eunit-buddy-basename orig-file-path)))
|
||||
(filename-join buddy-dir-name buddy-base-name)))
|
||||
|
||||
;;; Return the basename of the buddy file:
|
||||
;;; /tmp/foo/src/x.erl --> x_tests.erl
|
||||
;;; /tmp/foo/test/x_tests.erl --> x.erl
|
||||
(defun erlang-eunit-buddy-basename (file-path)
|
||||
(let ((src-module-name (erlang-eunit-source-module-name file-path)))
|
||||
(cond
|
||||
((erlang-eunit-src-file-p file-path)
|
||||
(concat src-module-name "_tests.erl"))
|
||||
((erlang-eunit-test-file-p file-path)
|
||||
(concat src-module-name ".erl")))))
|
||||
|
||||
;;; Checks whether a file is a source file or not
|
||||
(defun erlang-eunit-src-file-p (file-path)
|
||||
(not (erlang-eunit-test-file-p file-path)))
|
||||
|
||||
;;; Checks whether a file is a EUnit test file or not
|
||||
(defun erlang-eunit-test-file-p (file-path)
|
||||
(erlang-eunit-string-match-p "^\\(.+\\)_tests.erl$" file-path))
|
||||
|
||||
;;; Return the module name of the source file
|
||||
;;; /tmp/foo/src/x.erl --> x
|
||||
;;; /tmp/foo/test/x_tests.erl --> x
|
||||
(defun erlang-eunit-source-module-name (file-path)
|
||||
(interactive)
|
||||
(let ((module-name (erlang-eunit-module-name file-path)))
|
||||
(if (string-match "^\\(.+\\)_tests$" module-name)
|
||||
(substring module-name (match-beginning 1) (match-end 1))
|
||||
module-name)))
|
||||
|
||||
;;; Return the module name of the file
|
||||
;;; /tmp/foo/src/x.erl --> x
|
||||
;;; /tmp/foo/test/x_tests.erl --> x_tests
|
||||
(defun erlang-eunit-module-name (file-path)
|
||||
(interactive)
|
||||
(file-name-sans-extension (file-name-nondirectory file-path)))
|
||||
|
||||
;;; Older emacsen don't have string-match-p.
|
||||
(defun erlang-eunit-string-match-p (regexp string &optional start)
|
||||
(if (fboundp 'string-match-p) ;; appeared in emacs 23
|
||||
(string-match-p regexp string start)
|
||||
(save-match-data ;; fallback for earlier versions of emacs
|
||||
(string-match regexp string start))))
|
||||
|
||||
;;; Join filenames
|
||||
(defun filename-join (dir file)
|
||||
(if (or (= (elt file 0) ?/)
|
||||
(= (car (last (append dir nil))) ?/))
|
||||
(concat dir file)
|
||||
(concat dir "/" file)))
|
||||
|
||||
;;; Get info about the most recent running of EUnit
|
||||
(defun erlang-eunit-recent (key)
|
||||
(cdr (assq key erlang-eunit-recent-info)))
|
||||
|
||||
;;; Record info about the most recent running of EUnit
|
||||
;;; Known modes are 'module-mode and 'test-mode
|
||||
(defun erlang-eunit-record-recent (mode module test)
|
||||
(setcdr (assq 'mode erlang-eunit-recent-info) mode)
|
||||
(setcdr (assq 'module erlang-eunit-recent-info) module)
|
||||
(setcdr (assq 'test erlang-eunit-recent-info) test))
|
||||
|
||||
;;; Record whether the most recent running of EUnit included cover
|
||||
;;; compilation
|
||||
(defun erlang-eunit-record-recent-compile (under-cover)
|
||||
(setcdr (assq 'cover erlang-eunit-recent-info) under-cover))
|
||||
|
||||
;;; Determine options for EUnit.
|
||||
(defun erlang-eunit-opts ()
|
||||
(if current-prefix-arg ", [verbose]" ""))
|
||||
|
||||
;;; Determine current test function
|
||||
(defun erlang-eunit-current-test ()
|
||||
(save-excursion
|
||||
(erlang-end-of-function 1)
|
||||
(erlang-beginning-of-function 1)
|
||||
(erlang-name-of-function)))
|
||||
|
||||
(defun erlang-eunit-simple-test-p (test-name)
|
||||
(if (erlang-eunit-string-match-p "^\\(.+\\)_test$" test-name) t nil))
|
||||
|
||||
(defun erlang-eunit-test-generator-p (test-name)
|
||||
(if (erlang-eunit-string-match-p "^\\(.+\\)_test_$" test-name) t nil))
|
||||
|
||||
;;; Run one EUnit test
|
||||
(defun erlang-eunit-run-test (module-name test-name)
|
||||
(let ((command
|
||||
(cond ((erlang-eunit-simple-test-p test-name)
|
||||
(format "eunit:test({%s, %s}%s)."
|
||||
module-name test-name (erlang-eunit-opts)))
|
||||
((erlang-eunit-test-generator-p test-name)
|
||||
(format "eunit:test({generator, %s, %s}%s)."
|
||||
module-name test-name (erlang-eunit-opts)))
|
||||
(t (format "%% WARNING: '%s' is not a test function" test-name)))))
|
||||
(erlang-eunit-record-recent 'test-mode module-name test-name)
|
||||
(erlang-eunit-inferior-erlang-send-command command)))
|
||||
|
||||
;;; Run EUnit tests for the current module
|
||||
(defun erlang-eunit-run-module-tests (module-name)
|
||||
(let ((command (format "eunit:test(%s%s)." module-name (erlang-eunit-opts))))
|
||||
(erlang-eunit-record-recent 'module-mode module-name nil)
|
||||
(erlang-eunit-inferior-erlang-send-command command)))
|
||||
|
||||
(defun erlang-eunit-compile-and-run-recent ()
|
||||
"Compile the source and test files and repeat the most recent EUnit test run.
|
||||
|
||||
With prefix arg, compiles for debug and runs tests with the verbose flag set."
|
||||
(interactive)
|
||||
(case (erlang-eunit-recent 'mode)
|
||||
('test-mode
|
||||
(erlang-eunit-compile-and-test
|
||||
'erlang-eunit-run-test (list (erlang-eunit-recent 'module)
|
||||
(erlang-eunit-recent 'test))))
|
||||
('module-mode
|
||||
(erlang-eunit-compile-and-test
|
||||
'erlang-eunit-run-module-tests (list (erlang-eunit-recent 'module))
|
||||
(erlang-eunit-recent 'cover)))
|
||||
(t (error "EUnit has not yet been run. Please run a test first."))))
|
||||
|
||||
(defun erlang-eunit-cover-compile ()
|
||||
"Cover compile current module."
|
||||
(interactive)
|
||||
(let* ((erlang-compile-extra-opts
|
||||
(append (list 'debug_info) erlang-compile-extra-opts))
|
||||
(module-name
|
||||
(erlang-add-quotes-if-needed
|
||||
(erlang-eunit-module-name buffer-file-name)))
|
||||
(compile-command
|
||||
(format "cover:compile_beam(%s)." module-name)))
|
||||
(erlang-compile)
|
||||
(if (erlang-eunit-last-compilation-successful-p)
|
||||
(erlang-eunit-inferior-erlang-send-command compile-command))))
|
||||
|
||||
(defun erlang-eunit-analyze-coverage ()
|
||||
"Analyze the data collected by cover tool for the module in the
|
||||
current buffer.
|
||||
|
||||
Assumes that the module has been cover compiled prior to this
|
||||
call. This function will do two things: print the number of
|
||||
covered and uncovered functions in the erlang shell and display a
|
||||
new buffer called *<module name> coverage* which shows the source
|
||||
code along with the coverage analysis results."
|
||||
(interactive)
|
||||
(let* ((module-name (erlang-add-quotes-if-needed
|
||||
(erlang-eunit-module-name buffer-file-name)))
|
||||
(tmp-filename (make-temp-file "cover"))
|
||||
(analyze-command (format "cover:analyze_to_file(%s, \"%s\"). "
|
||||
module-name tmp-filename))
|
||||
(buf-name (format "*%s coverage*" module-name)))
|
||||
(erlang-eunit-inferior-erlang-send-command analyze-command)
|
||||
;; The purpose of the following snippet is to get the result of the
|
||||
;; analysis from a file into a new buffer (or an old, if one with
|
||||
;; the specified name already exists). Also we want the erlang-mode
|
||||
;; *and* view-mode to be enabled.
|
||||
(save-excursion
|
||||
(let ((buf (get-buffer-create (format "*%s coverage*" module-name))))
|
||||
(set-buffer buf)
|
||||
(setq buffer-read-only nil)
|
||||
(insert-file-contents tmp-filename nil nil nil t)
|
||||
(if (= (buffer-size) 0)
|
||||
(kill-buffer buf)
|
||||
;; FIXME: this would be a good place to enable (emacs-mode)
|
||||
;; to get some nice syntax highlighting in the
|
||||
;; coverage report, but it doesn't play well with
|
||||
;; flymake. Leave it off for now.
|
||||
(view-buffer buf))))
|
||||
(delete-file tmp-filename)))
|
||||
|
||||
(defun erlang-eunit-compile-and-run-current-test ()
|
||||
"Compile the source and test files and run the current EUnit test.
|
||||
|
||||
With prefix arg, compiles for debug and runs tests with the verbose flag set."
|
||||
(interactive)
|
||||
(let ((module-name (erlang-add-quotes-if-needed
|
||||
(erlang-eunit-module-name buffer-file-name)))
|
||||
(test-name (erlang-eunit-current-test)))
|
||||
(erlang-eunit-compile-and-test
|
||||
'erlang-eunit-run-test (list module-name test-name))))
|
||||
|
||||
(defun erlang-eunit-compile-and-run-module-tests ()
|
||||
"Compile the source and test files and run all EUnit tests in the module.
|
||||
|
||||
With prefix arg, compiles for debug and runs tests with the verbose flag set."
|
||||
(interactive)
|
||||
(let ((module-name (erlang-add-quotes-if-needed
|
||||
(erlang-eunit-source-module-name buffer-file-name))))
|
||||
(erlang-eunit-compile-and-test
|
||||
'erlang-eunit-run-module-tests (list module-name))))
|
||||
|
||||
;;; Compile source and EUnit test file and finally run EUnit tests for
|
||||
;;; the current module
|
||||
(defun erlang-eunit-compile-and-test (test-fun test-args &optional under-cover)
|
||||
"Compile the source and test files and run the EUnit test suite.
|
||||
|
||||
If under-cover is set to t, the module under test is compile for
|
||||
code coverage analysis. If under-cover is left out or not set,
|
||||
coverage analysis is disabled. The result of the code coverage
|
||||
is both printed to the erlang shell (the number of covered vs
|
||||
uncovered functions in a module) and written to a buffer called
|
||||
*<module> coverage* (which shows the source code for the module
|
||||
and the number of times each line is covered).
|
||||
With prefix arg, compiles for debug and runs tests with the verbose flag set."
|
||||
(erlang-eunit-record-recent-compile under-cover)
|
||||
(let ((src-filename (erlang-eunit-src-filename buffer-file-name))
|
||||
(test-filename (erlang-eunit-test-filename buffer-file-name)))
|
||||
|
||||
;; The purpose of out-maneuvering `save-some-buffers', as is done
|
||||
;; below, is to ask the question about saving buffers only once,
|
||||
;; instead of possibly several: one for each file to compile,
|
||||
;; for instance for both x.erl and x_tests.erl.
|
||||
(save-some-buffers erlang-eunit-autosave)
|
||||
(flet ((save-some-buffers (&optional any) nil))
|
||||
|
||||
;; Compilation of the source file is mandatory (the file must
|
||||
;; exist, otherwise the procedure is aborted). Compilation of the
|
||||
;; test file on the other hand, is optional, since eunit tests may
|
||||
;; be placed in the source file instead. Any compilation error
|
||||
;; will prevent the subsequent steps to be run (hence the `and')
|
||||
(and (erlang-eunit-compile-file src-filename under-cover)
|
||||
(if (file-readable-p test-filename)
|
||||
(erlang-eunit-compile-file test-filename)
|
||||
t)
|
||||
(apply test-fun test-args)
|
||||
(if under-cover
|
||||
(save-excursion
|
||||
(set-buffer (find-file-noselect src-filename))
|
||||
(erlang-eunit-analyze-coverage)))))))
|
||||
|
||||
(defun erlang-eunit-compile-and-run-module-tests-under-cover ()
|
||||
"Compile the source and test files and run the EUnit test suite and measure
|
||||
code coverage.
|
||||
|
||||
With prefix arg, compiles for debug and runs tests with the verbose flag set."
|
||||
(interactive)
|
||||
(let ((module-name (erlang-add-quotes-if-needed
|
||||
(erlang-eunit-source-module-name buffer-file-name))))
|
||||
(erlang-eunit-compile-and-test
|
||||
'erlang-eunit-run-module-tests (list module-name) t)))
|
||||
|
||||
(defun erlang-eunit-compile-file (file-path &optional under-cover)
|
||||
(if (file-readable-p file-path)
|
||||
(save-excursion
|
||||
(set-buffer (find-file-noselect file-path))
|
||||
;; In order to run a code coverage analysis on a
|
||||
;; module, we have two options:
|
||||
;;
|
||||
;; * either compile the module with cover:compile instead of the
|
||||
;; regular compiler
|
||||
;;
|
||||
;; * or first compile the module with the regular compiler (but
|
||||
;; *with* debug_info) and then compile it for coverage
|
||||
;; analysis using cover:compile_beam.
|
||||
;;
|
||||
;; We could accomplish the first by changing the
|
||||
;; erlang-compile-erlang-function to cover:compile, but there's
|
||||
;; a risk that that's used for other purposes. Therefore, a
|
||||
;; safer alternative (although with more steps) is to add
|
||||
;; debug_info to the list of compiler options and go for the
|
||||
;; second alternative.
|
||||
(if under-cover
|
||||
(erlang-eunit-cover-compile)
|
||||
(erlang-compile))
|
||||
(erlang-eunit-last-compilation-successful-p))
|
||||
(let ((msg (format "Could not read %s" file-path)))
|
||||
(erlang-eunit-inferior-erlang-send-command
|
||||
(format "%% WARNING: %s" msg))
|
||||
(error msg))))
|
||||
|
||||
(defun erlang-eunit-last-compilation-successful-p ()
|
||||
(save-excursion
|
||||
(set-buffer inferior-erlang-buffer)
|
||||
(goto-char compilation-parsing-end)
|
||||
(erlang-eunit-all-list-elems-fulfill-p
|
||||
(lambda (re) (let ((continue t)
|
||||
(result t))
|
||||
(while continue ; ignore warnings, stop at errors
|
||||
(if (re-search-forward re (point-max) t)
|
||||
(if (erlang-eunit-is-compilation-warning)
|
||||
t
|
||||
(setq result nil)
|
||||
(setq continue nil))
|
||||
(setq result t)
|
||||
(setq continue nil)))
|
||||
result))
|
||||
(mapcar (lambda (e) (car e)) erlang-error-regexp-alist))))
|
||||
|
||||
(defun erlang-eunit-is-compilation-warning ()
|
||||
(erlang-eunit-string-match-p
|
||||
"[0-9]+: Warning:"
|
||||
(buffer-substring (line-beginning-position) (line-end-position))))
|
||||
|
||||
(defun erlang-eunit-all-list-elems-fulfill-p (pred list)
|
||||
(let ((matches-p t))
|
||||
(while (and list matches-p)
|
||||
(if (not (funcall pred (car list)))
|
||||
(setq matches-p nil))
|
||||
(setq list (cdr list)))
|
||||
matches-p))
|
||||
|
||||
;;; Evaluate a command in an erlang buffer
|
||||
(defun erlang-eunit-inferior-erlang-send-command (command)
|
||||
"Evaluate a command in an erlang buffer."
|
||||
(interactive "P")
|
||||
(inferior-erlang-prepare-for-input)
|
||||
(inferior-erlang-send-command command)
|
||||
(sit-for 0) ;; redisplay
|
||||
(inferior-erlang-wait-prompt))
|
||||
|
||||
|
||||
;;;====================================================================
|
||||
;;; Key bindings
|
||||
;;;====================================================================
|
||||
|
||||
(defconst erlang-eunit-key-bindings
|
||||
'(("\C-c\C-et" erlang-eunit-toggle-src-and-test-file-other-window)
|
||||
("\C-c\C-ek" erlang-eunit-compile-and-run-module-tests)
|
||||
("\C-c\C-ej" erlang-eunit-compile-and-run-current-test)
|
||||
("\C-c\C-el" erlang-eunit-compile-and-run-recent)
|
||||
("\C-c\C-ec" erlang-eunit-compile-and-run-module-tests-under-cover)
|
||||
("\C-c\C-ev" erlang-eunit-cover-compile)
|
||||
("\C-c\C-ea" erlang-eunit-analyze-coverage)))
|
||||
|
||||
(defun erlang-eunit-add-key-bindings ()
|
||||
(dolist (binding erlang-eunit-key-bindings)
|
||||
(erlang-eunit-bind-key (car binding) (cadr binding))))
|
||||
|
||||
(defun erlang-eunit-bind-key (key function)
|
||||
(erlang-eunit-ensure-keymap-for-key key)
|
||||
(local-set-key key function))
|
||||
|
||||
(defun erlang-eunit-ensure-keymap-for-key (key-seq)
|
||||
(let ((prefix-keys (butlast (append key-seq nil)))
|
||||
(prefix-seq ""))
|
||||
(while prefix-keys
|
||||
(setq prefix-seq (concat prefix-seq (make-string 1 (car prefix-keys))))
|
||||
(setq prefix-keys (cdr prefix-keys))
|
||||
(if (not (keymapp (lookup-key (current-local-map) prefix-seq)))
|
||||
(local-set-key prefix-seq (make-sparse-keymap))))))
|
||||
|
||||
(add-hook 'erlang-mode-hook 'erlang-eunit-add-key-bindings)
|
||||
|
||||
|
||||
(provide 'erlang-eunit)
|
||||
;; erlang-eunit ends here
|
|
@ -0,0 +1,103 @@
|
|||
;; erlang-flymake.el
|
||||
;;
|
||||
;; Syntax check erlang source code on the fly (integrates with flymake).
|
||||
;;
|
||||
;; Start using flymake with erlang by putting the following somewhere
|
||||
;; in your .emacs file:
|
||||
;;
|
||||
;; (require 'erlang-flymake)
|
||||
;;
|
||||
;; Flymake is rather eager and does its syntax checks frequently by
|
||||
;; default and if you are bothered by this, you might want to put the
|
||||
;; following in your .emacs as well:
|
||||
;;
|
||||
;; (erlang-flymake-only-on-save)
|
||||
;;
|
||||
;; There are a couple of variables which control the compilation options:
|
||||
;; * erlang-flymake-get-code-path-dirs-function
|
||||
;; * erlang-flymake-get-include-dirs-function
|
||||
;; * erlang-flymake-extra-opts
|
||||
;;
|
||||
;; This code is inspired by http://www.emacswiki.org/emacs/FlymakeErlang.
|
||||
|
||||
(require 'flymake)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(defvar erlang-flymake-command
|
||||
"erlc"
|
||||
"The command that will be used to perform the syntax check")
|
||||
|
||||
(defvar erlang-flymake-get-code-path-dirs-function
|
||||
'erlang-flymake-get-code-path-dirs
|
||||
"Return a list of ebin directories to add to the code path.")
|
||||
|
||||
(defvar erlang-flymake-get-include-dirs-function
|
||||
'erlang-flymake-get-include-dirs
|
||||
"Return a list of include directories to add to the compiler options.")
|
||||
|
||||
(defvar erlang-flymake-extra-opts
|
||||
(list "+warn_obsolete_guard"
|
||||
"+warn_unused_import"
|
||||
"+warn_shadow_vars"
|
||||
"+warn_export_vars"
|
||||
"+strong_validation"
|
||||
"+report")
|
||||
"A list of options that will be passed to the compiler")
|
||||
|
||||
(defun erlang-flymake-only-on-save ()
|
||||
"Trigger flymake only when the buffer is saved (disables syntax
|
||||
check on newline and when there are no changes)."
|
||||
(interactive)
|
||||
;; There doesn't seem to be a way of disabling this; set to the
|
||||
;; largest int available as a workaround (most-positive-fixnum
|
||||
;; equates to 8.5 years on my machine, so it ought to be enough ;-) )
|
||||
(setq flymake-no-changes-timeout most-positive-fixnum)
|
||||
(setq flymake-start-syntax-check-on-newline nil))
|
||||
|
||||
|
||||
(defun erlang-flymake-get-code-path-dirs ()
|
||||
(list (concat (erlang-flymake-get-app-dir) "ebin")))
|
||||
|
||||
(defun erlang-flymake-get-include-dirs ()
|
||||
(list (concat (erlang-flymake-get-app-dir) "include")
|
||||
(concat (erlang-flymake-get-app-dir) "deps")))
|
||||
|
||||
(defun erlang-flymake-get-app-dir ()
|
||||
(let ((src-path (file-name-directory (buffer-file-name))))
|
||||
(file-name-directory (directory-file-name src-path))))
|
||||
|
||||
(defun erlang-flymake-init ()
|
||||
(let* ((temp-file
|
||||
(flet ((flymake-get-temp-dir () (erlang-flymake-temp-dir)))
|
||||
(flymake-init-create-temp-buffer-copy
|
||||
'flymake-create-temp-with-folder-structure)))
|
||||
(code-dir-opts
|
||||
(erlang-flymake-flatten
|
||||
(mapcar (lambda (dir) (list "-pa" dir))
|
||||
(funcall erlang-flymake-get-code-path-dirs-function))))
|
||||
(inc-dir-opts
|
||||
(erlang-flymake-flatten
|
||||
(mapcar (lambda (dir) (list "-I" dir))
|
||||
(funcall erlang-flymake-get-include-dirs-function))))
|
||||
(compile-opts
|
||||
(append inc-dir-opts
|
||||
code-dir-opts
|
||||
erlang-flymake-extra-opts)))
|
||||
(list erlang-flymake-command (append compile-opts (list temp-file)))))
|
||||
|
||||
(defun erlang-flymake-temp-dir ()
|
||||
;; Squeeze the user's name in there in order to make sure that files
|
||||
;; for two users who are working on the same computer (like a linux
|
||||
;; box) don't collide
|
||||
(format "%s/flymake-%s" temporary-file-directory user-login-name))
|
||||
|
||||
(defun erlang-flymake-flatten (list)
|
||||
(apply #'append list))
|
||||
|
||||
(add-to-list 'flymake-allowed-file-name-masks
|
||||
'("\\.erl\\'" erlang-flymake-init))
|
||||
(add-hook 'erlang-mode-hook 'flymake-mode)
|
||||
|
||||
(provide 'erlang-flymake)
|
||||
;; erlang-flymake ends here
|
|
@ -0,0 +1,2 @@
|
|||
(define-package "erlang" "20130214.1536" "Erlang major mode [source: github]"
|
||||
'((flymake "0.4.13")))
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,121 @@
|
|||
;; erlang-start.el --- Load this file to initialize the Erlang package.
|
||||
|
||||
;; Copyright (C) 1998 Ericsson Telecom AB
|
||||
|
||||
;; Author: Anders Lindgren
|
||||
;; Version: 2.3
|
||||
;; Keywords: erlang, languages, processes
|
||||
;; Created: 1996-09-18
|
||||
;; Date: 1998-03-16
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Introduction:
|
||||
;; ------------
|
||||
;;
|
||||
;; This package provides support for the programming language Erlang.
|
||||
;; The package provides an editing mode with lots of bells and
|
||||
;; whistles, compilation support, and it makes it possible for the
|
||||
;; user to start Erlang shells that run inside Emacs.
|
||||
;;
|
||||
;; See the Erlang distribution for full documentation of this package.
|
||||
|
||||
;; Installation:
|
||||
;; ------------
|
||||
;;
|
||||
;; Place this file in Emacs load path, byte-compile it, and add the
|
||||
;; following line to the appropriate init file:
|
||||
;;
|
||||
;; (require 'erlang-start)
|
||||
;;
|
||||
;; The full documentation contains much more extensive description of
|
||||
;; the installation procedure.
|
||||
|
||||
;; Reporting Bugs:
|
||||
;; --------------
|
||||
;;
|
||||
;; Please send bug reports to the following email address:
|
||||
;; support@erlang.ericsson.se
|
||||
;;
|
||||
;; Please state as exactly as possible:
|
||||
;; - Version number of Erlang Mode (see the menu), Emacs, Erlang,
|
||||
;; and of any other relevant software.
|
||||
;; - What the expected result was.
|
||||
;; - What you did, preferably in a repeatable step-by-step form.
|
||||
;; - A description of the unexpected result.
|
||||
;; - Relevant pieces of Erlang code causing the problem.
|
||||
;; - Personal Emacs customisations, if any.
|
||||
;;
|
||||
;; Should the Emacs generate an error, please set the emacs variable
|
||||
;; `debug-on-error' to `t'. Repeat the error and enclose the debug
|
||||
;; information in your bug-report.
|
||||
;;
|
||||
;; To set the variable you can use the following command:
|
||||
;; M-x set-variable RET debug-on-error RET t RET
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;
|
||||
;; Declare functions in "erlang.el".
|
||||
;;
|
||||
|
||||
(autoload 'erlang-mode "erlang" "Major mode for editing Erlang code." t)
|
||||
(autoload 'erlang-version "erlang"
|
||||
"Return the current version of Erlang mode." t)
|
||||
(autoload 'erlang-shell "erlang" "Start a new Erlang shell." t)
|
||||
(autoload 'run-erlang "erlang" "Start a new Erlang shell." t)
|
||||
|
||||
(autoload 'erlang-compile "erlang"
|
||||
"Compile Erlang module in current buffer." t)
|
||||
|
||||
(autoload 'erlang-man-module "erlang"
|
||||
"Find manual page for MODULE." t)
|
||||
(autoload 'erlang-man-function "erlang"
|
||||
"Find manual page for NAME, where NAME is module:function." t)
|
||||
|
||||
(autoload 'erlang-find-tag "erlang"
|
||||
"Like `find-tag'. Capable of retreiving Erlang modules.")
|
||||
(autoload 'erlang-find-tag-other-window "erlang"
|
||||
"Like `find-tag-other-window'. Capable of retreiving Erlang modules.")
|
||||
|
||||
|
||||
;;
|
||||
;; Associate files extensions ".erl" and ".hrl" with Erlang mode.
|
||||
;;
|
||||
|
||||
(let ((a '("\\.erl\\'" . erlang-mode))
|
||||
(b '("\\.hrl\\'" . erlang-mode)))
|
||||
(or (assoc (car a) auto-mode-alist)
|
||||
(setq auto-mode-alist (cons a auto-mode-alist)))
|
||||
(or (assoc (car b) auto-mode-alist)
|
||||
(setq auto-mode-alist (cons b auto-mode-alist))))
|
||||
|
||||
;;
|
||||
;; Associate files using interpreter "escript" with Erlang mode.
|
||||
;;
|
||||
|
||||
(add-to-list 'interpreter-mode-alist (cons "escript" 'erlang-mode))
|
||||
|
||||
;;
|
||||
;; Ignore files ending in ".jam", ".vee", and ".beam" when performing
|
||||
;; file completion.
|
||||
;;
|
||||
|
||||
(let ((erl-ext '(".jam" ".vee" ".beam")))
|
||||
(while erl-ext
|
||||
(let ((cie completion-ignored-extensions))
|
||||
(while (and cie (not (string-equal (car cie) (car erl-ext))))
|
||||
(setq cie (cdr cie)))
|
||||
(if (null cie)
|
||||
(setq completion-ignored-extensions
|
||||
(cons (car erl-ext) completion-ignored-extensions))))
|
||||
(setq erl-ext (cdr erl-ext))))
|
||||
|
||||
|
||||
;;
|
||||
;; The end.
|
||||
;;
|
||||
|
||||
(provide 'erlang-start)
|
||||
|
||||
;; erlang-start.el ends here.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,172 @@
|
|||
;; Buffer-related defuns
|
||||
|
||||
(require 'imenu)
|
||||
|
||||
(defvar buffer-local-mode nil)
|
||||
(make-variable-buffer-local 'buffer-local-mode)
|
||||
|
||||
(defun mode-keymap (mode-sym)
|
||||
(symbol-value (intern (concat (symbol-name mode-sym) "-map"))))
|
||||
|
||||
(defun* buffer-local-set-key (key action)
|
||||
(when buffer-local-mode
|
||||
(define-key (mode-keymap buffer-local-mode)
|
||||
key action)
|
||||
(return-from set-key-buffer-local))
|
||||
(let* ((mode-name-loc (gensym "-blm")))
|
||||
(eval `(define-minor-mode ,mode-name-loc nil nil nil (make-sparse-keymap)))
|
||||
(setq buffer-local-mode mode-name-loc)
|
||||
(funcall mode-name-loc 1)
|
||||
(define-key (mode-keymap mode-name-loc) key action)))
|
||||
|
||||
(defun create-scratch-buffer nil
|
||||
"create a new scratch buffer to work in. (could be *scratch* - *scratchX*)"
|
||||
(interactive)
|
||||
(let ((n 0)
|
||||
bufname)
|
||||
(while (progn
|
||||
(setq bufname (concat "*scratch"
|
||||
(if (= n 0) "" (int-to-string n))
|
||||
"*"))
|
||||
(setq n (1+ n))
|
||||
(get-buffer bufname)))
|
||||
(switch-to-buffer (get-buffer-create bufname))
|
||||
(emacs-lisp-mode)
|
||||
))
|
||||
|
||||
(defun split-window-right-and-move-there-dammit ()
|
||||
(interactive)
|
||||
(split-window-right)
|
||||
(windmove-right))
|
||||
|
||||
(defun toggle-window-split ()
|
||||
(interactive)
|
||||
(if (= (count-windows) 2)
|
||||
(let* ((this-win-buffer (window-buffer))
|
||||
(next-win-buffer (window-buffer (next-window)))
|
||||
(this-win-edges (window-edges (selected-window)))
|
||||
(next-win-edges (window-edges (next-window)))
|
||||
(this-win-2nd (not (and (<= (car this-win-edges)
|
||||
(car next-win-edges))
|
||||
(<= (cadr this-win-edges)
|
||||
(cadr next-win-edges)))))
|
||||
(splitter
|
||||
(if (= (car this-win-edges)
|
||||
(car (window-edges (next-window))))
|
||||
'split-window-horizontally
|
||||
'split-window-vertically)))
|
||||
(delete-other-windows)
|
||||
(let ((first-win (selected-window)))
|
||||
(funcall splitter)
|
||||
(if this-win-2nd (other-window 1))
|
||||
(set-window-buffer (selected-window) this-win-buffer)
|
||||
(set-window-buffer (next-window) next-win-buffer)
|
||||
(select-window first-win)
|
||||
(if this-win-2nd (other-window 1))))))
|
||||
|
||||
(defun rotate-windows ()
|
||||
"Rotate your windows"
|
||||
(interactive)
|
||||
(cond ((not (> (count-windows)1))
|
||||
(message "You can't rotate a single window!"))
|
||||
(t
|
||||
(setq i 1)
|
||||
(setq numWindows (count-windows))
|
||||
(while (< i numWindows)
|
||||
(let* (
|
||||
(w1 (elt (window-list) i))
|
||||
(w2 (elt (window-list) (+ (% i numWindows) 1)))
|
||||
|
||||
(b1 (window-buffer w1))
|
||||
(b2 (window-buffer w2))
|
||||
|
||||
(s1 (window-start w1))
|
||||
(s2 (window-start w2))
|
||||
)
|
||||
(set-window-buffer w1 b2)
|
||||
(set-window-buffer w2 b1)
|
||||
(set-window-start w1 s2)
|
||||
(set-window-start w2 s1)
|
||||
(setq i (1+ i)))))))
|
||||
|
||||
(defun ido-imenu ()
|
||||
"Update the imenu index and then use ido to select a symbol to navigate to.
|
||||
Symbols matching the text at point are put first in the completion list."
|
||||
(interactive)
|
||||
(imenu--make-index-alist)
|
||||
(let ((name-and-pos '())
|
||||
(symbol-names '()))
|
||||
(flet ((addsymbols (symbol-list)
|
||||
(when (listp symbol-list)
|
||||
(dolist (symbol symbol-list)
|
||||
(let ((name nil) (position nil))
|
||||
(cond
|
||||
((and (listp symbol) (imenu--subalist-p symbol))
|
||||
(addsymbols symbol))
|
||||
|
||||
((listp symbol)
|
||||
(setq name (car symbol))
|
||||
(setq position (cdr symbol)))
|
||||
|
||||
((stringp symbol)
|
||||
(setq name symbol)
|
||||
(setq position (get-text-property 1 'org-imenu-marker symbol))))
|
||||
|
||||
(unless (or (null position) (null name))
|
||||
(add-to-list 'symbol-names name)
|
||||
(add-to-list 'name-and-pos (cons name position))))))))
|
||||
(addsymbols imenu--index-alist))
|
||||
;; If there are matching symbols at point, put them at the beginning of `symbol-names'.
|
||||
(let ((symbol-at-point (thing-at-point 'symbol)))
|
||||
(when symbol-at-point
|
||||
(let* ((regexp (concat (regexp-quote symbol-at-point) "$"))
|
||||
(matching-symbols (delq nil (mapcar (lambda (symbol)
|
||||
(if (string-match regexp symbol) symbol))
|
||||
symbol-names))))
|
||||
(when matching-symbols
|
||||
(sort matching-symbols (lambda (a b) (> (length a) (length b))))
|
||||
(mapc (lambda (symbol) (setq symbol-names (cons symbol (delete symbol symbol-names))))
|
||||
matching-symbols)))))
|
||||
(let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names))
|
||||
(position (cdr (assoc selected-symbol name-and-pos))))
|
||||
(push-mark (point))
|
||||
(goto-char position))))
|
||||
|
||||
(defun untabify-buffer ()
|
||||
(interactive)
|
||||
(untabify (point-min) (point-max)))
|
||||
|
||||
(defun indent-buffer ()
|
||||
(interactive)
|
||||
(indent-region (point-min) (point-max)))
|
||||
|
||||
(defun cleanup-buffer-safe ()
|
||||
"Perform a bunch of safe operations on the whitespace content of a buffer.
|
||||
Does not indent buffer, because it is used for a before-save-hook, and that
|
||||
might be bad."
|
||||
(interactive)
|
||||
(untabify-buffer)
|
||||
(delete-trailing-whitespace)
|
||||
(set-buffer-file-coding-system 'utf-8))
|
||||
|
||||
(defun cleanup-buffer ()
|
||||
"Perform a bunch of operations on the whitespace content of a buffer.
|
||||
Including indent-buffer, which should not be called automatically on save."
|
||||
(interactive)
|
||||
(cleanup-buffer-safe)
|
||||
(indent-buffer))
|
||||
|
||||
(defun file-name-with-one-directory (file-name)
|
||||
(concat (cadr (reverse (split-string file-name "/"))) "/"
|
||||
(file-name-nondirectory file-name)))
|
||||
|
||||
(defun recentf--file-cons (file-name)
|
||||
(cons (file-name-with-one-directory file-name) file-name))
|
||||
|
||||
(defun recentf-ido-find-file ()
|
||||
"Find a recent file using ido."
|
||||
(interactive)
|
||||
(let* ((recent-files (mapcar 'recentf--file-cons recentf-list))
|
||||
(files (mapcar 'car recent-files))
|
||||
(file (completing-read "Choose recent file: " files)))
|
||||
(find-file (cdr (assoc file recent-files)))))
|
|
@ -0,0 +1,79 @@
|
|||
;;; custom-init.el -- customized Emacs init options
|
||||
|
||||
;;; Commentary:
|
||||
;;; These options are ones that don't somehow fit under the guise of the other
|
||||
;;; configuration files.
|
||||
|
||||
;;; Code:
|
||||
(load-library "~/.emacs.d/personal/repo.el")
|
||||
|
||||
;; Show line numbers in the left margin
|
||||
(package-initialize)
|
||||
|
||||
(defvar personal-packages
|
||||
'(fill-column-indicator mark-multiple rect-mark flymake))
|
||||
|
||||
;; This block was taken from the a Prelude init script and modified
|
||||
|
||||
(defun personal-packages-installed-p ()
|
||||
;; check if the listed packages are installed
|
||||
(loop for p in personal-packages
|
||||
when (not (package-installed-p p)) do (return nil)
|
||||
finally (return t)))
|
||||
|
||||
(unless (personal-packages-installed-p)
|
||||
;; check for new packages (package versions)
|
||||
(message "%s" "Emacs Prelude is now refreshing its package database...")
|
||||
(package-refresh-contents)
|
||||
(message "%s" " done.")
|
||||
;; install the missing packages
|
||||
(dolist (p personal-packages)
|
||||
(when (not (package-installed-p p))
|
||||
(package-install p))))
|
||||
|
||||
;; Show line numbers in left margin
|
||||
(global-linum-mode 1)
|
||||
|
||||
|
||||
;; Show a margin at 80 characters
|
||||
(require 'fill-column-indicator)
|
||||
(setq fci-rule-width 2)
|
||||
(setq fci-rule-color "black")
|
||||
|
||||
;; Set global font
|
||||
(when (eq system-type 'gnu/linux)
|
||||
(set-frame-font "Ubuntu Mono-10" nil))
|
||||
(when (eq system-type 'windows-nt)
|
||||
(set-frame-font "Consolas-10" nil))
|
||||
(when (eq system-type 'darwin)
|
||||
(set-frame-font "Monaco-11" nil))
|
||||
|
||||
|
||||
;; Reopen read-only files in tramp-mode
|
||||
(defun th-rename-tramp-buffer ()
|
||||
;; Override for find-file to open with tramp
|
||||
(when (file-remote-p (buffer-file-name))
|
||||
(rename-buffer
|
||||
(format "%s:%s"
|
||||
(file-remote-p (buffer-file-name) 'method)
|
||||
(buffer-name)))))
|
||||
|
||||
(add-hook 'find-file-hook
|
||||
'th-rename-tramp-buffer)
|
||||
|
||||
(defadvice find-file (around th-find-file activate)
|
||||
"Open FILENAME using tramp's sudo method if it's read-only."
|
||||
(if (and (not (file-writable-p (ad-get-arg 0)))
|
||||
(y-or-n-p (concat "File "
|
||||
(ad-get-arg 0)
|
||||
" is read-only. Open it as root? ")))
|
||||
(th-find-file-sudo (ad-get-arg 0))
|
||||
ad-do-it))
|
||||
|
||||
(defun th-find-file-sudo (file)
|
||||
"Opens FILE with root privileges."
|
||||
(interactive "F")
|
||||
(set-buffer (find-file (concat "/sudo::" file))))
|
||||
|
||||
(provide 'custom-init)
|
||||
;;; custom-init.el ends here
|
|
@ -0,0 +1,39 @@
|
|||
;;; keybindings.el --- Custom keybindings go here
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Comment region
|
||||
|
||||
(global-set-key (kbd "C-c C-e") 'comment-region)
|
||||
(global-set-key (kbd "C-c C-u") 'uncomment-region)
|
||||
|
||||
;; Replace rectangle-text with inline-string-rectangle
|
||||
(global-set-key (kbd "C-x r t") 'inline-string-rectangle)
|
||||
|
||||
|
||||
;; Make rectangle selections visible
|
||||
(require 'mark-multiple)
|
||||
(require 'rect-mark)
|
||||
(global-set-key (kbd "C-x r C-SPC") 'rm-set-mark)
|
||||
(global-set-key (kbd "C-w")
|
||||
'(lambda(b e) (interactive "r")
|
||||
(if rm-mark-active
|
||||
(rm-kill-region b e) (kill-region b e))))
|
||||
(global-set-key (kbd "M-w")
|
||||
'(lambda(b e) (interactive "r")
|
||||
(if rm-mark-active
|
||||
(rm-kill-ring-save b e) (kill-ring-save b e))))
|
||||
(global-set-key (kbd "C-x C-x")
|
||||
'(lambda(&optional p) (interactive "p")
|
||||
(if rm-mark-active
|
||||
(rm-exchange-point-and-mark p) (exchange-point-and-mark p))))
|
||||
|
||||
;; Line Join
|
||||
(global-set-key (kbd "M-j")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(join-line -1)))
|
||||
|
||||
(provide 'keybindings)
|
||||
;;; keybindings.el ends here
|
|
@ -0,0 +1,3 @@
|
|||
;; Add the user-contributed repository
|
||||
(add-to-list 'package-archives
|
||||
'("marmalade" . "http://marmalade-repo.org/packages/"))
|
|
@ -0,0 +1,24 @@
|
|||
;;; Uncomment the modules you'd like to use and restart Prelude afterwards
|
||||
|
||||
(require 'prelude-c)
|
||||
;; (require 'prelude-clojure)
|
||||
;; (require 'prelude-coffee)
|
||||
;; (require 'prelude-common-lisp)
|
||||
;; (require 'prelude-css)
|
||||
(require 'prelude-emacs-lisp)
|
||||
(require 'prelude-erc)
|
||||
(require 'prelude-erlang)
|
||||
;; (require 'prelude-haskell)
|
||||
(require 'prelude-js)
|
||||
;; (require 'prelude-latex)
|
||||
(require 'prelude-lisp)
|
||||
(require 'prelude-markdown)
|
||||
;; (require 'prelude-mediawiki)
|
||||
(require 'prelude-org)
|
||||
(require 'prelude-perl)
|
||||
(require 'prelude-python)
|
||||
;; (require 'prelude-ruby)
|
||||
;; (require 'prelude-scala)
|
||||
(require 'prelude-scheme)
|
||||
;; (require 'prelude-scss)
|
||||
(require 'prelude-xml)
|
Loading…
Reference in New Issue