From fb2e993b0e2ab35ef9a2201ee4b731c3d17c3728 Mon Sep 17 00:00:00 2001 From: Jay Belanger Date: Fri, 10 Oct 2008 14:31:19 +0000 Subject: [PATCH] (calc-embedded-make-info): Use `calc-embedded-word-regexp' to find word. --- lisp/calc/calc-embed.el | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lisp/calc/calc-embed.el b/lisp/calc/calc-embed.el index c84559dd52a..f6278719c05 100644 --- a/lisp/calc/calc-embed.el +++ b/lisp/calc/calc-embed.el @@ -30,6 +30,10 @@ (require 'calc-ext) (require 'calc-macs) +;; Declare functions which are defined elsewhere. +(declare-function thing-at-point-looking-at "thingatpt" (regexp)) + + (defun calc-show-plain (n) (interactive "P") (calc-wrapper @@ -51,14 +55,13 @@ (defvar calc-embedded-announce-formula) (defvar calc-embedded-open-formula) (defvar calc-embedded-close-formula) -(defvar calc-embedded-open-word) -(defvar calc-embedded-close-word) (defvar calc-embedded-open-plain) (defvar calc-embedded-close-plain) (defvar calc-embedded-open-new-formula) (defvar calc-embedded-close-new-formula) (defvar calc-embedded-open-mode) (defvar calc-embedded-close-mode) +(defvar calc-embedded-word-regexp) (defconst calc-embedded-mode-vars '(("precision" . calc-internal-prec) ("word-size" . calc-word-size) @@ -829,7 +832,7 @@ The command \\[yank] can retrieve it from there." calc-embedded-firsttime-buf t) (let ((newann (assoc major-mode calc-embedded-announce-formula-alist)) (newform (assoc major-mode calc-embedded-open-close-formula-alist)) - (newword (assoc major-mode calc-embedded-open-close-word-alist)) + (newword (assoc major-mode calc-embedded-word-regexp-alist)) (newplain (assoc major-mode calc-embedded-open-close-plain-alist)) (newnewform (assoc major-mode calc-embedded-open-close-new-formula-alist)) @@ -843,10 +846,8 @@ The command \\[yank] can retrieve it from there." (setq calc-embedded-open-formula (nth 0 (cdr newform))) (setq calc-embedded-close-formula (nth 1 (cdr newform)))) (when newword - (make-local-variable 'calc-embedded-open-word) - (make-local-variable 'calc-embedded-close-word) - (setq calc-embedded-open-word (nth 0 (cdr newword))) - (setq calc-embedded-close-word (nth 1 (cdr newword)))) + (make-local-variable 'calc-embedded-word-regexp) + (setq calc-embedded-word-regexp (nth 1 newword))) (when newplain (make-local-variable 'calc-embedded-open-plain) (make-local-variable 'calc-embedded-close-plain) @@ -902,9 +903,18 @@ The command \\[yank] can retrieve it from there." (setq calc-embed-top (aref info 2) fixed calc-embed-top) (if (consp calc-embed-top) - (let ((calc-embedded-open-formula calc-embedded-open-word) - (calc-embedded-close-formula calc-embedded-close-word)) - (calc-embedded-find-bounds 'plain)) + (progn + (require 'thingatpt) + (if (thing-at-point-looking-at calc-embedded-word-regexp) + (progn + (setq calc-embed-top (copy-marker (match-beginning 0))) + (setq calc-embed-bot (copy-marker (match-end 0))) + (setq calc-embed-outer-top calc-embed-top) + (setq calc-embed-outer-bot calc-embed-bot)) + (setq calc-embed-top (point-marker)) + (setq calc-embed-bot (point-marker)) + (setq calc-embed-outer-top calc-embed-top) + (setq calc-embed-outer-bot calc-embed-bot))) (or calc-embed-top (calc-embedded-find-bounds 'plain))) (aset info 2 (copy-marker (min calc-embed-top calc-embed-bot))) -- 2.39.5