Advertisement
Guest User

Untitled

a guest
Apr 7th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. #+TITLE: Dev-Team
  2.  
  3. * All Dev People
  4. #+NAME: people-tbl
  5. | First | Last | Team | Slack | Mail |
  6. |-----------+-----------+--------+------------+----------------|
  7. | Han | Solo | Falcon | @han | han.solo |
  8. | Luke | Skywalker | Jedi | @luke | luke.skywalker |
  9. | Darth | Vader | Sith | @darth | darth.vader |
  10. | Princess | Leia | Falcon | @leia | princess.leia |
  11. | Master | Yoda | Jedi | @yoda | master.yoda |
  12. | Imperator | Palpatine | Sith | @imperator | palpatine |
  13. * E-Mail / Calendar
  14. ** All people
  15. #+BEGIN_SRC emacs-lisp :results raw drawer :var people=people-tbl by-team=by-team email-list=email-list
  16. (email-list people)
  17. #+END_SRC
  18.  
  19. #+RESULTS:
  20. :RESULTS:
  21. Han Solo <han.solo@example.org>, Luke Skywalker <luke.skywalker@example.org>, Darth Vader <darth.vader@example.org>, Princess Leia <princess.leia@example.org>, Master Yoda <master.yoda@example.org>, Imperator Palpatine <palpatine@example.org>
  22. :END:
  23.  
  24. ** All people filtered by a team
  25. #+BEGIN_SRC emacs-lisp :results raw drawer :var people=people-tbl by-team=by-team email-list=email-list
  26. (email-list (by-team 'Jedi people))
  27. #+END_SRC
  28.  
  29. #+RESULTS:
  30. :RESULTS:
  31. Luke Skywalker <luke.skywalker@example.org>, Master Yoda <master.yoda@example.org>
  32. :END:
  33.  
  34. * Slack
  35. ** All people
  36. #+BEGIN_SRC emacs-lisp :results raw drawer :var people=people-tbl by-team=by-team slack-list=slack-list
  37. (slack-list people)
  38. #+END_SRC
  39.  
  40. #+RESULTS:
  41. :RESULTS:
  42. @han, @luke, @darth, @leia, @yoda, @imperator
  43. :END:
  44.  
  45. ** All people filtered by a team
  46. #+BEGIN_SRC emacs-lisp :results raw drawer :var people=people-tbl by-team=by-team slack-list=slack-list
  47. (slack-list (by-team 'Jedi people))
  48. #+END_SRC
  49.  
  50. #+RESULTS:
  51. :RESULTS:
  52. @luke, @yoda
  53. :END:
  54. * Helper functions
  55. Filter the table by team
  56. #+NAME: by-team
  57. #+BEGIN_SRC emacs-lisp :tangle no
  58. (defun by-team (team people)
  59. (seq-filter (lambda (x) (string-equal (nth 2 x) team)) people)
  60. )
  61. #+END_SRC
  62.  
  63. Format the names as email or calendar receipients
  64. #+NAME: email-list
  65. #+BEGIN_SRC emacs-lisp
  66. (defun email-list (people)
  67. (let* (
  68. (output-fmt "%s %s <%s@example.org>")
  69. (format-members (lambda (x)
  70. (format output-fmt (nth 0 x) (nth 1 x) (nth 4 x))
  71. ))
  72. (formatted (mapcar format-members people)))
  73.  
  74. (mapconcat 'identity formatted ", ")
  75. )
  76. )
  77. #+END_SRC
  78.  
  79. Format the names as slack mentions
  80. #+NAME: slack-list
  81. #+BEGIN_SRC emacs-lisp
  82. (defun slack-list (people)
  83. (let* (
  84. (format-members (lambda (x)
  85. (format "%s" (nth 3 x))
  86. ))
  87. (formatted (mapcar format-members people)))
  88.  
  89. (mapconcat 'identity formatted ", ")
  90. )
  91. )
  92. #+END_SRC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement