Skip to content

Instantly share code, notes, and snippets.

@anticrisis
Last active February 6, 2021 21:55
Show Gist options
  • Save anticrisis/08ca7e7e5a66a4c9d4b445cde7ed75b4 to your computer and use it in GitHub Desktop.
Save anticrisis/08ca7e7e5a66a4c9d4b445cde7ed75b4 to your computer and use it in GitHub Desktop.
Patch to emacs to fix tcl-mode with nested procs/methods
diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el
index 0a0118a5eb..82e1343e05 100644
--- a/lisp/progmodes/tcl.el
+++ b/lisp/progmodes/tcl.el
@@ -651,7 +651,6 @@ tcl-mode
(setq-local add-log-current-defun-function
#'tcl-add-log-defun)
- (setq-local beginning-of-defun-function #'tcl-beginning-of-defun-function)
(setq-local end-of-defun-function #'tcl-end-of-defun-function))
@@ -849,14 +848,12 @@ tcl-calculate-indent
state
containing-sexp
found-next-line)
- (cond
- (parse-start
+
+ (if parse-start
(goto-char parse-start))
- ((not (beginning-of-defun))
- ;; If we're not in a function, don't use
- ;; `tcl-beginning-of-defun-function'.
- (let ((beginning-of-defun-function nil))
- (beginning-of-defun))))
+
+ (beginning-of-defun)
+
(while (< (point) indent-point)
(setq parse-start (point))
(setq state (parse-partial-sexp (point) indent-point 0))
@@ -1035,22 +1032,6 @@ tcl-indent-exp
;; Interfaces to other packages.
;;
-(defun tcl-beginning-of-defun-function (&optional arg)
- "`beginning-of-defun-function' for Tcl mode."
- (when (or (not arg) (= arg 0))
- (setq arg 1))
- (let* ((search-fn (if (> arg 0)
- ;; Positive arg means to search backward.
- #'re-search-backward
- #'re-search-forward))
- (arg (abs arg))
- (result t))
- (while (and (> arg 0) result)
- (unless (funcall search-fn tcl-proc-regexp nil t)
- (setq result nil))
- (setq arg (1- arg)))
- result))
-
(defun tcl-end-of-defun-function ()
"`end-of-defun-function' for Tcl mode."
;; Because we let users redefine tcl-proc-list, we don't really know
@anticrisis
Copy link
Author

anticrisis commented Feb 6, 2021

This patch applies to emacs 28.0.50. It simply removes the customized tcl-beginning-of-defun-function and falls back on the standard emacs version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment