From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Klaus-Dieter Bauer Newsgroups: gmane.emacs.help Subject: Emacs Lisp: Indentation of higher order functions? Date: Tue, 9 Sep 2014 14:22:55 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1410265435 11480 80.91.229.3 (9 Sep 2014 12:23:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Sep 2014 12:23:55 +0000 (UTC) To: emacs help Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 09 14:23:47 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XRKSY-000832-Hi for geh-help-gnu-emacs@m.gmane.org; Tue, 09 Sep 2014 14:23:46 +0200 Original-Received: from localhost ([::1]:49335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRKSY-0003jL-3Q for geh-help-gnu-emacs@m.gmane.org; Tue, 09 Sep 2014 08:23:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRKSJ-0003jA-VL for help-gnu-emacs@gnu.org; Tue, 09 Sep 2014 08:23:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRKSE-000810-Tj for help-gnu-emacs@gnu.org; Tue, 09 Sep 2014 08:23:31 -0400 Original-Received: from mail-vc0-x232.google.com ([2607:f8b0:400c:c03::232]:55602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRKSE-00080d-ND for help-gnu-emacs@gnu.org; Tue, 09 Sep 2014 08:23:26 -0400 Original-Received: by mail-vc0-f178.google.com with SMTP id hy4so2221451vcb.37 for ; Tue, 09 Sep 2014 05:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=jHqjpLjUWTDkhhzhFF1UCdukdBJx3Ut/zEC54pZrup0=; b=CL7rPRaVrMju4ZxNA7RU8eEg2raNn6DDU6XlNAMhOPlX6H32s3P2kDVWY9MC3cezOE NzScPCZomwDQA/PdnxTZ0qtAibvFst70MnIYsV8QsIkUwifQ4J80RH6YZ1J2mhCeoh0G yx0FvSaDLTQxgIHUD0aMNN/fz91nm+fxfm9hGKOShKXLGCgAKFNjNKpJaJYenz8mPIIJ Ma6EKM97+ToARtV2Di6/tS+aRFYP2vMn+sw1SPYDqMHGHtDjGLUab7Zrli2+XfkuQKCg FUH76woOicQD8K5pGFaLvEydiNMmh6/yuoshnnEj8//ZBvK/2UcOzemnpBzk5nBeNTkr nWtA== X-Received: by 10.220.114.5 with SMTP id c5mr15261007vcq.28.1410265405899; Tue, 09 Sep 2014 05:23:25 -0700 (PDT) Original-Received: by 10.220.202.10 with HTTP; Tue, 9 Sep 2014 05:22:55 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c03::232 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:99727 Archived-At: Hello! I was wondering about the indentation rules of higher order functions in emacs-lisp. Consider e.g. this case: (let ((incr-string (apply #'string (mapcar #'1+ "Hello World")))) ...) or likewise within the same indentation rules (let ((incr-string (apply #'string (mapcar #'1+ "Hello World")))) ...) In emacs lisp higher order functions typically don't declare special indentation rules. The result however is that chaining higher order functions often becomes highly verbose in terms of whitespace, using either unnecessarily much space vertically or horizontally, subjectively making the code harder to read. As far as I understand, the 2-column indentation is intended to signify "this is going to be executed as a code block" while a 4-column indentation should signify "this is a special argument to the special form" and hence assigning (declare (indent 1)) would conflict with formatting expectations. Yet the verbosity of nested function calls seems like a relevant disadvantage. Personally I tried using a file-variable `lisp-indent-offset:2', but this breaks formatting of `let' type forms and multil-ine alist-constants, resulting in an awkward distinction of indentation between the first and further elements and would likely make the code less readable to others. For some time I thus changed the `lisp-indent-function' entry for know higher-order functions through code in my .emacs file, but this leads to the same problems (and would harm when changing another person's emacs lisp code by not being file-specific). What is the proper way to deal with such situations in emacs lisp? regards, Klaus