diff options
| -rw-r--r-- | lisp/subr.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 4232fd77e09..4029b7fa334 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1294,6 +1294,16 @@ Only affects hooks run in the current buffer." | |||
| 1294 | (let ((delay-mode-hooks t)) | 1294 | (let ((delay-mode-hooks t)) |
| 1295 | ,@body))) | 1295 | ,@body))) |
| 1296 | 1296 | ||
| 1297 | ;; PUBLIC: find if the current mode derives from another. | ||
| 1298 | |||
| 1299 | (defun derived-mode-p (&rest modes) | ||
| 1300 | "Non-nil if the current major mode is derived from one of MODES. | ||
| 1301 | Uses the `derived-mode-parent' property of the symbol to trace backwards." | ||
| 1302 | (let ((parent major-mode)) | ||
| 1303 | (while (and (not (memq parent modes)) | ||
| 1304 | (setq parent (get parent 'derived-mode-parent)))) | ||
| 1305 | parent)) | ||
| 1306 | |||
| 1297 | (defmacro with-syntax-table (table &rest body) | 1307 | (defmacro with-syntax-table (table &rest body) |
| 1298 | "Evaluate BODY with syntax table of current buffer set to a copy of TABLE. | 1308 | "Evaluate BODY with syntax table of current buffer set to a copy of TABLE. |
| 1299 | The syntax table of the current buffer is saved, BODY is evaluated, and the | 1309 | The syntax table of the current buffer is saved, BODY is evaluated, and the |