Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add `-defun' #347

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open

Add `-defun' #347

wants to merge 32 commits into from

Commits on Nov 6, 2020

  1. Add `-defun'

    `-defun' is like `-lambda', but with destructuring. To implement it, abstract
    the arglist and form generation code of `-lambda' into separate functions.
    
    Additional benefits of the refactoring are:
    
    - `-lambda' (and by extension, `-defun') can now accept empty argument lists
    - `-lambda' (and `-defun') no longer rebinds symbols (fixing the TODO)
    
    Various declaration forms should be handled properly in `-defun'.
    
    Motivation: when this is merged, `lsp-defun' can be made an alias for `-defun'.
    nbfalcon committed Nov 6, 2020
    Configuration menu
    Copy the full SHA
    f3f29e3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6add372 View commit details
    Browse the repository at this point in the history
  3. Add examples for `-defun'

    nbfalcon committed Nov 6, 2020
    Configuration menu
    Copy the full SHA
    3a63e45 View commit details
    Browse the repository at this point in the history
  4. -defun', -lambda': support &optional and &rest

    - Add a `-defun' &rest example.
    - `-defun': add (declare debug), making it debuggable
    nbfalcon committed Nov 6, 2020
    Configuration menu
    Copy the full SHA
    727df5c View commit details
    Browse the repository at this point in the history
  5. Fix `-defun' &rest example

    nbfalcon committed Nov 6, 2020
    Configuration menu
    Copy the full SHA
    379e48c View commit details
    Browse the repository at this point in the history
  6. -lambda': support declare-forms; add -defmacro'

    Refactor `dash--destructure-body' to handle declarations and docstrings itself,
    meaning that more code can be shared between `-lambda' and `-defun'.
    
    Refactor `dash--destructure-body' to add signatures to the docstring of BODY if
    necessary. This means that docstrings for `-defun' and `-lambda', ... now
    generate functions with proper signatures.
    
    Add `-defmacro', which is like `-defun' but as a macro.
    nbfalcon committed Nov 6, 2020
    Configuration menu
    Copy the full SHA
    24850aa View commit details
    Browse the repository at this point in the history
  7. Improve docstrings

    nbfalcon committed Nov 6, 2020
    Configuration menu
    Copy the full SHA
    2e989aa View commit details
    Browse the repository at this point in the history
  8. Fix edebug specs

    nbfalcon committed Nov 6, 2020
    Configuration menu
    Copy the full SHA
    03186e0 View commit details
    Browse the repository at this point in the history
  9. Optimize &as bindings

    For &as bindings, don't generate input<n> parameters but use the names
    in the corresponding functions directly.
    
    (-lambda ((sym &as &DocumentSymbol :detail?))) -> (lambda (sym) (-let ...))
    nbfalcon committed Nov 6, 2020
    Configuration menu
    Copy the full SHA
    6a87bae View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    95462fc View commit details
    Browse the repository at this point in the history
  11. `-defun', ...: optimize &as bindings in vectors

    &as bindings would generate paramters for lists already. Now do the same
    for destructured vectors, too.
    nbfalcon committed Nov 6, 2020
    Configuration menu
    Copy the full SHA
    c4ffe96 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2020

  1. Configuration menu
    Copy the full SHA
    6f2626f View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2020

  1. Fix byte-compile error(s)

    For some reason, using `-let' in `dash--destructure-body' caused compile-errors
    when running the tests. Use `let*' + manual destructuring instead, fixing the
    error and making the test suite pass.
    nbfalcon committed Nov 13, 2020
    Configuration menu
    Copy the full SHA
    bcfd26a View commit details
    Browse the repository at this point in the history
  2. `-defmacro': add example

    nbfalcon committed Nov 13, 2020
    Configuration menu
    Copy the full SHA
    fd53121 View commit details
    Browse the repository at this point in the history

Commits on Nov 26, 2020

  1. dash--destructure-body': optimize: use -let*'

    `-let*' generates less bytecode than `-let', even if otherwise equivalent,
    because the latter is implemented in terms of the former, with many temporaries.
    This is exacerbated when using dynamic binding, because all of those variables
    also need to be bound dynamically.
    
    Add a TODO note because this is an implementation detail; `-let' needs to be
    optimized independently.
    nbfalcon committed Nov 26, 2020
    Configuration menu
    Copy the full SHA
    92e623f View commit details
    Browse the repository at this point in the history
  2. `dash--destructure-arglist': docstring generation

    No longer generate a redundant nil in `-defun' and `-defmacro', if no docstring
    is provided and the arglist doesn't use destructuring.
    
    This was due to a bug in `dash--destructure-body' only triggered in that case
    with NODOC=nil.
    nbfalcon committed Nov 26, 2020
    Configuration menu
    Copy the full SHA
    23749b3 View commit details
    Browse the repository at this point in the history
  3. Fix edebug specs: debugging `-defun'

    Use `def-body', as is used in `cl-defun', allowing `-defun' to be
    debugged.
    nbfalcon committed Nov 26, 2020
    Configuration menu
    Copy the full SHA
    6afe446 View commit details
    Browse the repository at this point in the history
  4. `-defun', ...: improve error handling

    Before this PR, a `wrong-type-argument' error was issued if the match-form
    wasn't of appropriate type. Restore this behavior by `signal'ing this way again
    if the arglist is of incorrect type.
    nbfalcon committed Nov 26, 2020
    Configuration menu
    Copy the full SHA
    376acdb View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    34d618b View commit details
    Browse the repository at this point in the history

Commits on Dec 30, 2020

  1. -lambda': don't interpret declare'

    For `lambda', `declare' is ignored. Do the same in `-lambda', allowing a
    `-lambda' that starts with `declare' to be debugged.
    
    To implement this, extend `dash--decompose-defun-body' to take an optional
    DECLARE? parameter that determines whether `declare' is supported in addition to
    `interactive'.
    
    Note that macros can still be `interactive'. This is consistent with
    `cl-defmacro', which doesn't put the first `interactive' in `cl-block'.
    nbfalcon committed Dec 30, 2020
    Configuration menu
    Copy the full SHA
    79a71d6 View commit details
    Browse the repository at this point in the history
  2. `dash-lamba-list': remove TODO

    It would be a waste of time to implement a proper edebug spec for it, since
    `dash''s destructuring logic is very complex and extensible. In addition, this
    would make extending `dash''s destructuring logic harder.
    nbfalcon committed Dec 30, 2020
    Configuration menu
    Copy the full SHA
    30a0de5 View commit details
    Browse the repository at this point in the history

Commits on Jan 6, 2021

  1. -defun', ...: use make-symbol'

    The input<n> temporaries used in the generated function's arglists are now
    uninterned symbols, preventing users of `-defun', `-lambda', ... from accessing
    them.
    
    To implement this, a new intermediate step was added: `dash--parse-arglist'
    extracts variable bindings from a given arglist, and `dash--destructure-arglist'
    (formerly `dash--make-arglist') and `dash--destructure-body' now also take the
    result of the first function. This needed because uninterned symbols need to be
    communicated to these functions.
    
    Additional benefits of the new intermediate step are that
    `dash--destructure-body' no longer needs to know anything about how the arglist
    looks like and that there is no part of `dash' needs to know anything about
    `lambda', `defun', ... keywords.
    nbfalcon committed Jan 6, 2021
    Configuration menu
    Copy the full SHA
    e0fb5d5 View commit details
    Browse the repository at this point in the history
  2. `dash--as-matcher?': destructure directly

    As of the previous commit, `dash--matcher?' only has one user,
    `dash--parse-arglist'. Refactor the former to now also do destructuring,
    yielding a better API and reducing code, as `dash--as-matcher-variable' and
    `dash--as-matcher-tail' could be eliminated.
    nbfalcon committed Jan 6, 2021
    Configuration menu
    Copy the full SHA
    2f9fc8c View commit details
    Browse the repository at this point in the history
  3. `dash--as-matcher?': [x &as] is not an as-matcher

    `-let' treats [x &as] as destructuring a vector of two elements, `x' and `&as',
    while `dash--as-matcher?' would treat it as x being destructured like the empty
    vector. Fix that by constraining vector matchers to be of at least length 3.
    nbfalcon committed Jan 6, 2021
    Configuration menu
    Copy the full SHA
    148a833 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    83a3c12 View commit details
    Browse the repository at this point in the history

Commits on Jan 7, 2021

  1. `dash--destructure-body': DOC -> ARGLIST

    As of shared arglist parsing refactoring, ARGLIST was only used to compute the
    docstring. Remove DOC, and make ARGLIST in its place imply that a docstring is
    to be generated.
    nbfalcon committed Jan 7, 2021
    Configuration menu
    Copy the full SHA
    bcc9763 View commit details
    Browse the repository at this point in the history
  2. `dash--decompose-defun-body': drop DECLARE?

    (command-execute (lambda () (declare) (interactive))) works, so all declarations
    must be parsed. This function now behaves similar to `macroexp-parse-body',
    except that the last form is not treated as the body, so that (-lambda ()
    (interactive)) works.
    nbfalcon committed Jan 7, 2021
    Configuration menu
    Copy the full SHA
    caf7445 View commit details
    Browse the repository at this point in the history
  3. `-defun', .... reduce code duplication

    Abstract the common parts of `-defun', `-lambda', etc. into the new function,
    `dash--defun'.
    nbfalcon committed Jan 7, 2021
    Configuration menu
    Copy the full SHA
    7895a2b View commit details
    Browse the repository at this point in the history
  4. Drop `dash--docstring-add-signature'

    `help-add-fundoc-usage', from the pre-loaded `help' library, is more robust (it
    properly handles quotes), so use that.
    nbfalcon committed Jan 7, 2021
    Configuration menu
    Copy the full SHA
    9ac1487 View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2021

  1. dash--decompose-defun-body': behave like defun'

    If a `defun' contains only a single string in the body, that string is
    considered both result and docstring. Do the same for `-defun'. This patch also
    makes that function parse a `-defun' whose body consists only of strings
    correctly.
    
    Add regression tests.
    nbfalcon committed Mar 22, 2021
    Configuration menu
    Copy the full SHA
    d8cab22 View commit details
    Browse the repository at this point in the history
  2. Fix square-bracket arguments

    `dash--normalize-arglist' should wrap them in another list. Add a
    regression test.
    nbfalcon committed Mar 22, 2021
    Configuration menu
    Copy the full SHA
    8ac91de View commit details
    Browse the repository at this point in the history
  3. Improve examples

    Only 3 examples are shown in the manual, so move the various cons adding
    examples later since they are not helpful. As such, show an `interactive'
    example, a Docstring result example and a square bracket args example.
    
    Rename `example/add-cons' -> `example/interactive'.
    nbfalcon committed Mar 22, 2021
    Configuration menu
    Copy the full SHA
    66f513e View commit details
    Browse the repository at this point in the history