This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-06
Channels
- # bangalore-clj (2)
- # beginners (55)
- # boot (32)
- # bristol-clojurians (4)
- # cider (16)
- # clara (13)
- # cljsrn (6)
- # clojure (110)
- # clojure-india (1)
- # clojure-italy (69)
- # clojure-spec (32)
- # clojure-uk (15)
- # clojurescript (102)
- # community-development (6)
- # cursive (1)
- # datomic (9)
- # docs (2)
- # duct (1)
- # emacs (39)
- # events (3)
- # fulcro (131)
- # garden (1)
- # immutant (4)
- # jobs (1)
- # jobs-discuss (5)
- # keechma (1)
- # lein-figwheel (6)
- # leiningen (6)
- # mount (6)
- # nrepl (2)
- # off-topic (69)
- # om (54)
- # parinfer (7)
- # re-frame (63)
- # reagent (13)
- # remote-jobs (1)
- # shadow-cljs (90)
- # spacemacs (8)
- # specter (6)
- # sql (16)
- # testing (1)
- # unrepl (3)
- # vim (4)
- # yada (1)
in particular, I want to rewrite the following in elisp:
(defmacro do [& args]
`(progn ~@args))
@qqq https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/macroexp.el#L320
in Emads, what is the fastest way o find all lines that match a particular regex? I'm looking for all lines that start with
;; *
;; **
;; ***
;; ****
to generate a TOC of sorts. All solutions on SO basically show using find-next-regexp repeatedly until end of buffer.
Is there a better solution ?no idea, but you can look at occur
s source to search for insights: https://github.com/emacs-mirror/emacs/blob/master/lisp/replace.el#L1394
@qqq if you’re doing this in org-mode, there is already a way to generate TOC https://orgmode.org/manual/Table-of-contents.html
What does the matches
in the let form of
(defun re-seq (regexp string)
"Get a list of all regexp matches in a string"
(save-match-data
(let ((pos 0)
matches)
(while (string-match regexp string pos)
(push (match-string 0 string) matches)
(setq pos (match-end 0)))
matches)))
mean ?@bostonaholic: I'm working on something custom where I pipe it to ivy
emacs lisp allows for a binding pair, or just a symbol which means it is bound to nil
the matches
is short for (matches nil)
yeah, what @dpsutton said
@dpsutton, @bostonaholic: thanks!
you can also test it out yourself by evaluating
(let ((pos 0)
matches)
matches)
that expression returns nil
clojure has a builtin of a hashmap; does emacs have anything similar for storing 'structs' ?
http://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Hash.html#Creating-Hash
depending on size alist can be faster and easier. hashmaps have some overhead and can be overkill for simple things
'((1 2 3) (4 5 6) (7 8 9))
==> (3 6 9)
how do I write a ELISP function that does that? I've tried
(map #'caddr lst)
already, but it doesn't work as map wants 3 argumentsif you happen to have dash.el (which you probably do, lots of libraries use it) you can just use the functions you expect map
, filter
, reduce
and their friends prefixed with a dash and they will work roughly like the functions you expect
(defun heading-keep? (s)
(not (string-match "[ *=]*" s)))
(heading-keep? "=====")
(heading-keep? "* =====")
(heading-keep? "hello world")
I expect the response to be false false true, but I get nil nil nil
basicaly, I want to keep all headings, except those made of the chars space, star, equal-signbtw, +
instead of *
will make a difference for empty strings. using *
will return t
and with +
will return nil
. idk what your requirements are in this case
(defmacro do (&rest exps)
`(progn ,@exps) )
^-- what is wrong with this macro? I'm trying to make do
an alias to progn
(loses less space to nested indentations)it does have a do
, but I don't think it does the same as progn
/ Clojure do
(if memory serves, it's more like do-while
)
but because it does already have that macro, re-defining it with a different meaning will cause breakage with any packages that use the original macro
What's wrong with just using progn
?
There's nothing wrong with progn
; I just was not aware do
was a builtin, and wanted to use it.
fair enough, I have done many things in emacs "just because" 🙂