From 0c097e5d019451a1667846729d3e42b3bab6ef6b Mon Sep 17 00:00:00 2001 From: Derek Taylor Date: Fri, 12 Apr 2024 21:47:50 -0500 Subject: [PATCH 1/2] Testing completion-read. --- .config/emacs/config.el | 37 ++++++++++++++++++++++--------------- .config/emacs/config.org | 35 +++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/.config/emacs/config.el b/.config/emacs/config.el index bc78b29..3b1c1c6 100644 --- a/.config/emacs/config.el +++ b/.config/emacs/config.el @@ -703,22 +703,12 @@ (defun reader () (interactive) - (let ((choices '(("First" . "First") + (let ((choices '(("First" . "Hi!") ("Second" . 'second-choice) ("Third" . 'third-choice)))) (alist-get (completing-read "Choose: " choices) - choices nil t 'equal))) - -(setq yy-keywords - '("touch" - "touch_start" - "touch_end" - "for" - "foreach" - "forall" - )) - + choices nil nil 'message))) (defun github-code-search () "Search code on github for a given language." @@ -730,7 +720,24 @@ (browse-url (concat "https://github.com/search?l=" language "&type=code&q=" code)))) -<<<<<<< HEAD + +(defun dm-search () + "Search various search engines." + (interactive) + (let ((engine (completing-read + "Search Engine: " + '("Arch Wiki" + "Bing" + "Google" + "Wikipedia"))) + (query (read-string "Query: "))) + (if (equal engine "Google") + (browse-url + (concat "https://www.google.com/search?q=" query))))) -======= ->>>>>>> 987492dc041b7a12f6a57be035df64dd74fc6c09 +(defun dt/key-value-completing (choice) + (interactive + (list + (let ((completions '(("1" "One") ("2" "Two") ("3" "Three")))) + (cadr (assoc (completing-read "Choose: " completions) completions))))) + (message "You choose `%s'" choice)) diff --git a/.config/emacs/config.org b/.config/emacs/config.org index e363840..6c7827c 100644 --- a/.config/emacs/config.org +++ b/.config/emacs/config.org @@ -1032,22 +1032,12 @@ With Emacs version 29, true transparency has been added. I have turned transpar #+begin_src emacs-lisp (defun reader () (interactive) - (let ((choices '(("First" . "First") + (let ((choices '(("First" . "Hi!") ("Second" . 'second-choice) ("Third" . 'third-choice)))) (alist-get (completing-read "Choose: " choices) - choices nil t 'equal))) - -(setq yy-keywords - '("touch" - "touch_start" - "touch_end" - "for" - "foreach" - "forall" - )) - + choices nil nil 'message))) (defun github-code-search () "Search code on github for a given language." @@ -1060,4 +1050,25 @@ With Emacs version 29, true transparency has been added. I have turned transpar (concat "https://github.com/search?l=" language "&type=code&q=" code)))) +(defun dm-search () + "Search various search engines." + (interactive) + (let ((engine (completing-read + "Search Engine: " + '("Arch Wiki" + "Bing" + "Google" + "Wikipedia"))) + (query (read-string "Query: "))) + (if (equal engine "Google") + (browse-url + (concat "https://www.google.com/search?q=" query))))) + +(defun dt/key-value-completing (choice) + (interactive + (list + (let ((completions '(("1" "One") ("2" "Two") ("3" "Three")))) + (cadr (assoc (completing-read "Choose: " completions) completions))))) + (message "You choose `%s'" choice)) + #+end_src From 67ddcb090fdcd5be954bb3af13ae6dbc236d988f Mon Sep 17 00:00:00 2001 From: Derek Taylor Date: Fri, 12 Apr 2024 22:21:50 -0500 Subject: [PATCH 2/2] Testing completion-read. --- .config/emacs/config.el | 4 +++- .config/emacs/config.org | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.config/emacs/config.el b/.config/emacs/config.el index 3b1c1c6..ea48edd 100644 --- a/.config/emacs/config.el +++ b/.config/emacs/config.el @@ -738,6 +738,8 @@ (defun dt/key-value-completing (choice) (interactive (list - (let ((completions '(("1" "One") ("2" "Two") ("3" "Three")))) + (let ((completions '(("1" "One") + ("2" "Two") + ("3" "Three")))) (cadr (assoc (completing-read "Choose: " completions) completions))))) (message "You choose `%s'" choice)) diff --git a/.config/emacs/config.org b/.config/emacs/config.org index 6c7827c..38ffc8d 100644 --- a/.config/emacs/config.org +++ b/.config/emacs/config.org @@ -1067,7 +1067,9 @@ With Emacs version 29, true transparency has been added. I have turned transpar (defun dt/key-value-completing (choice) (interactive (list - (let ((completions '(("1" "One") ("2" "Two") ("3" "Three")))) + (let ((completions '(("1" "One") + ("2" "Two") + ("3" "Three")))) (cadr (assoc (completing-read "Choose: " completions) completions))))) (message "You choose `%s'" choice))