unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Use lexical-binding in button.el
@ 2019-10-01 13:00 Basil L. Contovounesios
  2019-10-02 10:49 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Basil L. Contovounesios @ 2019-10-01 13:00 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 163 bytes --]

The following patch enables lexical-binding and touches up some
documentation in button.el, WDYT?  (More unit tests for button.el are on
their way in bug#37515.)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-lexical-binding-in-button.el.patch --]
[-- Type: text/x-diff, Size: 8825 bytes --]

From 3b091edd84adf63318cfa91805f8c231ba2de9d2 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Tue, 1 Oct 2019 02:22:31 +0100
Subject: [PATCH] Use lexical-binding in button.el

* lisp/button.el: Use lexical-binding.  Expand Keywords header.
Quote function symbols as such.  Use ;;;-comments where appropriate.
(button): Remove outdated commentary of defface.
(define-button-type, make-button, insert-button, make-text-button)
(insert-text-button): Clarify in docstring that PROPERTIES argument
is a plist.
(button-type-subtype-p, button-has-type-p): Do not overspecify
return value in docstring.
(button-put): Fix typo in commentary.
---
 lisp/button.el | 62 +++++++++++++++++++++++---------------------------
 1 file changed, 29 insertions(+), 33 deletions(-)

diff --git a/lisp/button.el b/lisp/button.el
index 9112e518b0..32efc2f95b 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -1,9 +1,9 @@
-;;; button.el --- clickable buttons
+;;; button.el --- clickable buttons -*- lexical-binding: t -*-
 ;;
 ;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <miles@gnu.org>
-;; Keywords: extensions
+;; Keywords: extensions, hypermedia
 ;; Package: emacs
 ;;
 ;; This file is part of GNU Emacs.
@@ -49,11 +49,8 @@
 ;;; Code:
 
 \f
-;; Globals
+;;; Globals
 
-;; Use color for the MS-DOS port because it doesn't support underline.
-;; FIXME if MS-DOS correctly answers the (supports) question, it need
-;; no longer be a special case.
 (defface button '((t :inherit link))
   "Default face used for buttons."
   :group 'basic-faces)
@@ -81,25 +78,25 @@ button-buffer-map
   "Keymap useful for buffers containing buttons.
 Mode-specific keymaps may want to use this as their parent keymap.")
 
-;; Default properties for buttons
+;; Default properties for buttons.
 (put 'default-button 'face 'button)
 (put 'default-button 'mouse-face 'highlight)
 (put 'default-button 'keymap button-map)
 (put 'default-button 'type 'button)
-;; action may be either a function to call, or a marker to go to
-(put 'default-button 'action 'ignore)
+;; `action' may be either a function to call, or a marker to go to.
+(put 'default-button 'action #'ignore)
 (put 'default-button 'help-echo (purecopy "mouse-2, RET: Push this button"))
 ;; Make overlay buttons go away if their underlying text is deleted.
 (put 'default-button 'evaporate t)
-;; Prevent insertions adjacent to the text-property buttons from
-;; inheriting its properties.
+;; Prevent insertions adjacent to text-property buttons from
+;; inheriting their properties.
 (put 'default-button 'rear-nonsticky t)
 
-;; A `category-symbol' property for the default button type
+;; A `category-symbol' property for the default button type.
 (put 'button 'button-category-symbol 'default-button)
 
 \f
-;; Button types (which can be used to hold default properties for buttons)
+;;; Button types (which can be used to hold default properties for buttons)
 
 ;; Because button-type properties are inherited by buttons using the
 ;; special `category' property (implemented by both overlays and
@@ -118,7 +115,7 @@ button-category-symbol
 
 (defun define-button-type (name &rest properties)
   "Define a `button type' called NAME (a symbol).
-The remaining arguments form a sequence of PROPERTY VALUE pairs,
+The remaining arguments form a plist of PROPERTY VALUE pairs,
 specifying properties to use as defaults for buttons with this type
 \(a button's type may be set by giving it a `type' property when
 creating the button, using the :type keyword argument).
@@ -148,7 +145,7 @@ define-button-type
 	(when (eq prop :supertype)
 	  (setq prop 'supertype))
 	(put catsym prop (pop properties))))
-    ;; Make sure there's a `supertype' property
+    ;; Make sure there's a `supertype' property.
     (unless (get catsym 'supertype)
       (put catsym 'supertype 'button))
     name))
@@ -162,14 +159,14 @@ button-type-get
   (get (button-category-symbol type) prop))
 
 (defun button-type-subtype-p (type supertype)
-  "Return t if button-type TYPE is a subtype of SUPERTYPE."
+  "Return non-nil if button-type TYPE is a subtype of SUPERTYPE."
   (or (eq type supertype)
       (and type
 	   (button-type-subtype-p (button-type-get type 'supertype)
 				  supertype))))
 
 \f
-;; Button properties and other attributes
+;;; Button properties and other attributes
 
 (defun button-start (button)
   "Return the position at which BUTTON starts."
@@ -203,9 +200,9 @@ button-put
   "Set BUTTON's PROP property to VAL."
   ;; Treat some properties specially.
   (cond ((memq prop '(type :type))
-	 ;; We translate a `type' property a `category' property, since
-	 ;; that's what's actually used by overlays/text-properties for
-	 ;; inheriting properties.
+         ;; We translate a `type' property to a `category' property,
+         ;; since that's what's actually used by overlay and
+         ;; text-property buttons for inheriting properties.
 	 (setq prop 'category)
 	 (setq val (button-category-symbol val)))
 	((eq prop 'category)
@@ -261,7 +258,7 @@ button-type
   (button-get button 'type))
 
 (defun button-has-type-p (button type)
-  "Return t if BUTTON has button-type TYPE, or one of TYPE's subtypes."
+  "Return non-nil if BUTTON has button-type TYPE, or one of its subtypes."
   (button-type-subtype-p (button-get button 'type) type))
 
 (defun button--area-button-p (b)
@@ -272,11 +269,11 @@ button--area-button-p
 (defalias 'button--area-button-string #'car
   "Return area button BUTTON's button-string.")
 \f
-;; Creating overlay buttons
+;;; Creating overlay buttons
 
 (defun make-button (beg end &rest properties)
   "Make a button from BEG to END in the current buffer.
-The remaining arguments form a sequence of PROPERTY VALUE pairs,
+The remaining arguments form a plist of PROPERTY VALUE pairs,
 specifying properties to add to the button.
 In addition, the keyword argument :type may be used to specify a
 button-type from which to inherit other properties; see
@@ -292,12 +289,12 @@ make-button
     ;; If the user didn't specify a type, use the default.
     (unless (overlay-get overlay 'category)
       (overlay-put overlay 'category 'default-button))
-    ;; OVERLAY is the button, so return it
+    ;; OVERLAY is the button, so return it.
     overlay))
 
 (defun insert-button (label &rest properties)
   "Insert a button with the label LABEL.
-The remaining arguments form a sequence of PROPERTY VALUE pairs,
+The remaining arguments form a plist of PROPERTY VALUE pairs,
 specifying properties to add to the button.
 In addition, the keyword argument :type may be used to specify a
 button-type from which to inherit other properties; see
@@ -310,11 +307,11 @@ insert-button
 	 properties))
 
 \f
-;; Creating text-property buttons
+;;; Creating text-property buttons
 
 (defun make-text-button (beg end &rest properties)
   "Make a button from BEG to END in the current buffer.
-The remaining arguments form a sequence of PROPERTY VALUE pairs,
+The remaining arguments form a plist of PROPERTY VALUE pairs,
 specifying properties to add to the button.
 In addition, the keyword argument :type may be used to specify a
 button-type from which to inherit other properties; see
@@ -352,8 +349,8 @@ make-text-button
       ;; text-properties for inheritance.
       (setcar type-entry 'category)
       (setcar (cdr type-entry)
-	      (button-category-symbol (car (cdr type-entry)))))
-    ;; Now add all the text properties at once
+              (button-category-symbol (cadr type-entry))))
+    ;; Now add all the text properties at once.
     (add-text-properties beg end
                          ;; Each button should have a non-eq `button'
                          ;; property so that next-single-property-change can
@@ -365,7 +362,7 @@ make-text-button
 
 (defun insert-text-button (label &rest properties)
   "Insert a button with the label LABEL.
-The remaining arguments form a sequence of PROPERTY VALUE pairs,
+The remaining arguments form a plist of PROPERTY VALUE pairs,
 specifying properties to add to the button.
 In addition, the keyword argument :type may be used to specify a
 button-type from which to inherit other properties; see
@@ -383,7 +380,7 @@ insert-text-button
 	 properties))
 
 \f
-;; Finding buttons in a buffer
+;;; Finding buttons in a buffer
 
 (defun button-at (pos)
   "Return the button at position POS in the current buffer, or nil.
@@ -436,7 +433,7 @@ previous-button
 	       (button-at (1- pos)))))))
 
 \f
-;; User commands
+;;; User commands
 
 (defun push-button (&optional pos use-mouse-action)
   "Perform the action specified by a button at location POS.
@@ -535,7 +532,6 @@ backward-button
   (interactive "p\nd\nd")
   (forward-button (- n) wrap display-message no-error))
 
-
 (provide 'button)
 
 ;;; button.el ends here
-- 
2.23.0


[-- Attachment #3: Type: text/plain, Size: 20 bytes --]


Thanks,

-- 
Basil

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Use lexical-binding in button.el
  2019-10-01 13:00 [PATCH] Use lexical-binding in button.el Basil L. Contovounesios
@ 2019-10-02 10:49 ` Lars Ingebrigtsen
  2019-10-03 23:00   ` Basil L. Contovounesios
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-02 10:49 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: emacs-devel

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> The following patch enables lexical-binding and touches up some
> documentation in button.el, WDYT?  (More unit tests for button.el are on
> their way in bug#37515.)

Looks good to me.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Use lexical-binding in button.el
  2019-10-02 10:49 ` Lars Ingebrigtsen
@ 2019-10-03 23:00   ` Basil L. Contovounesios
  0 siblings, 0 replies; 3+ messages in thread
From: Basil L. Contovounesios @ 2019-10-03 23:00 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> "Basil L. Contovounesios" <contovob@tcd.ie> writes:
>
>> The following patch enables lexical-binding and touches up some
>> documentation in button.el, WDYT?  (More unit tests for button.el are on
>> their way in bug#37515.)
>
> Looks good to me.

Thanks, pushed to master:

Use lexical-binding in button.el
660d509acd 2019-10-03 23:04:56 +0100
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=660d509acd9da23d9795b5aaa12a5453e6c61bbd

-- 
Basil



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-03 23:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01 13:00 [PATCH] Use lexical-binding in button.el Basil L. Contovounesios
2019-10-02 10:49 ` Lars Ingebrigtsen
2019-10-03 23:00   ` Basil L. Contovounesios

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).