Mercurial > emacs
changeset 98603:2f77b9a9fd06
(calc-embedded-make-info): Use `calc-embedded-word-regexp' to find word.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Fri, 10 Oct 2008 14:31:19 +0000 |
parents | 8bc022b29e81 |
children | 06ca8e88517c |
files | lisp/calc/calc-embed.el |
diffstat | 1 files changed, 20 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/calc/calc-embed.el Fri Oct 10 14:30:22 2008 +0000 +++ b/lisp/calc/calc-embed.el Fri Oct 10 14:31:19 2008 +0000 @@ -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 @@ 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 @@ (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 @@ (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)))