From 706a445f831a7864256bbc375ee0d60be5ce2f6e Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 6 Jan 2015 20:52:42 -0200 Subject: Use defconst for button help-echo's --- sx-button.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'sx-button.el') diff --git a/sx-button.el b/sx-button.el index 4c0666b..2dd20d0 100644 --- a/sx-button.el +++ b/sx-button.el @@ -104,23 +104,29 @@ usually part of a code-block." ;;; Help-echo definitions -(defvar sx-button--help-echo +(defconst sx-button--help-echo (concat "mouse-1, RET" (propertize ": %s -- " 'face 'minibuffer-prompt) "w" (propertize ": copy %s" 'face 'minibuffer-prompt)) "Base help-echo on which others can be written.") -(defvar sx-button--question-title-help-echo +(defconst sx-button--user-help-echo (format sx-button--help-echo - (propertize "hide content" 'face 'minibuffer-prompt) - (propertize "link" 'face 'minibuffer-prompt)) + "visit user page" + "link") + "Help echoed in the minibuffer when point is on a user.") + +(defconst sx-button--question-title-help-echo + (format sx-button--help-echo + "hide content" + "link") "Help echoed in the minibuffer when point is on a section.") -(defvar sx-button--link-help-echo +(defconst sx-button--link-help-echo (format sx-button--help-echo - (propertize "visit %s" 'face 'minibuffer-prompt) - (propertize "URL" 'face 'minibuffer-prompt)) + "visit %s" + "URL") "Help echoed in the minibuffer when point is on a section.") -- cgit v1.2.3 From 17d41cf40e36d0f0a7c48c60a7bf8880b659c438 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 6 Jan 2015 20:53:41 -0200 Subject: Define user button --- sx-button.el | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sx-button.el') diff --git a/sx-button.el b/sx-button.el index 2dd20d0..8309543 100644 --- a/sx-button.el +++ b/sx-button.el @@ -151,6 +151,13 @@ usually part of a code-block." 'action #'sx-button-follow-link :supertype 'sx-button) +(define-button-type 'sx-button-user + 'action #'sx-button-follow-link + 'help-echo sx-button--user-help-echo + ;; We use different faces on diferent parts of the user button. + 'face nil + :supertype 'sx-button) + (define-button-type 'sx-button-comment 'help-echo (concat "mouse-1, RET" (propertize ": write a comment" -- cgit v1.2.3 From 7ea2edd6e54cf4dd257a32555fec4489d510eaf6 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 7 Jan 2015 17:59:51 -0200 Subject: Only display_name and @name are turned into buttons --- sx-button.el | 2 +- sx-user.el | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'sx-button.el') diff --git a/sx-button.el b/sx-button.el index 8309543..a459eb4 100644 --- a/sx-button.el +++ b/sx-button.el @@ -155,7 +155,7 @@ usually part of a code-block." 'action #'sx-button-follow-link 'help-echo sx-button--user-help-echo ;; We use different faces on diferent parts of the user button. - 'face nil + 'face 'sx-user-name :supertype 'sx-button) (define-button-type 'sx-button-comment diff --git a/sx-user.el b/sx-user.el index 44456a0..c0f3a78 100644 --- a/sx-user.el +++ b/sx-user.el @@ -95,6 +95,8 @@ errors if you remove them." (website_url string))) :group 'sx-user) + +;;; Text properties (defface sx-user-name '((t :inherit font-lock-builtin-face)) "Face used for user names." @@ -111,7 +113,9 @@ errors if you remove them." :group 'sx-user) (defvar sx-user--format-property-alist - '((?d face sx-user-name) + `((?d button ,(list t) category ,(button-category-symbol 'sx-button-user)) + (?n button ,(list t) category ,(button-category-symbol 'sx-button-user)) + (?@ button ,(list t) category ,(button-category-symbol 'sx-button-user)) (?r face sx-user-reputation) (?a face sx-user-accept-rate)) "Alist relating % constructs with text properties. @@ -130,8 +134,10 @@ replaced by text that describes the specified USER: %r is the reputation. %a is the accept rate. -The returned string is additionally propertized as a button with -the `sx-button-user' category." +The string replaced in each of these construct is also given the +text-properties specified in `sx-user--format-property-alist'. +Specially, %d and %@ are turned into buttons with the +`sx-button-user' category." (sx-assoc-let (append user sx-question-mode-fallback-user) (let* ((text (sx-format-replacements format-string @@ -144,12 +150,11 @@ the `sx-button-user' category." (sx-user--@name .display_name))) ) sx-user--format-property-alist))) - (if (> 0 (string-width .link)) - (insert-text-button text - ;; For visiting and stuff. - 'sx-button-url .link - 'sx-button-copy .link - :type 'sx-button-user) + (if (< 0 (string-width .link)) + (propertize text + ;; For visiting and stuff. + 'sx-button-url .link + 'sx-button-copy .link) text)))) -- cgit v1.2.3 From c14bdb9a4ed4707937255ba27c68aa2dfd02de30 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Wed, 7 Jan 2015 18:18:00 -0500 Subject: Spellcheck --- sx-babel.el | 2 +- sx-button.el | 6 +++--- sx-question.el | 2 +- sx-search.el | 2 +- sx-switchto.el | 2 +- sx.org | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) (limited to 'sx-button.el') diff --git a/sx-babel.el b/sx-babel.el index 4386172..31c0924 100644 --- a/sx-babel.el +++ b/sx-babel.el @@ -22,7 +22,7 @@ ;; This file contains functions and a variable for font-locking the ;; content of markdown pre blocks according to their language. The ;; main configuration point, for both the user and the developer is -;; the varuable `sx-babel-major-mode-alist', which see. +;; the variable `sx-babel-major-mode-alist', which see. ;;; Code: diff --git a/sx-button.el b/sx-button.el index a459eb4..5a2f052 100644 --- a/sx-button.el +++ b/sx-button.el @@ -23,7 +23,7 @@ ;; buttons, see: ;; http://www.gnu.org/software/emacs/manual/html_node/elisp/Buttons.html ;; -;; Most interactible parts of the SX buffers are buttons. Wherever you +;; Most interactive parts of the SX buffers are buttons. Wherever you ;; are, you can always cycle through all buttons by hitting `TAB', ;; that should help identify what's a button in each buffer. ;; @@ -34,7 +34,7 @@ ;; ;; Buttons can then be inserted in their respective files using ;; `insert-text-button'. Give it the string, the `:type' you defined, -;; and any aditional properties that can only be determined at +;; and any additional properties that can only be determined at ;; creation. Existing text can be transformed into a button with ;; `make-text-button' instead. @@ -154,7 +154,7 @@ usually part of a code-block." (define-button-type 'sx-button-user 'action #'sx-button-follow-link 'help-echo sx-button--user-help-echo - ;; We use different faces on diferent parts of the user button. + ;; We use different faces on different parts of the user button. 'face 'sx-user-name :supertype 'sx-button) diff --git a/sx-question.el b/sx-question.el index b9fc78a..1adbc24 100644 --- a/sx-question.el +++ b/sx-question.el @@ -19,7 +19,7 @@ ;;; Commentary: -;; Thie file provides an API for retrieving questions and defines +;; This file provides an API for retrieving questions and defines ;; additional logic for marking questions as read or hidden. diff --git a/sx-search.el b/sx-search.el index fa08e56..aefd12e 100644 --- a/sx-search.el +++ b/sx-search.el @@ -19,7 +19,7 @@ ;;; Commentary: -;; Implements sarch functionality. The basic function is +;; Implements search functionality. The basic function is ;; `sx-search-get-questions', which returns an array of questions ;; according to a search term. ;; diff --git a/sx-switchto.el b/sx-switchto.el index ed83360..6a195e0 100644 --- a/sx-switchto.el +++ b/sx-switchto.el @@ -33,7 +33,7 @@ (mapc (lambda (x) (define-key sx-switchto-map (car x) (cadr x))) '( - ;; These immitate the site's G hotkey. + ;; These imitate the site's G hotkey. ("a" sx-ask) ("h" sx-tab-frontpage) ("m" sx-tab-meta-or-main) diff --git a/sx.org b/sx.org index 7ccb51b..94780ec 100644 --- a/sx.org +++ b/sx.org @@ -97,7 +97,7 @@ Scrolling past the bottom of the list fetches more questions. - ~sx-init-hook~ :: Run when ~sx-initialize~ is called. - ~sx-compose-before-send-hook~ :: Run before POSTing to the API from a buffer in ~sx-compose-mode~. If any of the functions in this - hook, return nil, the transaction is cancelled. + hook, return nil, the transaction is canceled. - ~sx-compose-after-send-functions~ :: Run after POSTing to the API from a buffer in ~sx-compose-mode~, if the transaction was successful. -- cgit v1.2.3