From 3a461aec5aa5b78a1ad8919eab11abfb0d5d65b3 Mon Sep 17 00:00:00 2001 From: Torsten Hilbrich Date: Wed, 8 May 2013 21:03:38 +0200 Subject: word-definition: Fix creation of links to word definition match-beginning was called with 1 instead of 2 when calculating match-start. This is clearly wrong. Also small changes in the code, first calculate, then replace, this fixed a little problem with the link placement. Also fixing the documentation for the dictionary-color-support variable. --- dictionary.el | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/dictionary.el b/dictionary.el index 9548127..a5885c3 100755 --- a/dictionary.el +++ b/dictionary.el @@ -295,7 +295,7 @@ by the choice value: (condition-case nil (x-display-color-p) (error nil)) - "Stores the point position while buffer display.") + "Determines if the Emacs has support to display color") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Basic function providing startup actions @@ -764,18 +764,17 @@ This function knows about the special meaning of quotes (\")" (goto-char start) (while (< (point) (point-max)) (if (search-forward-regexp regexp nil t) - (let ((match-start (match-beginning 1)) + (let ((match-start (match-beginning 2)) (match-end (match-end 2))) (if dictionary-color-support - (progn - (replace-match "\\2") - ;; Compensate for the replacement - (let ((brace-match-length (- (match-end 1) - (match-beginning 1)))) - (setq match-start (- (match-beginning 2) - brace-match-length)) - (setq match-end (- (match-end 2) - brace-match-length))))) + ;; Compensate for the replacement + (let ((brace-match-length (- (match-end 1) + (match-beginning 1)))) + (setq match-start (- (match-beginning 2) + brace-match-length)) + (setq match-end (- (match-end 2) + brace-match-length)) + (replace-match "\\2"))) (dictionary-mark-reference match-start match-end 'dictionary-new-search word dictionary)) -- cgit v1.2.3