[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 8ec8a5b 05/14: Use cl-lib, nadvice, and lexical-binding

From: Phil
Subject: [elpa] master 8ec8a5b 05/14: Use cl-lib, nadvice, and lexical-binding
Date: Sat, 11 Jul 2020 00:57:55 -0400 (EDT)

branch: master
commit 8ec8a5be830995d02d41186ffb9a5198a60fea2e
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Phil Sainty <psainty@orcon.net.nz>

    Use cl-lib, nadvice, and lexical-binding
    (delight--inhibit): Rename from inhibit-mode-name-delight to clean up
    namespace use.
    (delight--format-mode-line): New function, extracted from the old defadvice.
    (format-mode-line): Replace defadvice with advice-add.
    Co-authored-by: Phil Sainty <psainty@orcon.net.nz>
    Based on GNU ELPA commit 463f1e3f14ed99dd35d77be8fa55055e5e7c71cb.
 delight.el | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/delight.el b/delight.el
index e8265b6..9c6cba1 100644
--- a/delight.el
+++ b/delight.el
@@ -1,13 +1,14 @@
-;;; delight.el --- A dimmer switch for your lighter text.
+;;; delight.el --- A dimmer switch for your lighter text  -*- 
lexical-binding:t -*-
-;; Copyright (C) 2013, 2014, 2016 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 ;; Author: Phil Sainty <psainty@orcon.net.nz>
 ;; Maintainer: Phil Sainty <psainty@orcon.net.nz>
 ;; URL: https://savannah.nongnu.org/projects/delight
+;; Package-Requires: ((cl-lib "0.5") (nadvice "0.3"))
 ;; Keywords: convenience
 ;; Created: 25 Jun 2013
-;; Version: 1.5
+;; Version: 1.6
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -92,6 +93,9 @@
 ;;; Change Log:
+;; 1.6 (2019-07-23)
+;;   - Use cl-lib, nadvice, and lexical-binding.
+;;   - Rename `inhibit-mode-name-delight' to `delight--inhibit'.
 ;; 1.5 (2016-03-01)
 ;;   - Support FILE value t, meaning that the minor MODE in question
 ;;     is guaranteed to already be loaded.
@@ -109,8 +113,8 @@
 ;;; Code:
-  (require 'cl))
+(eval-when-compile (require 'cl-lib))
+(require 'nadvice)
 (defvar delighted-modes ()
   "List of specs for modifying the display of mode names in the mode line.
@@ -142,10 +146,10 @@ for this purpose). These FILE options are relevant to 
minor modes only.
 For major modes you should specify the keyword :major as the value of FILE,
 to prevent the mode being treated as a minor mode."
-  (add-hook 'after-change-major-mode-hook 'delight-major-mode)
+  (add-hook 'after-change-major-mode-hook #'delight-major-mode)
   (let ((glum (if (consp spec) spec (list (list spec value file)))))
     (while glum
-      (destructuring-bind (mode &optional value file) (pop glum)
+      (cl-destructuring-bind (mode &optional value file) (pop glum)
         (assq-delete-all mode delighted-modes)
         (add-to-list 'delighted-modes (list mode value file))
         (unless (eq file :major)
@@ -201,19 +205,23 @@ When `mode-name' is displayed in other contexts (such as 
in the
 `describe-mode' help buffer), its original value will be used."
   (let ((major-delight (assq major-mode delighted-modes)))
     (when major-delight
-      (setq mode-name `(inhibit-mode-name-delight
+      (setq mode-name `(delight--inhibit
                         ,mode-name ;; glum
                         ,(cadr major-delight)))))) ;; delighted
-(defvar inhibit-mode-name-delight)
+(define-obsolete-variable-alias 'inhibit-mode-name-delight
+  'delight--inhibit "delight-1.6")
+(defvar delight--inhibit)
-(defadvice format-mode-line (around delighted-modes-are-glum activate)
+(defun delight--format-mode-line (orig-fun &rest args)
   "Delighted modes should exhibit their original `mode-name' when
 `format-mode-line' is called. See `delight-major-mode'."
-  (let ((inhibit-mode-name-delight (if (boundp 'inhibit-mode-name-delight)
-                                       inhibit-mode-name-delight
+  (let ((delight--inhibit (if (boundp 'delight--inhibit)
+                                       delight--inhibit
-    ad-do-it))
+    (apply orig-fun args)))
+(advice-add 'format-mode-line :around #'delight--format-mode-line)
 (provide 'delight)
 ;;; delight.el ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]