From 142916ca3639995e7a06277ded627b3b01ee4931 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 2 Dec 2014 00:43:37 +0000 Subject: Add an answer button --- sx-button.el | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sx-button.el') diff --git a/sx-button.el b/sx-button.el index c1abf90..cd01598 100644 --- a/sx-button.el +++ b/sx-button.el @@ -121,6 +121,14 @@ code-block." 'action #'sx-comment :supertype 'sx-button) +(define-button-type 'sx-button-answer + 'help-echo (concat "mouse-1, RET" + (propertize ": write an answer" + 'face 'minibuffer-prompt)) + 'face 'custom-button + 'action #'sx-answer + :supertype 'sx-button) + (provide 'sx-button) ;;; sx-button.el ends here -- cgit v1.2.3 From 34cdd0f1f21c99914d58b0acea26c848ff8aa67c Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 2 Dec 2014 00:45:55 +0000 Subject: Prettier comment button --- sx-button.el | 1 + 1 file changed, 1 insertion(+) (limited to 'sx-button.el') diff --git a/sx-button.el b/sx-button.el index cd01598..8f0b6b9 100644 --- a/sx-button.el +++ b/sx-button.el @@ -118,6 +118,7 @@ code-block." 'help-echo (concat "mouse-1, RET" (propertize ": write a comment" 'face 'minibuffer-prompt)) + 'face 'custom-button 'action #'sx-comment :supertype 'sx-button) -- cgit v1.2.3 From 6f2f7f6cc68a673c75ae0ec9059c299967b43975 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 3 Dec 2014 14:12:03 +0000 Subject: Header commentary on sx-button Affects #123 --- sx-button.el | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'sx-button.el') diff --git a/sx-button.el b/sx-button.el index 8f0b6b9..f1d7e4d 100644 --- a/sx-button.el +++ b/sx-button.el @@ -1,4 +1,4 @@ -;;; sx-button.el --- Defining buttons used throughout SX. +;;; sx-button.el --- Defining buttons used throughout SX. -*- lexical-binding: t; -*- ;; Copyright (C) 2014 Artur Malabarba @@ -18,6 +18,25 @@ ;; along with this program. If not, see . ;;; Commentary: +;; +;; This file defines all buttons used by SX. For information on +;; 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 +;; are, you can always cycle through all buttons by hitting `TAB', +;; that should help identify what's a button in each buffer. +;; +;; To define a new type of button follow the examples below using +;; `define-button-type' with :supertype `sx-button'. Required +;; properties are `action' and `help-echo'. You'll probably want to +;; give it a `face' as well, unless you want it to look like a link. +;; +;; 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 +;; creation. Existing text can be transformed into a button with +;; `make-text-button' instead. ;;; Code: @@ -132,7 +151,3 @@ code-block." (provide 'sx-button) ;;; sx-button.el ends here - -;; Local Variables: -;; lexical-binding: t -;; End: -- cgit v1.2.3 From 4b3fa6cf6171950d4ed48de736395f8e74c6709f Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 3 Dec 2014 15:39:35 +0000 Subject: Don't rely on cus-edit for the faces --- sx-button.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sx-button.el') diff --git a/sx-button.el b/sx-button.el index f1d7e4d..dbadc2e 100644 --- a/sx-button.el +++ b/sx-button.el @@ -45,6 +45,14 @@ (require 'sx) (require 'sx-question) + +;;; Face +(defface sx-custom-button + '((((type x w32 ns) (class color)) ; Like default mode line + :box (:line-width 2 :style released-button) + :background "lightgrey" :foreground "black")) + "Face used on buttons such as \"Write an Answer\".") + ;;; Command definitions ;; This extends `button-map', which already defines RET and mouse-1. @@ -137,7 +145,7 @@ code-block." 'help-echo (concat "mouse-1, RET" (propertize ": write a comment" 'face 'minibuffer-prompt)) - 'face 'custom-button + 'face 'sx-custom-button 'action #'sx-comment :supertype 'sx-button) @@ -145,7 +153,7 @@ code-block." 'help-echo (concat "mouse-1, RET" (propertize ": write an answer" 'face 'minibuffer-prompt)) - 'face 'custom-button + 'face 'sx-custom-button 'action #'sx-answer :supertype 'sx-button) -- cgit v1.2.3