summaryrefslogtreecommitdiff
path: root/snakemake-mode.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-05-11 21:01:41 -0400
committerKyle Meyer <kyle@kyleam.com>2016-05-11 21:07:30 -0400
commit2d6136fe2b44ec4f21d7fa4a20be1a43f103e308 (patch)
treebb3e2ae28f3e54f76fd912d6ff762201c871ec91 /snakemake-mode.el
parent2ddaa5a5bf4d74b51f64720ea1be94bf06394c41 (diff)
downloadsnakemake-mode-2d6136fe2b44ec4f21d7fa4a20be1a43f103e308.tar.gz
Define function for add-log-current-defun-function
Diffstat (limited to 'snakemake-mode.el')
-rw-r--r--snakemake-mode.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/snakemake-mode.el b/snakemake-mode.el
index a598aca..a8d0539 100644
--- a/snakemake-mode.el
+++ b/snakemake-mode.el
@@ -206,6 +206,23 @@ forward rather than backward."
"Move to end of current rule block or function."
(or (snakemake-end-of-block)
(python-nav-end-of-defun)))
+
+(defun snakemake-block-name ()
+ "Return rule name for current block."
+ (let ((bounds (snakemake-block-bounds)))
+ (when bounds
+ (save-excursion
+ (goto-char (car bounds))
+ (and (looking-at snakemake-rule-or-subworkflow-re)
+ (match-string-no-properties 2))))))
+
+(defun snakemake-block-or-defun-name ()
+ "Return name of current rule or function.
+This function is appropriate to use as the value of
+`add-log-current-defun-function'."
+ (or (snakemake-block-name)
+ (python-info-current-defun)))
+
;;; Indentation
@@ -400,6 +417,8 @@ embedded R, you need to set mmm-global-mode to a non-nil value such as 'maybe.")
#'snakemake-beginning-of-defun)
(set (make-local-variable 'end-of-defun-function)
#'snakemake-end-of-defun)
+ (set (make-local-variable 'add-log-current-defun-function)
+ #'python-info-current-defun)
(set (make-local-variable 'font-lock-defaults)
`(,(append snakemake-font-lock-keywords python-font-lock-keywords))))