diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-12-02 15:24:47 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-12-02 15:24:47 +0000 |
commit | 8795a394f90f143239edeabd870bf0767303543d (patch) | |
tree | 1b3026d621d3f9a28642870c437c2ea281447b9e | |
parent | 761fe509343eb595094186c1a5dd5dc87286556f (diff) |
Redo sx--data-here take &optional noerror
-rw-r--r-- | sx-interaction.el | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sx-interaction.el b/sx-interaction.el index b04a49e..b67e0df 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -29,13 +29,20 @@ ;;; Using data in buffer -(defun sx--data-here () - "Get the text property `sx--data-here'." - (or (get-char-property (point) 'sx--data-here) +(defun sx--data-here (&optional noerror) + "Get data for the question or other object under point. +If NOERROR is non-nil, don't throw an error on failure. + +This looks at the text property `sx--data-here'. If it's not set, +it looks at a few other reasonable variables. If those fail too, +it throws an error." + (or (get-text-property (point) 'sx--data-here) (and (derived-mode-p 'sx-question-list-mode) (tabulated-list-get-id)) (and (derived-mode-p 'sx-question-mode) - sx-question-mode--data))) + sx-question-mode--data) + (and (null noerror) + (error "No question data found here")))) (defun sx--maybe-update-display () "Refresh the question list if we're inside it." |