Skip to content

Commit

Permalink
Hot fix: fix bug caused by last commit
Browse files Browse the repository at this point in the history
Last commit will cause some serious issue. While saving buffer, some
text will be replaced randomly. I believe it is due to org's parsing
mechanism which will change match data during parsing. It is fixed now,
by some save-match-data magic.
  • Loading branch information
et2010 committed Feb 15, 2016
1 parent 28c049c commit 0831534
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,16 @@
"Replace regexp with match in buffer."
(if (eq 'org-mode (buffer-local-value 'major-mode (current-buffer)))
(pangu-spacing-search-buffer regexp (point-min) (point-max)
(if (member 'link
(mapcar
(lambda (point)
(save-excursion
(goto-char point)
(org-element-type (org-element-context))))
(list (match-beginning 0) (match-end 0))))
(goto-char (match-end 0))
(replace-match match nil nil)))
(when (not (member 'link
(save-match-data
(save-excursion
(let ((p1 (match-beginning 1))
(p2 (match-beginning 2)))
(mapcar (lambda (pt) (goto-char pt)
(org-element-type
(org-element-context)))
(list p1 p2)))))))
(replace-match match nil nil)))
ad-do-it))))))

(defun han/init-visual-fill-column ()
Expand Down

1 comment on commit 0831534

@et2010
Copy link
Owner Author

@et2010 et2010 commented on 0831534 Feb 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That fix @28c049c26c870e5cb5ea96cba846e58ae4af8759 itself caused some more serious issue! Luckily, after spending couple of hours googling, I finally came up with a good solution. coldnew/pangu-spacing#10

Please sign in to comment.