aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2024-01-13 05:36:16 -0500
committerEli Zaretskii2024-01-13 05:36:16 -0500
commitf1736571fa3f4bc13dbc217f61bdc6e8efdc24b4 (patch)
treebd578b33ecfb44585800ded0bccf2856ba7bea14
parentccc28245c090c2d5f93184e8887fede3910b977e (diff)
parent99efe5c80f9d90de6540ef6f78504c0413947a25 (diff)
downloademacs-f1736571fa3f4bc13dbc217f61bdc6e8efdc24b4.tar.gz
emacs-f1736571fa3f4bc13dbc217f61bdc6e8efdc24b4.zip
Merge from origin/emacs-29
99efe5c80f9 Fix count of no-op functions (bug#68375) 0c01f97b73c Wrap @pxref of Abbrevs in parentheses (bug#68375) 70a09325d65 ; Fix last change in widget.texi 63411709a8d ; Fix typos 824cf54951c ; * etc/TODO: Add item to make play-sound non-blocking. 4fadbfe300a Add examples to the Widget manual 1bbb610821e Implement missing functions for custom-icon widget 29af214a75a Fix fontification of cgroup2 in fstab (bug#68367)
-rw-r--r--doc/lispref/functions.texi4
-rw-r--r--doc/lispref/symbols.texi2
-rw-r--r--doc/misc/widget.texi222
-rw-r--r--etc/TODO2
-rw-r--r--lisp/cus-edit.el58
-rw-r--r--lisp/generic-x.el1
-rw-r--r--lisp/progmodes/python.el4
7 files changed, 285 insertions, 8 deletions
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index 29061e6561c..344b3ff3a50 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -982,8 +982,8 @@ lists) and call them using @code{funcall} or @code{apply}. Functions
982that accept function arguments are often called @dfn{functionals}. 982that accept function arguments are often called @dfn{functionals}.
983 983
984 Sometimes, when you call a functional, it is useful to supply a no-op 984 Sometimes, when you call a functional, it is useful to supply a no-op
985function as the argument. Here are two different kinds of no-op 985function as the argument. Here are three different kinds of no-op
986function: 986functions:
987 987
988@defun identity argument 988@defun identity argument
989This function returns @var{argument} and has no side effects. 989This function returns @var{argument} and has no side effects.
diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi
index 6fe4189901a..367bd195f16 100644
--- a/doc/lispref/symbols.texi
+++ b/doc/lispref/symbols.texi
@@ -675,7 +675,7 @@ name} (@pxref{Symbol Components}).
675 675
676It is useful to think of shorthands as @emph{abbreviating} the full 676It is useful to think of shorthands as @emph{abbreviating} the full
677names of intended symbols. Despite this, do not confuse shorthands with the 677names of intended symbols. Despite this, do not confuse shorthands with the
678Abbrev system @pxref{Abbrevs}. 678Abbrev system (@pxref{Abbrevs}).
679 679
680@cindex namespace etiquette 680@cindex namespace etiquette
681Shorthands make Emacs Lisp's @dfn{namespacing etiquette} easier to work 681Shorthands make Emacs Lisp's @dfn{namespacing etiquette} easier to work
diff --git a/doc/misc/widget.texi b/doc/misc/widget.texi
index 93b7606b01e..cfb9d2211cf 100644
--- a/doc/misc/widget.texi
+++ b/doc/misc/widget.texi
@@ -1384,6 +1384,15 @@ a specific way. If present, @var{value} is used to initialize the
1384@code{:value} property. When created, it inserts the value as a 1384@code{:value} property. When created, it inserts the value as a
1385string in the buffer. 1385string in the buffer.
1386 1386
1387@noindent
1388Example:
1389
1390@lisp
1391(widget-create 'item :tag "Today is" :format "%t: %v\n"
1392 (format-time-string "%d-%m-%Y"))
1393@end lisp
1394
1395
1387By default, it has the following properties: 1396By default, it has the following properties:
1388 1397
1389@table @code 1398@table @code
@@ -1428,6 +1437,20 @@ The @var{value}, if present, is used to initialize the @code{:value}
1428property. The value should be a string, which will be inserted in the 1437property. The value should be a string, which will be inserted in the
1429buffer. 1438buffer.
1430 1439
1440@noindent
1441Example:
1442
1443@lisp
1444(widget-create 'link
1445 :button-prefix ""
1446 :button-suffix ""
1447 :tag "Mail yourself"
1448 :action #'(lambda (widget &optional _event)
1449 (compose-mail-other-window (widget-value widget)))
1450 user-mail-address)
1451@end lisp
1452
1453
1431By default, it has the following properties: 1454By default, it has the following properties:
1432 1455
1433@table @code 1456@table @code
@@ -1471,6 +1494,31 @@ A widget to represent a link to a web page. Its super is the
1471It overrides the @code{:action} property to open up the @var{url} 1494It overrides the @code{:action} property to open up the @var{url}
1472specified. 1495specified.
1473 1496
1497@noindent
1498Example:
1499
1500@lisp
1501@group
1502(widget-create 'url-link
1503 :button-prefix ""
1504 :button-suffix ""
1505 ;; Return appropriate face.
1506 :button-face-get (lambda (widget)
1507 (if (widget-get widget :visited)
1508 'link-visited
1509 'link))
1510 :format "%[%t%]"
1511 :tag "Browse this manual"
1512 :action (lambda (widget &optional _event)
1513 (widget-put widget :visited t)
1514 ;; Takes care of redrawing the widget.
1515 (widget-value-set widget (widget-value widget))
1516 ;; And then call the original function.
1517 (widget-url-link-action widget))
1518 "https://www.gnu.org/software/emacs/manual/html_mono/widget.html")
1519@end group
1520@end lisp
1521
1474@node info-link 1522@node info-link
1475@subsection The @code{info-link} Widget 1523@subsection The @code{info-link} Widget
1476@findex info-link@r{ widget} 1524@findex info-link@r{ widget}
@@ -1487,6 +1535,17 @@ A widget to represent a link to an info file. Its super is the
1487It overrides the @code{:action} property, to a function to start the 1535It overrides the @code{:action} property, to a function to start the
1488built-in Info reader on @var{address}, when invoked. 1536built-in Info reader on @var{address}, when invoked.
1489 1537
1538@noindent
1539Example:
1540
1541@lisp
1542(widget-create 'info-link
1543 :button-prefix ""
1544 :button-suffix ""
1545 :tag "Browse this manual"
1546 "(widget) info-link")))
1547@end lisp
1548
1490@node function-link 1549@node function-link
1491@subsection The @code{function-link} Widget 1550@subsection The @code{function-link} Widget
1492@findex function-link@r{ widget} 1551@findex function-link@r{ widget}
@@ -1502,6 +1561,17 @@ A widget to represent a link to an Emacs function. Its super is the
1502It overrides the @code{:action} property, to a function to describe 1561It overrides the @code{:action} property, to a function to describe
1503@var{function}. 1562@var{function}.
1504 1563
1564@noindent
1565Example:
1566
1567@lisp
1568(widget-create 'function-link
1569 :button-prefix ""
1570 :button-suffix ""
1571 :tag "Describe the function that gets called"
1572 #'widget-function-link-action)
1573@end lisp
1574
1505@node variable-link 1575@node variable-link
1506@subsection The @code{variable-link} Widget 1576@subsection The @code{variable-link} Widget
1507@findex variable-link@r{ widget} 1577@findex variable-link@r{ widget}
@@ -1517,6 +1587,17 @@ A widget to represent a link to an Emacs variable. Its super is the
1517It overrides the @code{:action} property, to a function to describe 1587It overrides the @code{:action} property, to a function to describe
1518@var{var}. 1588@var{var}.
1519 1589
1590@noindent
1591Example:
1592
1593@lisp
1594(widget-create 'variable-link
1595 :button-prefix ""
1596 :button-suffix ""
1597 :tag "What setting controls button-prefix?"
1598 'widget-button-prefix)
1599@end lisp
1600
1520@node face-link 1601@node face-link
1521@subsection The @code{face-link} Widget 1602@subsection The @code{face-link} Widget
1522@findex face-link@r{ widget} 1603@findex face-link@r{ widget}
@@ -1532,6 +1613,17 @@ A widget to represent a link to an Emacs face. Its super is the
1532It overrides the @code{:action} property, to a function to describe 1613It overrides the @code{:action} property, to a function to describe
1533@var{face}. 1614@var{face}.
1534 1615
1616@noindent
1617Example:
1618
1619@lisp
1620(widget-create 'face-link
1621 :button-prefix ""
1622 :button-suffix ""
1623 :tag "Which face is this one?"
1624 'widget-button)
1625@end lisp
1626
1535@node file-link 1627@node file-link
1536@subsection The @code{file-link} Widget 1628@subsection The @code{file-link} Widget
1537@findex file-link@r{ widget} 1629@findex file-link@r{ widget}
@@ -1547,6 +1639,19 @@ A widget to represent a link to a file. Its super is the
1547It overrides the @code{:action} property, to a function to find the file 1639It overrides the @code{:action} property, to a function to find the file
1548@var{file}. 1640@var{file}.
1549 1641
1642@noindent
1643Example:
1644
1645@lisp
1646(let ((elisp-files (directory-files user-emacs-directory t ".el$")))
1647 (dolist (file elisp-files)
1648 (widget-create 'file-link
1649 :button-prefix ""
1650 :button-suffix ""
1651 file)
1652 (widget-insert "\n")))
1653@end lisp
1654
1550@node emacs-library-link 1655@node emacs-library-link
1551@subsection The @code{emacs-library-link} Widget 1656@subsection The @code{emacs-library-link} Widget
1552@findex emacs-library-link@r{ widget} 1657@findex emacs-library-link@r{ widget}
@@ -1562,6 +1667,17 @@ A widget to represent a link to an Emacs Lisp file. Its super is the
1562It overrides the @code{:action} property, to a function to find the file 1667It overrides the @code{:action} property, to a function to find the file
1563@var{file}. 1668@var{file}.
1564 1669
1670@noindent
1671Example:
1672
1673@lisp
1674(widget-create 'emacs-library-link
1675 :button-prefix ""
1676 :button-suffix ""
1677 :tag "Show yourself, Widget Library!"
1678 "wid-edit.el")
1679@end lisp
1680
1565@node emacs-commentary-link 1681@node emacs-commentary-link
1566@subsection The @code{emacs-commentary-link} Widget 1682@subsection The @code{emacs-commentary-link} Widget
1567@findex emacs-commentary-link@r{ widget} 1683@findex emacs-commentary-link@r{ widget}
@@ -1577,6 +1693,17 @@ file. Its super is the @code{link} widget.
1577It overrides the @code{:action} property, to a function to find the file 1693It overrides the @code{:action} property, to a function to find the file
1578@var{file} and put point in the Comment section. 1694@var{file} and put point in the Comment section.
1579 1695
1696@noindent
1697Example:
1698
1699@lisp
1700(widget-create 'emacs-commentary-link
1701 :button-prefix ""
1702 :button-suffix ""
1703 :tag "Check our good friend Customize"
1704 "cus-edit.el")
1705@end lisp
1706
1580@node push-button 1707@node push-button
1581@subsection The @code{push-button} Widget 1708@subsection The @code{push-button} Widget
1582@findex push-button@r{ widget} 1709@findex push-button@r{ widget}
@@ -2009,6 +2136,33 @@ A widget that can toggle between two states. Its super is the
2009The widget has two possible states, @samp{on} and @samp{off}, which 2136The widget has two possible states, @samp{on} and @samp{off}, which
2010correspond to a @code{t} or @code{nil} value, respectively. 2137correspond to a @code{t} or @code{nil} value, respectively.
2011 2138
2139@noindent
2140Example:
2141
2142@lisp
2143@group
2144(widget-insert "Press the button to activate/deactivate the field: ")
2145(widget-create 'toggle
2146 :notify (lambda (widget &rest _ignored)
2147 (widget-apply widget-example-field
2148 (if (widget-value widget)
2149 :activate
2150 :deactivate))))
2151(widget-insert "\n")
2152@end group
2153@group
2154(setq widget-example-field
2155 (widget-create 'editable-field
2156 :deactivate (lambda (widget)
2157 (widget-specify-inactive
2158 widget
2159 (widget-field-start widget)
2160 (widget-get widget :to)))))
2161(widget-apply widget-example-field :deactivate)))
2162@end group
2163@end lisp
2164
2165
2012It either overrides or adds the following properties: 2166It either overrides or adds the following properties:
2013 2167
2014@table @code 2168@table @code
@@ -2148,6 +2302,21 @@ The @var{type} arguments represent each checklist item. The widget's
2148value will be a list containing the values of all checked @var{type} 2302value will be a list containing the values of all checked @var{type}
2149arguments. 2303arguments.
2150 2304
2305@noindent
2306Example:
2307
2308@lisp
2309(widget-create 'checklist
2310 :notify (lambda (widget child &optional _event)
2311 (funcall
2312 (widget-value (widget-get-sibling child))
2313 'toggle))
2314 :value (list 'tool-bar-mode 'menu-bar-mode)
2315 '(item :tag "Tool-bar" tool-bar-mode)
2316 '(item :tag "Menu-bar" menu-bar-mode))))
2317@end lisp
2318
2319
2151It either overrides or adds the following properties: 2320It either overrides or adds the following properties:
2152 2321
2153@table @code 2322@table @code
@@ -2899,6 +3068,59 @@ The predefined functions @code{widget-types-convert-widget} and
2899@code{widget-value-convert-widget} can be used here. 3068@code{widget-value-convert-widget} can be used here.
2900@end table 3069@end table
2901 3070
3071@noindent
3072Example:
3073
3074@lisp
3075@group
3076(defvar widget-ranged-integer-map
3077 (let ((map (copy-keymap widget-keymap)))
3078 (define-key map [up] #'widget-ranged-integer-increase)
3079 (define-key map [down] #'widget-ranged-integer-decrease)
3080 map))
3081@end group
3082
3083@group
3084(define-widget 'ranged-integer 'integer
3085 "A ranged integer widget."
3086 :min-value most-negative-fixnum
3087 :max-value most-positive-fixnum
3088 :keymap widget-ranged-integer-map)
3089@end group
3090
3091@group
3092(defun widget-ranged-integer-change (widget how)
3093 "Change the value of the ranged-integer WIDGET, according to HOW."
3094 (let* ((value (widget-value widget))
3095 (newval (cond
3096 ((eq how 'up)
3097 (if (< (1+ value) (widget-get widget :max-value))
3098 (1+ value)
3099 (widget-get widget :max-value)))
3100 ((eq how 'down)
3101 (if (> (1- value) (widget-get widget :min-value))
3102 (1- value)
3103 (widget-get widget :min-value)))
3104 (t (error "HOW has a bad value"))))
3105 (inhibit-read-only t))
3106 (widget-value-set widget newval)))
3107@end group
3108
3109@group
3110(defun widget-ranged-integer-increase (widget)
3111 "Increase the value of the ranged-integer WIDGET."
3112 (interactive (list (widget-at)))
3113 (widget-ranged-integer-change widget 'up))
3114@end group
3115
3116@group
3117(defun widget-ranged-integer-decrease (widget)
3118 "Decrease the value of the ranged-integer WIDGET."
3119 (interactive (list (widget-at)))
3120 (widget-ranged-integer-change widget 'down))
3121@end group
3122@end lisp
3123
2902@node Inspecting Widgets 3124@node Inspecting Widgets
2903@chapter Inspecting Widgets 3125@chapter Inspecting Widgets
2904@cindex widget browser 3126@cindex widget browser
diff --git a/etc/TODO b/etc/TODO
index a3674c452a3..0152cf9303e 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -156,6 +156,8 @@ from.
156 156
157** Make back_comment use syntax-ppss or equivalent 157** Make back_comment use syntax-ppss or equivalent
158 158
159** Make play-sound asynchronous and non-blocking
160
159** Consider improving src/sysdep.c's search for a fqdn 161** Consider improving src/sysdep.c's search for a fqdn
160https://lists.gnu.org/r/emacs-devel/2007-04/msg00782.html 162https://lists.gnu.org/r/emacs-devel/2007-04/msg00782.html
161 163
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 0eeca7c2f31..38b6ec984ab 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -5389,9 +5389,49 @@ The following properties have special meanings for this widget:
5389 :hidden-states '(standard) 5389 :hidden-states '(standard)
5390 :action #'custom-icon-action 5390 :action #'custom-icon-action
5391 :custom-set #'custom-icon-set 5391 :custom-set #'custom-icon-set
5392 :custom-reset-current #'custom-redraw) 5392 :custom-mark-to-save #'custom-icon-mark-to-save
5393 ;; Not implemented yet. 5393 :custom-reset-current #'custom-redraw
5394 ;; :custom-reset-saved 'custom-icon-reset-saved) 5394 :custom-reset-saved #'custom-icon-reset-saved
5395 :custom-state-set-and-redraw #'custom-icon-state-set-and-redraw
5396 :custom-reset-standard #'custom-icon-reset-standard
5397 :custom-mark-to-reset-standard #'custom-icon-mark-to-reset-standard)
5398
5399(defun custom-icon-mark-to-save (widget)
5400 "Mark user customization for icon edited by WIDGET to be saved later."
5401 (let* ((icon (widget-value widget))
5402 (value (custom--icons-widget-value
5403 (car (widget-get widget :children)))))
5404 (custom-push-theme 'theme-icon icon 'user 'set value)))
5405
5406(defun custom-icon-reset-saved (widget)
5407 "Restore icon customized by WIDGET to the icon's default attributes.
5408
5409If there's a theme value for the icon, resets to that. Otherwise, resets to
5410its standard value."
5411 (let* ((icon (widget-value widget)))
5412 (custom-push-theme 'theme-icon icon 'user 'reset)
5413 (custom-icon-state-set widget)
5414 (custom-redraw widget)))
5415
5416(defun custom-icon-state-set-and-redraw (widget)
5417 "Set state of icon widget WIDGET and redraw it with up-to-date settings."
5418 (custom-icon-state-set widget)
5419 (custom-redraw-magic widget))
5420
5421(defun custom-icon-reset-standard (widget)
5422 "Reset icon edited by WIDGET to its standard value."
5423 (let* ((icon (widget-value widget))
5424 (themes (get icon 'theme-icon)))
5425 (dolist (theme themes)
5426 (custom-push-theme 'theme-icon icon (car theme) 'reset))
5427 (custom-save-all))
5428 (widget-put widget :custom-state 'unknown)
5429 (custom-redraw widget))
5430
5431(defun custom-icon-mark-to-reset-standard (widget)
5432 "Reset icon edited by WIDGET to its standard value."
5433 ;; Don't mark for now, there aren't that many icons.
5434 (custom-icon-reset-standard widget))
5395 5435
5396(defvar custom-icon-extended-menu 5436(defvar custom-icon-extended-menu
5397 (let ((map (make-sparse-keymap))) 5437 (let ((map (make-sparse-keymap)))
@@ -5410,6 +5450,18 @@ The following properties have special meanings for this widget:
5410 :enable (memq 5450 :enable (memq
5411 (widget-get custom-actioned-widget :custom-state) 5451 (widget-get custom-actioned-widget :custom-state)
5412 '(modified changed)))) 5452 '(modified changed))))
5453 (define-key-after map [custom-icon-reset-saved]
5454 '(menu-item "Revert This Session's Customization"
5455 custom-icon-reset-saved
5456 :enable (memq
5457 (widget-get custom-actioned-widget :custom-state)
5458 '(modified set changed rogue))))
5459 (when (or custom-file init-file-user)
5460 (define-key-after map [custom-icon-reset-standard]
5461 '(menu-item "Erase Customization" custom-icon-reset-standard
5462 :enable (memq
5463 (widget-get custom-actioned-widget :custom-state)
5464 '(modified set changed saved rogue)))))
5413 map) 5465 map)
5414 "A menu for `custom-icon' widgets. 5466 "A menu for `custom-icon' widgets.
5415Used in `custom-icon-action' to show a menu to the user.") 5467Used in `custom-icon-action' to show a menu to the user.")
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index b4ae0225943..373bfad92dd 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -1491,6 +1491,7 @@ like an INI file. You can add this hook to `find-file-hook'."
1491 "cd9660" 1491 "cd9660"
1492 "cfs" 1492 "cfs"
1493 "cgroup" 1493 "cgroup"
1494 "cgroup2"
1494 "cifs" 1495 "cifs"
1495 "coda" 1496 "coda"
1496 "coherent" 1497 "coherent"
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index a44d4215d7c..e2f614f52c2 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1117,7 +1117,7 @@ fontified."
1117 1117
1118(defun python--treesit-fontify-union-types (node override start end &optional type-regex &rest _) 1118(defun python--treesit-fontify-union-types (node override start end &optional type-regex &rest _)
1119 "Fontify nested union types in the type hints. 1119 "Fontify nested union types in the type hints.
1120For examlpe, Lvl1 | Lvl2[Lvl3[Lvl4[Lvl5 | None]], Lvl2]. This 1120For example, Lvl1 | Lvl2[Lvl3[Lvl4[Lvl5 | None]], Lvl2]. This
1121structure is represented via nesting binary_operator and 1121structure is represented via nesting binary_operator and
1122subscript nodes. This function iterates over all levels and 1122subscript nodes. This function iterates over all levels and
1123highlight identifier nodes. If TYPE-REGEX is not nil fontify type 1123highlight identifier nodes. If TYPE-REGEX is not nil fontify type
@@ -1275,7 +1275,7 @@ fontified."
1275 (subscript (identifier) @font-lock-type-face) 1275 (subscript (identifier) @font-lock-type-face)
1276 (subscript (attribute attribute: (identifier) @font-lock-type-face))])) 1276 (subscript (attribute attribute: (identifier) @font-lock-type-face))]))
1277 1277
1278 ;; Patern matching: case [str(), pack0.Type0()]. Take only the 1278 ;; Pattern matching: case [str(), pack0.Type0()]. Take only the
1279 ;; last identifier. 1279 ;; last identifier.
1280 (class_pattern (dotted_name (identifier) @font-lock-type-face :anchor)) 1280 (class_pattern (dotted_name (identifier) @font-lock-type-face :anchor))
1281 1281