• 0 Posts
  • 21 Comments
Joined 1 year ago
cake
Cake day: October 4th, 2023

help-circle





  • (add-variable-watcher 'autosave-toggle
                          #'(lambda (_ value _ _)
                              (if value (autosave-setup) (autosave-teardown))))
    

    Don’t add an anonymous function. It will make it harder to remove. Better yet, implement this as a minor-mode.

    (defvar autosave-delay-interval 1
      "The amount of time to wait before autosaving after a change has occurred.")
    (defvar autosave-exclude-buffer-list
      '("COMMIT_EDITMSG" "treemacs-persist")
      "List of buffers to exclude from autosaving")
    (defvar autosave-immediate-save-functions-list
      '(switch-to-buffer other-window windmove-up windmove-down windmove-left windmove-right next-buffer previous-buffer)
      "A list of functions which trigger an immediate save")
    (defvar autosave-immediate-save-hooks-list
      '(mouse-leave-buffer-hook focus-out-hook)
      "A list of hooks which trigger an immediate save")
    

    These should be user options defined via defcustom

    (defmacro advice-add-list (advice-list how function)
      "Add list of advice to given function using the how parameter"
      `(dolist (advice ,advice-list)
         (advice-add advice ,how ,function)))
    (defmacro advice-remove-list (advice-list function)
      "Remove list of advice from given function using the how parameter"
      `(dolist (advice ,advice-list)
         (advice-remove advice ,function)))
    (defmacro add-hooks (hook-list function)
      "Add list of hooks to given function"
      `(dolist (hook ,hook-list)
        (add-hook hook ,function)))
    (defmacro remove-hooks (hook-list function)
      "Remove list of hooks from given function"
      `(dolist (hook ,hook-list)
        (remove-hook hook ,function)))
    

    These should be functions instead of macros. They should also be prefixed with your package’s “namespace”.


  • nv-elisp@alien.topBtoEmacs@communick.newsRate my elisp
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    You don’t have anything to guard against a bad response from the server. e.g.

    (unless (equal url-http-response-status 200)
      (error "Server responded with status: %S" url-http-response-status))
    

    To position point at the end of the headers:

    (goto-char url-http-end-of-headers)
    

    This:

    (setq result (cons (cons ...) result))
    

    Is more clearly expressed as:

    (push (cons ...) result)
    

    Better yet, you could map over the elements you’re interested in and accumulate the results via mapcar or cl-loop. That would obviate the need for the “results” variable.

    You could probably shorten things by using the dom-elements function to directly search for the href’s you’re interested in in combination with dom-parent to get at the parent elements.

    Overall your function gets a 65 out of 130 ERU (elisp rating units).












  • Seems over-complicated. Most of the “modules” amount to:

    ;;install package
    ;;require package
    ;;provide named feature for module
    

    How is that any better than a single file with some use-package declarations? Especially considering you’re using a literate Org style. The blocks could be toggled with the “tangle” header arg. The Papa Roach Approach (“Cut my lisp; init pieces…this is my last resort!!!”) is an anti-pattern. It makes Emacs load slower and is harder to reason about. If the aim is to grow a community of users, what does this config offer over the myriad other options?