diff options
| author | Stefan Kangas | 2021-03-21 17:27:44 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2021-03-22 01:06:32 +0100 |
| commit | aa21273788a8727effd05e9ae5fb2b2369fbd559 (patch) | |
| tree | 99ec397873024048d1b1956300bf69a2b663f0d9 | |
| parent | 7c2ebf6e23663fdc7b1880a4d7caeadc8c47c00e (diff) | |
| download | emacs-aa21273788a8727effd05e9ae5fb2b2369fbd559.tar.gz emacs-aa21273788a8727effd05e9ae5fb2b2369fbd559.zip | |
Use lexical-binding in notifications.el
* lisp/notifications.el: Use lexical-binding.
(notifications-notify): Prefer 'push' to 'add-to-list'.
| -rw-r--r-- | lisp/notifications.el | 99 |
1 files changed, 56 insertions, 43 deletions
diff --git a/lisp/notifications.el b/lisp/notifications.el index 2241afa9050..b439d822317 100644 --- a/lisp/notifications.el +++ b/lisp/notifications.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; notifications.el --- Client interface to desktop notifications. | 1 | ;;; notifications.el --- Client interface to desktop notifications. -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2010-2021 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2010-2021 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -229,56 +229,69 @@ of another `notifications-notify' call." | |||
| 229 | id) | 229 | id) |
| 230 | ;; Build hints array | 230 | ;; Build hints array |
| 231 | (when urgency | 231 | (when urgency |
| 232 | (add-to-list 'hints `(:dict-entry | 232 | (push `(:dict-entry |
| 233 | "urgency" | 233 | "urgency" |
| 234 | (:variant :byte ,(pcase urgency | 234 | (:variant :byte ,(pcase urgency |
| 235 | ('low 0) | 235 | ('low 0) |
| 236 | ('critical 2) | 236 | ('critical 2) |
| 237 | (_ 1)))) t)) | 237 | (_ 1)))) |
| 238 | hints)) | ||
| 238 | (when category | 239 | (when category |
| 239 | (add-to-list 'hints `(:dict-entry | 240 | (push `(:dict-entry |
| 240 | "category" | 241 | "category" |
| 241 | (:variant :string ,category)) t)) | 242 | (:variant :string ,category)) |
| 243 | hints)) | ||
| 242 | (when desktop-entry | 244 | (when desktop-entry |
| 243 | (add-to-list 'hints `(:dict-entry | 245 | (push `(:dict-entry |
| 244 | "desktop-entry" | 246 | "desktop-entry" |
| 245 | (:variant :string ,desktop-entry)) t)) | 247 | (:variant :string ,desktop-entry)) |
| 248 | hints)) | ||
| 246 | (when image-data | 249 | (when image-data |
| 247 | (add-to-list 'hints `(:dict-entry | 250 | (push `(:dict-entry |
| 248 | "image-data" | 251 | "image-data" |
| 249 | (:variant :struct ,image-data)) t)) | 252 | (:variant :struct ,image-data)) |
| 253 | hints)) | ||
| 250 | (when image-path | 254 | (when image-path |
| 251 | (add-to-list 'hints `(:dict-entry | 255 | (push `(:dict-entry |
| 252 | "image-path" | 256 | "image-path" |
| 253 | (:variant :string ,image-path)) t)) | 257 | (:variant :string ,image-path)) |
| 258 | hints)) | ||
| 254 | (when action-items | 259 | (when action-items |
| 255 | (add-to-list 'hints `(:dict-entry | 260 | (push `(:dict-entry |
| 256 | "action-items" | 261 | "action-items" |
| 257 | (:variant :boolean ,action-items)) t)) | 262 | (:variant :boolean ,action-items)) |
| 263 | hints)) | ||
| 258 | (when sound-file | 264 | (when sound-file |
| 259 | (add-to-list 'hints `(:dict-entry | 265 | (push `(:dict-entry |
| 260 | "sound-file" | 266 | "sound-file" |
| 261 | (:variant :string ,sound-file)) t)) | 267 | (:variant :string ,sound-file)) |
| 268 | hints)) | ||
| 262 | (when sound-name | 269 | (when sound-name |
| 263 | (add-to-list 'hints `(:dict-entry | 270 | (push `(:dict-entry |
| 264 | "sound-name" | 271 | "sound-name" |
| 265 | (:variant :string ,sound-name)) t)) | 272 | (:variant :string ,sound-name)) |
| 273 | hints)) | ||
| 266 | (when suppress-sound | 274 | (when suppress-sound |
| 267 | (add-to-list 'hints `(:dict-entry | 275 | (push `(:dict-entry |
| 268 | "suppress-sound" | 276 | "suppress-sound" |
| 269 | (:variant :boolean ,suppress-sound)) t)) | 277 | (:variant :boolean ,suppress-sound)) |
| 278 | hints)) | ||
| 270 | (when resident | 279 | (when resident |
| 271 | (add-to-list 'hints `(:dict-entry | 280 | (push `(:dict-entry |
| 272 | "resident" | 281 | "resident" |
| 273 | (:variant :boolean ,resident)) t)) | 282 | (:variant :boolean ,resident)) |
| 283 | hints)) | ||
| 274 | (when transient | 284 | (when transient |
| 275 | (add-to-list 'hints `(:dict-entry | 285 | (push `(:dict-entry |
| 276 | "transient" | 286 | "transient" |
| 277 | (:variant :boolean ,transient)) t)) | 287 | (:variant :boolean ,transient)) |
| 288 | hints)) | ||
| 278 | (when x | 289 | (when x |
| 279 | (add-to-list 'hints `(:dict-entry "x" (:variant :int32 ,x)) t)) | 290 | (push `(:dict-entry "x" (:variant :int32 ,x)) hints)) |
| 280 | (when y | 291 | (when y |
| 281 | (add-to-list 'hints `(:dict-entry "y" (:variant :int32 ,y)) t)) | 292 | (push `(:dict-entry "y" (:variant :int32 ,y)) hints)) |
| 293 | |||
| 294 | (setq hints (nreverse hints)) | ||
| 282 | 295 | ||
| 283 | ;; Call Notify method. | 296 | ;; Call Notify method. |
| 284 | (setq id | 297 | (setq id |
| @@ -313,8 +326,8 @@ of another `notifications-notify' call." | |||
| 313 | (on-close (plist-get params :on-close)) | 326 | (on-close (plist-get params :on-close)) |
| 314 | (unique-name (dbus-get-name-owner bus notifications-service))) | 327 | (unique-name (dbus-get-name-owner bus notifications-service))) |
| 315 | (when on-action | 328 | (when on-action |
| 316 | (add-to-list 'notifications-on-action-map | 329 | (push (list (list bus unique-name id) on-action) |
| 317 | (list (list bus unique-name id) on-action)) | 330 | notifications-on-action-map) |
| 318 | (unless notifications-on-action-object | 331 | (unless notifications-on-action-object |
| 319 | (setq notifications-on-action-object | 332 | (setq notifications-on-action-object |
| 320 | (dbus-register-signal | 333 | (dbus-register-signal |
| @@ -326,8 +339,8 @@ of another `notifications-notify' call." | |||
| 326 | 'notifications-on-action-signal)))) | 339 | 'notifications-on-action-signal)))) |
| 327 | 340 | ||
| 328 | (when on-close | 341 | (when on-close |
| 329 | (add-to-list 'notifications-on-close-map | 342 | (push (list (list bus unique-name id) on-close) |
| 330 | (list (list bus unique-name id) on-close)) | 343 | notifications-on-close-map) |
| 331 | (unless notifications-on-close-object | 344 | (unless notifications-on-close-object |
| 332 | (setq notifications-on-close-object | 345 | (setq notifications-on-close-object |
| 333 | (dbus-register-signal | 346 | (dbus-register-signal |