summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbenj <benj@rse8.com>2018-03-16 12:39:17 -0700
committerbenj <benj@rse8.com>2018-03-16 12:39:17 -0700
commit67b696a4d68d98fff8158edf9c11b5d5d24d3fa7 (patch)
tree8512e9b385ed17883fd8ee8842549bb0d3d7ec31
parent5dd18d1598b22000b60a329c6b1cc18896c5ced6 (diff)
parentc38ef385a9af288cf2d2ff0f306b6b2176fcf47d (diff)
downloademacs-67b696a4d68d98fff8158edf9c11b5d5d24d3fa7.tar
emacs-67b696a4d68d98fff8158edf9c11b5d5d24d3fa7.tar.gz
emacs-67b696a4d68d98fff8158edf9c11b5d5d24d3fa7.tar.bz2
emacs-67b696a4d68d98fff8158edf9c11b5d5d24d3fa7.tar.lz
emacs-67b696a4d68d98fff8158edf9c11b5d5d24d3fa7.tar.xz
emacs-67b696a4d68d98fff8158edf9c11b5d5d24d3fa7.tar.zst
emacs-67b696a4d68d98fff8158edf9c11b5d5d24d3fa7.zip
Merge remote-tracking branch 'refs/remotes/origin/master'
Diffstat (limited to '')
-rw-r--r--auto-insert/template.c7
-rw-r--r--init.el31
-rw-r--r--settings/sane-defaults.el1
-rw-r--r--settings/setup-auto-insert-mode.el30
-rw-r--r--settings/setup-keychain-environment.el75
-rw-r--r--settings/setup-yasnippet.el8
l---------snippets/c-mode/doxycomments1
-rw-r--r--snippets/doxygen/doxycomments48
8 files changed, 191 insertions, 10 deletions
diff --git a/auto-insert/template.c b/auto-insert/template.c
new file mode 100644
index 0000000..d9afc65
--- /dev/null
+++ b/auto-insert/template.c
@@ -0,0 +1,7 @@
+/*
+ * @file `(buffer-name)`
+ * @brief $0
+ *
+ * @author `user-full-name`
+ * @date `(format-time-string "%Y-%m-%d")`
+ */
diff --git a/init.el b/init.el
index 0f1a305..78c1b87 100644
--- a/init.el
+++ b/init.el
@@ -1,7 +1,27 @@
-;; Added by Package.el. This must come before configurations of
-;; installed packages. Don't delete this line. If you don't want it,
-;; just comment it out by adding a semicolon to the start of the line.
-;; You may delete these explanatory comments.
+;;; init.el --- initialize emacs configuration
+
+;;; Author: Benj Bellon <benjaminbellon@gmail.com>
+;;; Maintainer: Benj Bellon <benjaminbellon@gmail.com>
+;;; Homepage: https://github.com/benjbellon/emacs.d
+;;; Keywords: emacs, emacs.d, config
+
+;;; Commentary:
+
+;;; This config builds an instance of Emacs personalized for its author.
+;;; A few things of interest:
+;;; 1. C-x C-c is overriden in the GUI so it redirects to the default
+;;; *ansi-term* buffer. If you wish for this override while using
+;;; Emacs in terminal mode, provide the following ENV variable:
+;;; EMACS_OVERRIDE_C_X_C_C
+;;;
+;;; 2. init.el calls keychain-refresh-environment. If for some reason,
+;;; you do not wish for the following to be available to Emacs, add
+;;; a comment or remove the call:
+;;; SSH_AUTH_SOCK
+;;; SSH_AGENT_PID
+;;; GPG_AGENT_INFO
+;;;
+;;; Code:
(package-initialize)
;; Suppress splash screen
@@ -75,6 +95,7 @@
(add-to-list 'exec-path "/usr/local/bin")
+(require 'setup-auto-insert-mode)
(require 'setup-c++-mode)
(require 'setup-clojure-mode)
(require 'setup-ember-mode)
@@ -82,6 +103,7 @@
(require 'setup-flycheck)
(require 'setup-haskell-mode)
(require 'setup-ido)
+(require 'setup-keychain-environment)
(require 'setup-magit)
(require 'setup-markdown-mode)
(require 'setup-multiple-cursors)
@@ -101,4 +123,5 @@
(put 'upcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)
+(keychain-refresh-environment)
;;; init.el ends here
diff --git a/settings/sane-defaults.el b/settings/sane-defaults.el
index fa4ca8e..ef7e213 100644
--- a/settings/sane-defaults.el
+++ b/settings/sane-defaults.el
@@ -12,7 +12,6 @@
;; define browsers
(define-key global-map (kbd "C-x w") 'browse-url-emacs)
-(define-key global-map (kbd "C-x w") 'browse-url-emacs)
(define-key global-map (kbd "C-x M-w") 'browse-url-chromium)
;; Also auto refresh dired, but be quiet about it
diff --git a/settings/setup-auto-insert-mode.el b/settings/setup-auto-insert-mode.el
new file mode 100644
index 0000000..81284db
--- /dev/null
+++ b/settings/setup-auto-insert-mode.el
@@ -0,0 +1,30 @@
+(require 'autoinsert)
+
+(defun custom/expand-yasnippet ()
+ "Replace with real stuff"
+ (yas-expand-snippet (buffer-string) (point-min) (point-max)))
+
+(custom-set-variables
+ '(auto-insert-directory (locate-user-emacs-file "auto-insert")))
+
+;; Activate globally
+(auto-insert-mode)
+(setq auto-insert-query nil)
+
+;; Some global auto-insert variables
+(setq user-full-name "Benj Bellon"
+ user-email "benjaminbellon@gmail.com")
+
+;; C
+(define-auto-insert "\\.c\\'" ["template.c" custom/expand-yasnippet])
+(define-auto-insert "\\.h\\'" ["template.h" custom/expand-yasnippet])
+
+;; C++
+(define-auto-insert "\\.cc\\'" ["template.cc" custom/expand-yasnippet])
+(define-auto-insert "\\.hh\\'" ["template.cc" custom/expand-yasnippet])
+
+;; Python
+(define-auto-insert "\\.py\\'" ["template.py" custom/expand-yasnippet])
+
+
+(provide 'setup-auto-insert-mode)
diff --git a/settings/setup-keychain-environment.el b/settings/setup-keychain-environment.el
new file mode 100644
index 0000000..6d6c294
--- /dev/null
+++ b/settings/setup-keychain-environment.el
@@ -0,0 +1,75 @@
+;;; keychain-environment.el --- load keychain environment variables
+
+;; Copyright (C) 2011-2016 Jonas Bernoulli
+;; Copyright (C) 2008-2011 Paul Tipper
+
+;; Author: Paul Tipper <bluefoo at googlemail dot com>
+;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
+;; Created: 20081218
+;; Homepage: https://github.com/tarsius/keychain-environment
+;; Keywords: gnupg, pgp, ssh
+
+;; This file is not part of GNU Emacs.
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; For a full copy of the GNU General Public License
+;; see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Keychain is a script that manages ssh-agent and gpg-agent. It is
+;; typically run from the shell's initialization file. It allows your
+;; shells and cron jobs to share a single ssh-agent and/or gpg-agent.
+
+;; When keychain is run, it checks for running agent, otherwise it
+;; starts them. It saves the agents' environment variables to files
+;; inside ~/.keychain/, so that subsequent shells can source these
+;; files.
+
+;; When Emacs is started under X11 and not directly from a terminal
+;; these variables are not set. This library looks for these files
+;; created by keychain and then sets Emacs' environment variables
+;; accordingly. It does not actually run keychain, so you still
+;; have to run that from a login shell first.
+
+;; To use run the function `keychain-refresh-environment' in your
+;; init file. If keychain has not been run yet when you start Emacs
+;; you can also later call that function interactively.
+
+;; Also see: http://www.funtoo.org/wiki/Keychain
+
+;;; Code:
+
+;;;###autoload
+(defun keychain-refresh-environment ()
+ "Set ssh-agent and gpg-agent environment variables.
+Set the environment variables `SSH_AUTH_SOCK', `SSH_AGENT_PID'
+and `GPG_AGENT' in Emacs' `process-environment' according to
+information retrieved from files created by the keychain script."
+ (interactive)
+ (let* ((ssh (shell-command-to-string "keychain -q --noask --agents ssh --eval"))
+ (gpg (shell-command-to-string "keychain -q --noask --agents gpg --eval")))
+ (list (and ssh
+ (string-match "SSH_AUTH_SOCK[=\s]\\([^\s;\n]*\\)" ssh)
+ (setenv "SSH_AUTH_SOCK" (match-string 1 ssh)))
+ (and ssh
+ (string-match "SSH_AGENT_PID[=\s]\\([0-9]*\\)?" ssh)
+ (setenv "SSH_AGENT_PID" (match-string 1 ssh)))
+ (and gpg
+ (string-match "GPG_AGENT_INFO[=\s]\\([^\s;\n]*\\)" gpg)
+ (setenv "GPG_AGENT_INFO" (match-string 1 gpg))))))
+
+(provide 'setup-keychain-environment)
+;; Local Variables:
+;; indent-tabs-mode: nil
+;; End:
+;;; setup-keychain-environment.el ends here
diff --git a/settings/setup-yasnippet.el b/settings/setup-yasnippet.el
index 4145574..5441327 100644
--- a/settings/setup-yasnippet.el
+++ b/settings/setup-yasnippet.el
@@ -1,13 +1,11 @@
(require 'yasnippet)
(setq yas-snippet-dirs '("~/.emacs.d/snippets"))
-(yas-global-mode 1)
-
-(define-key yas-minor-mode-map [(tab)] nil)
-(define-key yas-minor-mode-map (kbd "TAB") nil)
+(yas-global-mode 1)
;; Jump to end of snippet definition
-(define-key yas-keymap (kbd "<return>") 'yas-exit-all-snippets)
+(define-key yas-keymap (kbd "<return>") 'yas-next-field)
+(define-key yas-keymap (kbd "C-x RET TAB") 'yas-exit-all-snippets)
(add-hook 'term-mode-hook (lambda()
(setq yas-dont-activate t)))
diff --git a/snippets/c-mode/doxycomments b/snippets/c-mode/doxycomments
new file mode 120000
index 0000000..62fd598
--- /dev/null
+++ b/snippets/c-mode/doxycomments
@@ -0,0 +1 @@
+../doxygen/doxycomments \ No newline at end of file
diff --git a/snippets/doxygen/doxycomments b/snippets/doxygen/doxycomments
new file mode 100644
index 0000000..94209bc
--- /dev/null
+++ b/snippets/doxygen/doxycomments
@@ -0,0 +1,48 @@
+# -*- mode: snippet -*-
+# name: doxcomments
+# key: dox
+# type: command
+# --
+;; Command to generate doxygen comments for c functions
+
+(defun flatten (ls)
+ "Implements standard flatten function"
+ (cond
+ ((atom ls) (list ls))
+ ((null (cdr ls)) (flatten (car ls)))
+ (t (append (flatten (car ls)) (flatten (cdr ls))))))
+
+(defun find-retval ()
+ "Returns the return value of the next parsed function"
+ (interactive)
+ (let ((struct-type "struct"))
+ (search-forward "(" nil t)
+ (move-beginning-of-line nil)
+ (let ((return-type (thing-at-point 'symbol)))
+ (if (string= return-type struct-type)
+ "NOT_IMPLEMENTED"
+ return-type))))
+
+(defun find-args ()
+ "Returns a list of function args for the next parsed function"
+ (interactive)
+ (let* ((struct-type "struct")
+ (start (search-forward "(" nil t))
+ (end (search-forward ")" nil t))
+ (args-string (buffer-substring-no-properties start (1- end)))
+ (args (mapcar 'string-trim-left (split-string args-string "," t))))
+ (mapcar (lambda (x) (car (reverse x))) (mapcar 'split-string args))))
+
+(let* ((retval (find-retval))
+ (args (find-args))
+ (args-len (length args))
+ (brief "@brief $1\n *")
+ (params (mapcar (lambda (x) (format "@param: %s ${%d:}" (cdr x) (car x)))
+ (mapcar* 'cons
+ (mapcar '1+ (number-sequence 1 args-len))
+ args)))
+ (retval (format "@return %s $0" retval))
+ (snippet-text (mapconcat 'identity (flatten (list "/**" brief params (concat "\n * " retval)))
+ "\n * ")))
+ (move-beginning-of-line nil)
+ (yas-expand-snippet (concat snippet-text "\n*/\n")))