1
0
mirror of https://github.com/djcb/mu.git synced 2024-06-27 07:35:16 +02:00
This commit is contained in:
Pedro Ribeiro Mendes Júnior 2020-01-16 08:28:08 -03:00
commit 5d087a130b
7 changed files with 521 additions and 531 deletions

View File

@ -63,6 +63,16 @@
- Add message-id's to messages when saving drafts, so we can find them even - Add message-id's to messages when saving drafts, so we can find them even
with ~mu4e-headers-skip-duplicates~. with ~mu4e-headers-skip-duplicates~.
- Bookmarks (as in ~mu4e-bookmarks~) are now simple plists (instead of cl
structs). ~make-mu4e-bookmark~ has been updated to produce such plists (for
backward compatibility). A bookmark now looks like a list of e.g.
~(:name "My bookmark" :query "banana OR pear" :key ?f)~
this format is a bit easier extensible.
- For instance, we now recognize an attribute ~:hide t~, which will hide the
bookmark item from the main-screen (and speedbar), but keep it avilable
through the completion UI.
*** toys *** toys
- Updated the ~mug~ toy UI to use Webkit2/GTK+. Note that this is just a toy - Updated the ~mug~ toy UI to use Webkit2/GTK+. Note that this is just a toy

View File

@ -437,7 +437,7 @@ You can append flags."
;; otherwise... ;; otherwise...
(concat (concat
(mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg)) (mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg))
(mu4e~draft-header "Cc" (mu4e~draft-recipients-construct :cc origmsg)))))))) (mu4e~draft-header "Cc" (mu4e~draft-recipients-construct :cc origmsg :reply-all))))))))
(defun mu4e~draft-reply-construct-recipients-list (origmsg) (defun mu4e~draft-reply-construct-recipients-list (origmsg)
"Determine the to/cc recipients for a reply message to a "Determine the to/cc recipients for a reply message to a

View File

@ -1,6 +1,6 @@
;;; mu4e-main.el -- part of mu4e, the mu mail user agent -*- lexical-binding: t -*- ;;; mu4e-main.el -- part of mu4e, the mu mail user agent -*- lexical-binding: t -*-
;; ;;
;; Copyright (C) 2011-2016 Dirk-Jan C. Binnema ;; Copyright (C) 2011-2020 Dirk-Jan C. Binnema
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
@ -87,18 +87,18 @@ when STR is clicked (using RET or mouse-2); if FUNC-OR-SHORTCUT is
a string, execute the corresponding keyboard action when it is a string, execute the corresponding keyboard action when it is
clicked." clicked."
(let ((newstr (let ((newstr
(replace-regexp-in-string (replace-regexp-in-string
"\\[\\(..?\\)\\]" "\\[\\(..?\\)\\]"
(lambda(m) (lambda(m)
(format "[%s]" (format "[%s]"
(propertize (match-string 1 m) 'face 'mu4e-highlight-face))) (propertize (match-string 1 m) 'face 'mu4e-highlight-face)))
str)) str))
(map (make-sparse-keymap)) (map (make-sparse-keymap))
(func (if (functionp func-or-shortcut) (func (if (functionp func-or-shortcut)
func-or-shortcut func-or-shortcut
(if (stringp func-or-shortcut) (if (stringp func-or-shortcut)
(lambda()(interactive) (lambda()(interactive)
(execute-kbd-macro func-or-shortcut)))))) (execute-kbd-macro func-or-shortcut))))))
(define-key map [mouse-2] func) (define-key map [mouse-2] func)
(define-key map (kbd "RET") func) (define-key map (kbd "RET") func)
(put-text-property 0 (length newstr) 'keymap map newstr) (put-text-property 0 (length newstr) 'keymap map newstr)
@ -111,96 +111,97 @@ clicked."
;; buffer switching at the end. ;; buffer switching at the end.
(defun mu4e~main-view-real (ignore-auto noconfirm) (defun mu4e~main-view-real (ignore-auto noconfirm)
(let ((buf (get-buffer-create mu4e~main-buffer-name)) (let ((buf (get-buffer-create mu4e~main-buffer-name))
(inhibit-read-only t)) (inhibit-read-only t))
(with-current-buffer buf (with-current-buffer buf
(erase-buffer) (erase-buffer)
(insert (insert
"* " "* "
(propertize "mu4e - mu for emacs version " 'face 'mu4e-title-face) (propertize "mu4e - mu for emacs version " 'face 'mu4e-title-face)
(propertize mu4e-mu-version 'face 'mu4e-header-key-face) (propertize mu4e-mu-version 'face 'mu4e-header-key-face)
;; show some server properties; in this case; a big C when there's ;; show some server properties; in this case; a big C when there's
;; crypto support, a big G when there's Guile support ;; crypto support, a big G when there's Guile support
" " " "
(propertize (propertize
(concat (concat
(when (plist-get mu4e~server-props :crypto) "C") (when (plist-get mu4e~server-props :crypto) "C")
(when (plist-get mu4e~server-props :guile) "G") (when (plist-get mu4e~server-props :guile) "G")
(when (plist-get mu4e~server-props :mux) "X")) (when (plist-get mu4e~server-props :mux) "X"))
'face 'mu4e-title-face) 'face 'mu4e-title-face)
"\n\n" "\n\n"
(propertize " Basics\n\n" 'face 'mu4e-title-face) (propertize " Basics\n\n" 'face 'mu4e-title-face)
(mu4e~main-action-str (mu4e~main-action-str
"\t* [j]ump to some maildir\n" 'mu4e-jump-to-maildir) "\t* [j]ump to some maildir\n" 'mu4e-jump-to-maildir)
(mu4e~main-action-str (mu4e~main-action-str
"\t* enter a [s]earch query\n" 'mu4e-search) "\t* enter a [s]earch query\n" 'mu4e-search)
(mu4e~main-action-str (mu4e~main-action-str
"\t* [C]ompose a new message\n" 'mu4e-compose-new) "\t* [C]ompose a new message\n" 'mu4e-compose-new)
"\n" "\n"
(propertize " Bookmarks\n\n" 'face 'mu4e-title-face) (propertize " Bookmarks\n\n" 'face 'mu4e-title-face)
;; TODO: it's a bit uncool to hard-code the "b" shortcut... ;; TODO: it's a bit uncool to hard-code the "b" shortcut...
(mapconcat (mapconcat
(lambda (bm) (lambda (bm)
(mu4e~main-action-str (unless (plist-get bm :hide)
(concat "\t* [b" (make-string 1 (mu4e-bookmark-key bm)) "] " (mu4e~main-action-str
(mu4e-bookmark-name bm)) (concat "\t* [b" (make-string 1 (plist-get bm :key)) "] "
(concat "b" (make-string 1 (mu4e-bookmark-key bm))))) (plist-get bm :name))
(mu4e-bookmarks) "\n") (concat "b" (make-string 1 (plist-get bm :key))))))
"\n\n" (mu4e-bookmarks) "\n")
(propertize " Misc\n\n" 'face 'mu4e-title-face) "\n\n"
(propertize " Misc\n\n" 'face 'mu4e-title-face)
(mu4e~main-action-str "\t* [;]Switch context\n" 'mu4e-context-switch) (mu4e~main-action-str "\t* [;]Switch context\n" 'mu4e-context-switch)
(mu4e~main-action-str "\t* [U]pdate email & database\n" (mu4e~main-action-str "\t* [U]pdate email & database\n"
'mu4e-update-mail-and-index) 'mu4e-update-mail-and-index)
;; show the queue functions if `smtpmail-queue-dir' is defined ;; show the queue functions if `smtpmail-queue-dir' is defined
(if (file-directory-p smtpmail-queue-dir) (if (file-directory-p smtpmail-queue-dir)
(mu4e~main-view-queue) (mu4e~main-view-queue)
"") "")
"\n" "\n"
(mu4e~main-action-str "\t* [N]ews\n" 'mu4e-news) (mu4e~main-action-str "\t* [N]ews\n" 'mu4e-news)
(mu4e~main-action-str "\t* [A]bout mu4e\n" 'mu4e-about) (mu4e~main-action-str "\t* [A]bout mu4e\n" 'mu4e-about)
(mu4e~main-action-str "\t* [H]elp\n" 'mu4e-display-manual) (mu4e~main-action-str "\t* [H]elp\n" 'mu4e-display-manual)
(mu4e~main-action-str "\t* [q]uit\n" 'mu4e-quit)) (mu4e~main-action-str "\t* [q]uit\n" 'mu4e-quit))
(mu4e-main-mode) (mu4e-main-mode)
))) )))
(defun mu4e~main-view-queue () (defun mu4e~main-view-queue ()
"Display queue-related actions in the main view." "Display queue-related actions in the main view."
(concat (concat
(mu4e~main-action-str "\t* toggle [m]ail sending mode " (mu4e~main-action-str "\t* toggle [m]ail sending mode "
'mu4e~main-toggle-mail-sending-mode) 'mu4e~main-toggle-mail-sending-mode)
"(currently " "(currently "
(propertize (if smtpmail-queue-mail "queued" "direct") (propertize (if smtpmail-queue-mail "queued" "direct")
'face 'mu4e-header-key-face) 'face 'mu4e-header-key-face)
")\n" ")\n"
(let ((queue-size (mu4e~main-queue-size))) (let ((queue-size (mu4e~main-queue-size)))
(if (zerop queue-size) (if (zerop queue-size)
"" ""
(mu4e~main-action-str (mu4e~main-action-str
(format "\t* [f]lush %s queued %s\n" (format "\t* [f]lush %s queued %s\n"
(propertize (int-to-string queue-size) (propertize (int-to-string queue-size)
'face 'mu4e-header-key-face) 'face 'mu4e-header-key-face)
(if (> queue-size 1) "mails" "mail")) (if (> queue-size 1) "mails" "mail"))
'smtpmail-send-queued-mail))))) 'smtpmail-send-queued-mail)))))
(defun mu4e~main-queue-size () (defun mu4e~main-queue-size ()
"Return, as an int, the number of emails in the queue." "Return, as an int, the number of emails in the queue."
(condition-case nil (condition-case nil
(with-temp-buffer (with-temp-buffer
(insert-file-contents (expand-file-name smtpmail-queue-index-file (insert-file-contents (expand-file-name smtpmail-queue-index-file
smtpmail-queue-dir)) smtpmail-queue-dir))
(count-lines (point-min) (point-max))) (count-lines (point-min) (point-max)))
(error 0))) (error 0)))
(defun mu4e~main-view () (defun mu4e~main-view ()
"Create the mu4e main-view, and switch to it." "Create the mu4e main-view, and switch to it."
(if (eq mu4e-split-view 'single-window) (if (eq mu4e-split-view 'single-window)
(if (buffer-live-p (mu4e-get-headers-buffer)) (if (buffer-live-p (mu4e-get-headers-buffer))
(switch-to-buffer (mu4e-get-headers-buffer)) (switch-to-buffer (mu4e-get-headers-buffer))
(mu4e~main-menu)) (mu4e~main-menu))
(mu4e~main-view-real nil nil) (mu4e~main-view-real nil nil)
(switch-to-buffer mu4e~main-buffer-name) (switch-to-buffer mu4e~main-buffer-name)
(goto-char (point-min))) (goto-char (point-min)))
@ -217,7 +218,7 @@ clicked."
(mu4e-error "`smtpmail-queue-dir' does not exist")) (mu4e-error "`smtpmail-queue-dir' does not exist"))
(setq smtpmail-queue-mail (not smtpmail-queue-mail)) (setq smtpmail-queue-mail (not smtpmail-queue-mail))
(message (concat "Outgoing mail will now be " (message (concat "Outgoing mail will now be "
(if smtpmail-queue-mail "queued" "sent directly"))) (if smtpmail-queue-mail "queued" "sent directly")))
(unless (eq mu4e-split-view 'single-window) (unless (eq mu4e-split-view 'single-window)
(let ((curpos (point))) (let ((curpos (point)))
(mu4e~main-view-real nil nil) (mu4e~main-view-real nil nil)
@ -227,36 +228,29 @@ clicked."
"mu4e main view in the minibuffer." "mu4e main view in the minibuffer."
(interactive) (interactive)
(let ((key (let ((key
(read-key (read-key
(mu4e-format (mu4e-format
"%s" "%s"
(concat (concat
(mu4e~main-action-str "[j]ump " 'mu4e-jump-to-maildir) (mu4e~main-action-str "[j]ump " 'mu4e-jump-to-maildir)
(mu4e~main-action-str "[s]earch " 'mu4e-search) (mu4e~main-action-str "[s]earch " 'mu4e-search)
(mu4e~main-action-str "[C]ompose " 'mu4e-compose-new) (mu4e~main-action-str "[C]ompose " 'mu4e-compose-new)
(mu4e~main-action-str "[b]ookmarks " 'mu4e-headers-search-bookmark) (mu4e~main-action-str "[b]ookmarks " 'mu4e-headers-search-bookmark)
(mu4e~main-action-str "[;]Switch context " 'mu4e-context-switch) (mu4e~main-action-str "[;]Switch context " 'mu4e-context-switch)
(mu4e~main-action-str "[U]pdate " 'mu4e-update-mail-and-index) (mu4e~main-action-str "[U]pdate " 'mu4e-update-mail-and-index)
(mu4e~main-action-str "[N]ews " 'mu4e-news) (mu4e~main-action-str "[N]ews " 'mu4e-news)
(mu4e~main-action-str "[A]bout " 'mu4e-about) (mu4e~main-action-str "[A]bout " 'mu4e-about)
(mu4e~main-action-str "[H]elp " 'mu4e-display-manual)))))) (mu4e~main-action-str "[H]elp " 'mu4e-display-manual))))))
(unless (member key '(?\C-g ?\C-\[)) (unless (member key '(?\C-g ?\C-\[))
(let ((mu4e-command (lookup-key mu4e-main-mode-map (string key) t))) (let ((mu4e-command (lookup-key mu4e-main-mode-map (string key) t)))
(if mu4e-command (if mu4e-command
(condition-case err (condition-case err
(let ((mu4e-hide-index-messages t)) (let ((mu4e-hide-index-messages t))
(call-interactively mu4e-command)) (call-interactively mu4e-command))
(error (when (cadr err) (message (cadr err))))) (error (when (cadr err) (message (cadr err)))))
(message (mu4e-format "key %s not bound to a command" (string key)))) (message (mu4e-format "key %s not bound to a command" (string key))))
(when (or (not mu4e-command) (eq mu4e-command 'mu4e-context-switch)) (when (or (not mu4e-command) (eq mu4e-command 'mu4e-context-switch))
(sit-for 1) (sit-for 1)
(mu4e~main-menu)))))) (mu4e~main-menu))))))
;; (progn
;; (define-key mu4e-compose-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode)
;; (define-key mu4e-view-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode)
;; (define-key mu4e-compose-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode)
;; (define-key mu4e-headers-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode)
;; )
(provide 'mu4e-main) (provide 'mu4e-main)

View File

@ -1,6 +1,6 @@
;;; mu4e-speedbar --- Speedbar support for mu4e -*- lexical-binding: t -*- ;;; mu4e-speedbar --- Speedbar support for mu4e -*- lexical-binding: t -*-
;; Copyright (C) 2012-2018 Antono Vasiljev, Dirk-Jan C. Binnema ;; Copyright (C) 2012-2020 Antono Vasiljev, Dirk-Jan C. Binnema
;; ;;
;; Author: Antono Vasiljev <self@antono.info> ;; Author: Antono Vasiljev <self@antono.info>
;; Version: 0.1 ;; Version: 0.1
@ -56,10 +56,10 @@
"Install those variables used by speedbar to enhance mu4e." "Install those variables used by speedbar to enhance mu4e."
(add-hook 'mu4e-context-changed-hook (add-hook 'mu4e-context-changed-hook
(lambda() (lambda()
(when (buffer-live-p speedbar-buffer) (when (buffer-live-p speedbar-buffer)
(with-current-buffer speedbar-buffer (with-current-buffer speedbar-buffer
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(mu4e-speedbar-buttons)))))) (mu4e-speedbar-buttons))))))
(dolist (keymap (dolist (keymap
'( mu4e-main-speedbar-key-map '( mu4e-main-speedbar-key-map
mu4e-headers-speedbar-key-map mu4e-headers-speedbar-key-map
@ -80,13 +80,13 @@
(when (buffer-live-p speedbar-buffer) (when (buffer-live-p speedbar-buffer)
(with-current-buffer speedbar-buffer (with-current-buffer speedbar-buffer
(mapcar (lambda (maildir-name) (mapcar (lambda (maildir-name)
(speedbar-insert-button (speedbar-insert-button
(concat " " maildir-name) (concat " " maildir-name)
'mu4e-highlight-face 'mu4e-highlight-face
'highlight 'highlight
'mu4e~speedbar-maildir 'mu4e~speedbar-maildir
maildir-name)) maildir-name))
(mu4e-get-maildirs))))) (mu4e-get-maildirs)))))
(defun mu4e~speedbar-maildir (&optional _text token _ident) (defun mu4e~speedbar-maildir (&optional _text token _ident)
"Jump to maildir TOKEN. TEXT and INDENT are not used." "Jump to maildir TOKEN. TEXT and INDENT are not used."
@ -98,12 +98,13 @@
"Insert the list of bookmarks in the speedbar" "Insert the list of bookmarks in the speedbar"
(interactive) (interactive)
(mapcar (lambda (bookmark) (mapcar (lambda (bookmark)
(speedbar-insert-button (unless (plist-get bookmark :hide)
(concat " " (mu4e-bookmark-name bookmark)) (speedbar-insert-button
'mu4e-highlight-face (concat " " (plist-get bookmark :name))
'highlight 'mu4e-highlight-face
'mu4e~speedbar-bookmark 'highlight
(mu4e-bookmark-query bookmark))) 'mu4e~speedbar-bookmark
(plist-get bookmark :query))))
(mu4e-bookmarks))) (mu4e-bookmarks)))
(defun mu4e~speedbar-bookmark (&optional _text token _ident) (defun mu4e~speedbar-bookmark (&optional _text token _ident)

File diff suppressed because it is too large Load Diff

View File

@ -201,43 +201,41 @@ If the string exceeds this limit, it will be truncated to fit."
(defvar mu4e-debug nil (defvar mu4e-debug nil
"When set to non-nil, log debug information to the *mu4e-log* buffer.") "When set to non-nil, log debug information to the *mu4e-log* buffer.")
(cl-defstruct mu4e-bookmark ;; for backward compatibility, when a bookmark was defined with defstruct.
"A mu4e bookmarl object with the following members: (cl-defun make-mu4e-bookmark (&key name query key)
"Create a mu4e proplist with the following elements:
- `name': the user-visible name of the bookmark - `name': the user-visible name of the bookmark
- `key': a single key to search for this bookmark - `key': a single key to search for this bookmark
- `query': the query for this bookmark. Either a literal string or a function - `query': the query for this bookmark. Either a literal string or a function
that evaluates to a string." that evaluates to a string."
name ;; name/description of the bookmark `(:name ,name :query ,query :key ,key))
query ;; a query (a string or a function evaluation to string) (make-obsolete 'make-mu4e-bookmark "`unneeded; `mu4e-bookmarks'
key ;; key to activate the bookmark are plists" "1.3.7")
)
(defcustom mu4e-bookmarks (defcustom mu4e-bookmarks
`( ,(make-mu4e-bookmark '(( :name "Unread messages"
:name "Unread messages" :query "flag:unread AND NOT flag:trashed"
:query "flag:unread AND NOT flag:trashed" :key ?u)
:key ?u) ( :name "Today's messages"
,(make-mu4e-bookmark :query "date:today..now"
:name "Today's messages" :key ?t)
:query "date:today..now" ( :name "Last 7 days"
:key ?t) :query "date:7d..now"
,(make-mu4e-bookmark :key ?w)
:name "Last 7 days" ( :name "Messages with images"
:query "date:7d..now" :query "mime:image/*"
:key ?w) :key ?p))
,(make-mu4e-bookmark "List of pre-defined queries that are shown on the main screen.
:name "Messages with images"
:query "mime:image/*" Each of the list elements is a plist with at least:
:key ?p)) :name - the name of the queryt
"A list of pre-defined queries. :query - the query expression
These will show up in the main screen. Each of the list elements :key - the shortcut key.
is a three-element list of the form (QUERY DESCRIPTION KEY),
where QUERY is a string with a mu query, DESCRIPTION is a short Optionally, you add the following:
description of the query (this will show up in the UI), and KEY :hide - if t, bookmark is hdden from the main-view and speedbar.
is a shortcut key for the query." "
:type '(repeat (list (string :tag "Query") :type '(repeat (plist))
(string :tag "Description")
character))
:group 'mu4e) :group 'mu4e)
(defcustom mu4e-split-view 'horizontal (defcustom mu4e-split-view 'horizontal

View File

@ -1962,25 +1962,21 @@ mu4e-search-bookmark-edit}) which lets you edit the bookmark first.
@subsection Setting up bookmarks @subsection Setting up bookmarks
@t{mu4e} provides a number of default bookmarks. Their definition is @t{mu4e} provides a number of default bookmarks. Their definition may
instructive: be instructive:
@lisp @lisp
(defvar mu4e-bookmarks (defvar mu4e-bookmarks
`( ,(make-mu4e-bookmark '( ( :name "Unread messages"
:name "Unread messages"
:query "flag:unread AND NOT flag:trashed" :query "flag:unread AND NOT flag:trashed"
:key ?u) :key ?u)
,(make-mu4e-bookmark ( :name "Today's messages"
:name "Today's messages"
:query "date:today..now" :query "date:today..now"
:key ?t) :key ?t)
,(make-mu4e-bookmark ( :name "Last 7 days"
:name "Last 7 days"
:query "date:7d..now" :query "date:7d..now"
:key ?w) :key ?w)
,(make-mu4e-bookmark ( :name "Messages with images"
:name "Messages with images"
:query "mime:image/*" :query "mime:image/*"
:key ?p)) :key ?p))
"A list of pre-defined queries. Each query is represented by a "A list of pre-defined queries. Each query is represented by a
@ -1997,10 +1993,9 @@ You can replace these or add your own items, by putting in your
configuration (@file{~/.emacs}) something like: configuration (@file{~/.emacs}) something like:
@lisp @lisp
(add-to-list 'mu4e-bookmarks (add-to-list 'mu4e-bookmarks
(make-mu4e-bookmark '( :name "Big messages"
:name "Big messages" :query "size:5M..500M"
:query "size:5M..500M" :key ?b))
:key ?b))
@end lisp @end lisp
This prepends your bookmark to the list, and assigns the key @key{b} to it. If This prepends your bookmark to the list, and assigns the key @key{b} to it. If
@ -2023,12 +2018,11 @@ inbox:
@lisp @lisp
(add-to-list 'mu4e-bookmarks (add-to-list 'mu4e-bookmarks
(make-mu4e-bookmark '( :name "Inbox messages in the last 7 days"
:name "Inbox messages in the last 7 days" :query (lambda () (concat "maildir:/inbox AND date:"
:query (lambda () (concat "maildir:/inbox AND date:" (format-time-string "%Y%m%d"
(format-time-string "%Y%m%d"
(subtract-time (current-time) (days-to-time 7))))) (subtract-time (current-time) (days-to-time 7)))))
:key ?w) t) :key ?w) t)
@end lisp @end lisp
Another example where the user is prompted how many days old messages should be Another example where the user is prompted how many days old messages should be
@ -2042,10 +2036,9 @@ shown:
(format-time-string "%Y%m%d" start-date)))) (format-time-string "%Y%m%d" start-date))))
(add-to-list 'mu4e-bookmarks (add-to-list 'mu4e-bookmarks
(make-mu4e-bookmark `(:name "Inbox messages in the last 7 days"
:name "Inbox messages in the last 7 days" :query ,(lambda () (call-interactively 'my/mu4e-bookmark-num-days-old-query))
:query (lambda () (call-interactively 'my/mu4e-bookmark-num-days-old-query)) :key ?o) t)
:key ?o) t)
@end lisp @end lisp
It is defining a function to make the code more readable. It is defining a function to make the code more readable.