diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-12-01 01:13:04 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-12-01 01:13:04 +0000 |
commit | d2ac145a981521e23cd975ff41e84dc90fa161e5 (patch) | |
tree | 6c24c80f6f2eb1d9ae7c6485c7ce5b45d050fd69 /sx-interaction.el | |
parent | bf56eba935f73c1803ea9964671a36bccb4efa21 (diff) |
Make sx--data-here throw error on failure.
Diffstat (limited to 'sx-interaction.el')
-rw-r--r-- | sx-interaction.el | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sx-interaction.el b/sx-interaction.el index 5f3ece6..87f72a5 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'." +(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)) (or (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." |