Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 905abd0

Browse filesBrowse files
authored
Set add-log-current-defun-function (#629)
1 parent 0be365a commit 905abd0
Copy full SHA for 905abd0

File tree

Expand file treeCollapse file tree

2 files changed

+36
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+36
-0
lines changed
Open diff view settings
Collapse file

‎CHANGELOG.md‎

Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### Changes
6+
7+
* [#629](https://github.com/clojure-emacs/clojure-mode/pull/629): Set `add-log-current-defun-function` to new function `clojure-current-defun-name` (this is used by which-function-mode and easy-kill).
8+
59
### Bugs fixed
610

711
* [#581](https://github.com/clojure-emacs/clojure-mode/issues/581): Fix font locking not working for keywords starting with a number
Collapse file

‎clojure-mode.el‎

Copy file name to clipboardExpand all lines: clojure-mode.el
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,37 @@ replacement for `cljr-expand-let`."
524524
#'clojure-space-for-delimiter-p)
525525
(advice-add 'paredit-convolute-sexp :after #'clojure--replace-let-bindings-and-indent)))
526526

527+
(defun clojure-current-defun-name ()
528+
"Return the name of the defun at point, or nil.
529+
530+
`add-log-current-defun-function' is set to this, for use by `which-func'."
531+
(save-excursion
532+
(let ((location (point)))
533+
;; If we are now precisely at the beginning of a defun, make sure
534+
;; beginning-of-defun finds that one rather than the previous one.
535+
(or (eobp) (forward-char 1))
536+
(beginning-of-defun)
537+
;; Make sure we are really inside the defun found, not after it.
538+
(when (and (looking-at "\\s(")
539+
(progn (end-of-defun)
540+
(< location (point)))
541+
(progn (forward-sexp -1)
542+
(>= location (point))))
543+
(if (looking-at "\\s(")
544+
(forward-char 1))
545+
;; Skip the defining construct name, e.g. "defn" or "def".
546+
(forward-sexp 1)
547+
;; The second element is usually a symbol being defined. If it
548+
;; is not, use the first symbol in it.
549+
(skip-chars-forward " \t\n'(")
550+
;; Skip metadata
551+
(while (looking-at "\\^")
552+
(forward-sexp 1)
553+
(skip-chars-forward " \t\n'("))
554+
(buffer-substring-no-properties (point)
555+
(progn (forward-sexp 1)
556+
(point)))))))
557+
527558
(defun clojure-mode-variables ()
528559
"Set up initial buffer-local variables for Clojure mode."
529560
(add-to-list 'imenu-generic-expression '(nil clojure-match-next-def 0))
@@ -552,6 +583,7 @@ replacement for `cljr-expand-let`."
552583
(setq-local parse-sexp-ignore-comments t)
553584
(setq-local prettify-symbols-alist clojure--prettify-symbols-alist)
554585
(setq-local open-paren-in-column-0-is-defun-start nil)
586+
(setq-local add-log-current-defun-function #'clojure-current-defun-name)
555587
(setq-local beginning-of-defun-function #'clojure-beginning-of-defun-function))
556588

557589
(defsubst clojure-in-docstring-p ()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.