[elpa] master 77b60ce 1/2: packages/let-alist: Enable access to deeper alists

2014-12-20 Thread Artur Malabarba
branch: master
commit 77b60ce4aa135d3a08af0bbdce695b5aff112d8d
Author: Artur Malabarba 
Commit: Artur Malabarba 

packages/let-alist: Enable access to deeper alists
---
 packages/let-alist/let-alist.el |   77 +--
 1 files changed, 58 insertions(+), 19 deletions(-)

diff --git a/packages/let-alist/let-alist.el b/packages/let-alist/let-alist.el
index 2efa027..692beba 100644
--- a/packages/let-alist/let-alist.el
+++ b/packages/let-alist/let-alist.el
@@ -4,7 +4,7 @@
 
 ;; Author: Artur Malabarba 
 ;; Maintainer: Artur Malabarba 
-;; Version: 1.0.1
+;; Version: 1.0.2
 ;; Keywords: extensions lisp
 ;; Prefix: let-alist
 ;; Separator: -
@@ -39,21 +39,25 @@
 ;;   (let-alist alist
 ;; (if (and .title .body)
 ;; .body
-;;   .site))
+;;   .site
+;;   .site.contents))
 ;;
-;; expands to
+;; essentially expands to
 ;;
 ;;   (let ((.title (cdr (assq 'title alist)))
-;; (.body (cdr (assq 'body alist)))
-;; (.site (cdr (assq 'site alist
+;; (.body  (cdr (assq 'body alist)))
+;; (.site  (cdr (assq 'site alist)))
+;; (.site.contents (cdr (assq 'contents (cdr (assq 'site alist))
 ;; (if (and .title .body)
 ;; .body
-;;   .site))
+;;   .site
+;;   .site.contents))
+;;
+;; If you nest `let-alist' invocations, the inner one can't access
+;; the variables of the outer one. You can, however, access alists
+;; inside the original alist by using dots inside the symbol, as
+;; displayed in the example above by the `.site.contents'.
 ;;
-;; Note that only one level is supported.  If you nest `let-alist'
-;; invocations, the inner one can't access the variables of the outer
-;; one.
-
 ;;; Code:
 
 
@@ -70,8 +74,33 @@ symbol, and each cdr is the same symbol without the `.'."
 (list (cons data (intern (replace-match "" nil nil name)))
((not (listp data)) nil)
(t (apply #'append
-(remove nil (mapcar #'let-alist--deep-dot-search data))
+(mapcar #'let-alist--deep-dot-search data)
+
+(defun let-alist--access-sexp (symbol variable)
+  "Return a sexp used to acess SYMBOL inside VARIABLE."
+  (let* ((clean (let-alist--remove-dot symbol))
+ (name (symbol-name clean)))
+(if (string-match "\\`\\." name)
+clean
+  (let-alist--list-to-sexp
+   (mapcar #'intern (nreverse (split-string name "\\.")))
+   variable
+
+(defun let-alist--list-to-sexp (list var)
+  "Turn symbols LIST into recursive calls to `cdr' `assq' on VAR."
+  `(cdr (assq ',(car list)
+  ,(if (cdr list) (let-alist--list-to-sexp (cdr list) var)
+ var
+
+(defun let-alist--remove-dot (symbol)
+  "Return SYMBOL, sans an initial dot."
+  (let ((name (symbol-name symbol)))
+(if (string-match "\\`\\." name)
+(intern (replace-match "" nil nil name))
+  symbol)))
 
+
+;;; The actual macro.
 ;;;###autoload
 (defmacro let-alist (alist &rest body)
   "Let-bind dotted symbols to their cdrs in ALIST and execute BODY.
@@ -83,20 +112,30 @@ For instance, the following code
   (let-alist alist
 (if (and .title .body)
 .body
-  .site))
+  .site
+  .site.contents))
 
-expands to
+essentially expands to
 
   (let ((.title (cdr (assq 'title alist)))
-(.body (cdr (assq 'body alist)))
-(.site (cdr (assq 'site alist
+(.body  (cdr (assq 'body alist)))
+(.site  (cdr (assq 'site alist)))
+(.site.contents (cdr (assq 'contents (cdr (assq 'site alist))
 (if (and .title .body)
 .body
-  .site))"
+  .site
+  .site.contents))
+
+If you nest `let-alist' invocations, the inner one can't access
+the variables of the outer one. You can, however, access alists
+inside the original alist by using dots inside the symbol, as
+displayed in the example above."
   (declare (indent 1) (debug t))
-  `(let ,(mapcar (lambda (x) `(,(car x) (cdr (assq ',(cdr x) ,alist
- (delete-dups (let-alist--deep-dot-search body)))
- ,@body))
+  (let ((var (gensym "alist")))
+`(let ((,var ,alist))
+   (let ,(mapcar (lambda (x) `(,(car x) ,(let-alist--access-sexp (car x) 
var)))
+   (delete-dups (let-alist--deep-dot-search body)))
+ ,@body
 
 (provide 'let-alist)
 



[elpa] master aea4c15 2/2: Merge branch 'master' of git+ssh://git.sv.gnu.org/srv/git/emacs/elpa

2014-12-20 Thread Artur Malabarba
branch: master
commit aea4c15472a71b08b003320006f888c693b8f4b8
Merge: 77b60ce 96e61a9
Author: Artur Malabarba 
Commit: Artur Malabarba 

Merge branch 'master' of git+ssh://git.sv.gnu.org/srv/git/emacs/elpa
---
 externals-list|1 +
 packages/darkroom/darkroom.el |  375 +
 packages/temp-buffer-browse/temp-buffer-browse.el |5 +-
 3 files changed, 379 insertions(+), 2 deletions(-)

diff --git a/externals-list b/externals-list
index 252c5da..19b5af1 100644
--- a/externals-list
+++ b/externals-list
@@ -23,6 +23,7 @@
  ("chess"  :external nil) ;; Was 
https://github.com/jwiegley/emacs-chess.git
  ("coffee-mode":subtree 
"https://github.com/defunkt/coffee-mode";)
  ("company":subtree 
"https://github.com/company-mode/company-mode.git";)
+ ("darkroom":subtree 
"https://github.com/capitaomorte/darkroom.git";)
  ("diff-hl":subtree "https://github.com/dgutov/diff-hl.git";)
  ("dismal" :external nil)
  ("easy-kill"  :subtree "https://github.com/leoliu/easy-kill";)
diff --git a/packages/darkroom/darkroom.el b/packages/darkroom/darkroom.el
new file mode 100644
index 000..45eaf9d
--- /dev/null
+++ b/packages/darkroom/darkroom.el
@@ -0,0 +1,375 @@
+;;; darkroom.el --- Remove visual distractions and focus on writing  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2014  Free Software Foundation, Inc.
+
+;; Author: João Távora 
+;; Maintainer: João Távora 
+;; Keywords: convenience, emulations
+;; Package-Requires: ((cl-lib "0.5"))
+;; Version: 0.1
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see .
+
+;;; Commentary:
+
+;; The main entrypoints to this extension are two minor modes:
+;;
+;;M-x darkroom-mode
+;;M-x darkroom-tentative-mode
+;;
+;; `darkroom-mode' makes visual distractions disappear: the
+;; mode-line is temporarily elided, text is enlarged and margins are
+;; adjusted so that it's centered on the window.
+;;
+;; `darkroom-tentative-mode' is similar, but it doesn't immediately
+;; turn-on `darkroom-mode', unless the current buffer lives in the
+;; sole window of the Emacs frame (i.e. all other windows are
+;; deleted). Whenever the frame is split to display more windows and
+;; more buffers, the buffer exits `darkroom-mode'. Whenever they are
+;; deleted, the buffer re-enters `darkroom-mode'.
+;;
+;; Personally, I always use `darkroom-tentative-mode'.
+;;
+;; See also the customization options `darkroom-margins' and
+;; `darkroom-fringes-outside-margins', which affect both modes.
+
+;;; Code:
+
+(require 'cl-lib)
+
+(defgroup darkroom nil
+  "Remove visual distractions and focus on writing"
+  :prefix "darkroom-"
+  :group 'emulations)
+
+(defcustom darkroom-margins 'darkroom-guess-margins
+  "Margins to use in `darkroom-mode'.
+
+Its value can be:
+
+- a floating point value betweeen 0 and 1, specifies percentage of
+  window width in columns to use as a margin.
+
+- a cons cell (LEFT RIGHT) specifying the left and right margins
+  in columns.
+
+- a function of a single argument, a window, that returns a cons
+  cell interpreted like the previous option. An example is
+  `darkroom-guess-margins', which see. Beware that this function
+  is called very often, so if it does some non-trivial processing
+  on the buffer's text, consider caching that value.
+
+Value is effective when `darkroom-mode' is toggled."
+  :type '(choice float
+ (cons integer integer)
+ (function-item darkroom-guess-margins :doc "Guess margins")
+ (function darkroom-guess-margins))
+  :group 'darkroom)
+
+(defcustom darkroom-text-scale-increase 2
+  "Steps to increase text size when in `darkroom-mode'.
+Value is passed to `text-scale-increase'."
+  :type 'integer
+  :group 'darkroom)
+
+(defcustom darkroom-fringes-outside-margins t
+  "If non-nil use fringes outside margins for `darkroom-mode'"
+  :type 'boolean
+  :group 'darkroom)
+
+(defcustom darkroom-margin-increment 0.05
+  "Increment to add used in `darkroom-increase-margins'."
+  :type 'float
+  :group 'darkroom)
+
+(defcustom darkroom-margins-if-failed-guess 0.15
+  "Margins when `darkroom-guess-margins' fails.
+If `darkroom-guess-margins' failed to figure out margins to
+center the text, use this percentage of window width for the
+symmetical margins."
+  :typ