From e022596155ba8335b9a4f73f855c1262c9cb8b01 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Fri, 15 Sep 2017 07:52:22 +0200 Subject: Update yasnippet, enable which-function-mode in .emacs, add snippets/python-mode/bang --- .emacs | 4 ++-- .emacs.d/lisp/yasnippet.el | 9 +++++++-- .emacs.d/snippets/python-mode/bang | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .emacs.d/snippets/python-mode/bang diff --git a/.emacs b/.emacs index 912f1fb..c1824cd 100644 --- a/.emacs +++ b/.emacs @@ -64,8 +64,8 @@ (add-to-list 'auto-mode-alist '("\\.ino\\'" . c++-mode)) ;; Enable which-function-mode for C, C++ and Python -;; (setq which-func-modes '(c-mode c++-mode java-mode python-mode)) -;; (which-function-mode t) +(setq which-func-modes '(c-mode c++-mode java-mode python-mode)) +(which-function-mode t) ;; Custom plugins (add-to-list 'load-path "~/.emacs.d/lisp/") diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el index 94ccffb..aa9fe5e 100644 --- a/.emacs.d/lisp/yasnippet.el +++ b/.emacs.d/lisp/yasnippet.el @@ -3839,9 +3839,14 @@ considered when expanding the snippet." (when first-field (sit-for 0) ;; fix issue 125 (yas--letenv (yas--snippet-expand-env snippet) - (yas--move-to-field snippet first-field)))) + (yas--move-to-field snippet first-field)) + (when (and (eq (yas--field-number first-field) 0) + (> (length (yas--field-text-for-display + first-field)) + 0)) + ;; Keep region for ${0:exit text}. + (setq deactivate-mark nil)))) (yas--message 4 "snippet %d expanded." (yas--snippet-id snippet)) - (setq deactivate-mark nil) t)))) (defun yas--take-care-of-redo (_beg _end snippet) diff --git a/.emacs.d/snippets/python-mode/bang b/.emacs.d/snippets/python-mode/bang new file mode 100644 index 0000000..d70a4a2 --- /dev/null +++ b/.emacs.d/snippets/python-mode/bang @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: #! +# key: #! +# contributor : @avelino +# -- +#!/usr/bin/env python \ No newline at end of file -- cgit v1.3