From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 10 12:43:53 2014 Received: (at submit) by debbugs.gnu.org; 10 Dec 2014 17:43:53 +0000 Received: from localhost ([127.0.0.1]:41885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XylIm-0002t2-M7 for submit@debbugs.gnu.org; Wed, 10 Dec 2014 12:43:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45448) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xyl0Y-0002NC-Gj for submit@debbugs.gnu.org; Wed, 10 Dec 2014 12:25:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xyl0S-0003Eq-Ds for submit@debbugs.gnu.org; Wed, 10 Dec 2014 12:24:57 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyl0S-0003Ej-BI for submit@debbugs.gnu.org; Wed, 10 Dec 2014 12:24:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyl0R-0003A8-6d for bug-gnu-emacs@gnu.org; Wed, 10 Dec 2014 12:24:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xyl0Q-0003C0-5f for bug-gnu-emacs@gnu.org; Wed, 10 Dec 2014 12:24:55 -0500 Received: from mail-ie0-x232.google.com ([2607:f8b0:4001:c03::232]:34844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyl0Q-0003Bs-07 for bug-gnu-emacs@gnu.org; Wed, 10 Dec 2014 12:24:54 -0500 Received: by mail-ie0-f178.google.com with SMTP id tp5so3036591ieb.23 for ; Wed, 10 Dec 2014 09:24:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=lul0LGXwX6efUCxrR1EXSiwA47p9oHVQTYDdN0crSZE=; b=AFw6YedT/tdlr2+p7FrfhdINV+ISBn/uPcDNj57DXTkjsQbXIdaapsw9CkD5OvEvUq jMmSnCfb4DBVJr7q9IEuHjVjzIDjWX0gsZMbZgbFzR6sVWl3Q2AorgNo5s9in5eemk8x HxKRdl688PGW7i2Wa6F/8c8UWDUbL63b2JXO5MznwVUO5Au8uzvmj/Kd207ZLNUBdnZJ mjAYT3g+pkMP2mupBXAWMVoaZXKcR7xWUdKjP5w7qL+wBf72ZZEh3LZTw2evVGNcj+fB xjGklRudneSA23cdmYbJw++yKMyNNMiqXl1rmHfpV7Z7Dq6LuhNIB3cCOQbAI5EoQLQB I0+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=lul0LGXwX6efUCxrR1EXSiwA47p9oHVQTYDdN0crSZE=; b=nLO6qjK8CEWroZZA44S2kdtALz5+3LO4reuTK4lD7AzJzOzWu0cBkD/t/iXPinR6vh rQG9OVPzV47soJjvktw3+CmK+bYU3xhxn4MICFv84GlyFiUrQrehHSdnra87w77uHJNW XgYNsrU/gnDy16oZAMqdo+IvzzqOly8VeTM6HEUmQ7xabrhYp8zrS+1pWW58UBZE0G7E b0Zxb/FJS0iEcz/qO2NFenKNKGQ+6RNN5jFuSap4gPgEBO/Cu85mHpWOWwd4iZyZjgDb +kVGVng8AwlTfApQLrKTwSq4Tdkq1wYKFT4CoiAuwr5ZYypVZ5XcfewlLuLonxCTCqiB 4CXw== X-Gm-Message-State: ALoCoQlo8MIYKS//TYQPTvgcR+WUE5m9+FRNlMDBO8bYD4N/Q4Bl/5Paa5Lheg4UZmowQbe7I5iG X-Received: by 10.50.117.71 with SMTP id kc7mr9151861igb.35.1418232293404; Wed, 10 Dec 2014 09:24:53 -0800 (PST) Received: from mpn-glaptop.corp.google.com ([2620:0:105f:310:381f:eb80:e0ce:71dc]) by mx.google.com with ESMTPSA id jg3sm7550613igb.12.2014.12.10.09.24.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Dec 2014 09:24:53 -0800 (PST) From: Michal Nazarewicz To: bug-gnu-emacs@gnu.org Subject: [PATCH 0/3] Implement an ElDoc function which describes char at point Date: Wed, 10 Dec 2014 18:24:40 +0100 Message-Id: <1418232280-16915-1-git-send-email-mpn@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 10 Dec 2014 12:43:50 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) From: Michal Nazarewicz `describe-char-eldoc' displays information about character at point, and can be used as a default value of `eldoc-documentation-function'. It is useful when, for example, one needs to distinguish various spaces (e.g. ] [, ] [, ] [, etc.) while using mono-spaced font. Michal Nazarewicz (3): eldoc: use default eldoc function if local one gives no results descr-text: add `describe-char-eldoc' describing character at point eldoc: convert `eldoc-documentation-function' into a defcustom etc/NEWS | 10 +++- lisp/descr-text.el | 96 +++++++++++++++++++++++++++++++++++++++ lisp/emacs-lisp/eldoc.el | 20 ++++++-- test/automated/descr-text-test.el | 94 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 214 insertions(+), 6 deletions(-) create mode 100644 test/automated/descr-text-test.el -- 2.2.0.rc0.207.ga3a616c From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 10 12:53:37 2014 Received: (at 19338) by debbugs.gnu.org; 10 Dec 2014 17:53:37 +0000 Received: from localhost ([127.0.0.1]:41932 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XylSC-0003AY-RT for submit@debbugs.gnu.org; Wed, 10 Dec 2014 12:53:37 -0500 Received: from mail-wg0-f51.google.com ([74.125.82.51]:39422) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XylOc-00033e-JM for 19338@debbugs.gnu.org; Wed, 10 Dec 2014 12:49:55 -0500 Received: by mail-wg0-f51.google.com with SMTP id x12so4318739wgg.10 for <19338@debbugs.gnu.org>; Wed, 10 Dec 2014 09:49:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id; bh=iMQzmyyvQy3BaBE1wBMhfsZfdCsDa2N6AFryJGPs+vE=; b=gjzoUsqNjuxbHJomk4vccyzx6x5bbXi8l2/hYf5qu42+HFX5PUGqRhzFV2nu++4RBW VPSfS2Q7g2ya0oY+po6Ixgdq8w8S5rM8qrS6LYcDc0z2Ro0K51rAKZkH7iin7gVJ4ESV JHrnynqq6M5gQuei1XGg4pvBJyWKrs9ZFsWm2x/+m0jNYPw259wokB7I0jiOcqyrzGRJ 5eG8gI+n9T6MDmepWmz/gy0M3PPYqc+nFHqClTLECxz8CiqacJSBRMh9glNcCgPDQbtj sQ9Dy4Fy6uYUq/lN5VpWq2MRPc6JkEC1lKRny6+RnQZtVgMhETGfYmNyXlOjdsRXzNxU uDJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=iMQzmyyvQy3BaBE1wBMhfsZfdCsDa2N6AFryJGPs+vE=; b=jAevQAlwnGzIBLzspXXXaXnXyCQAc+HsiVac6JEa4dmkfl64PSLkBl70cR442zsDaU f8W6eB4HdAXcyCV+ZqDosoZTI7A93Re6YR5R8WMLieaNYY0yC+CTdAmlkB1jrrC4dtY/ Rn2WgHHTxTZ3NQYnFnpeLhr2VjFsXAwmi89XUVwPL5eEOJi8CqUostMJXVFYkmTVdLxh GhuWEEmA1qO5CsrnQaYNddPl+IrRTSJwHHzuueJk08AV9KyieRNNjVXXLR/+Xcv3BGA6 18o8DTGdONxZYkjfITVZgZ0qCb8sB+RPXMjYPXgdIKly2aXTcTrhjVig2GKrDErkHSUO izZg== X-Gm-Message-State: ALoCoQmDYhKeUMg2loa9uufJ5b78GO9eBjBS6VupYHPQaMqFtA5Ytng7eRZOm2gje09SCvqbcloJ X-Received: by 10.194.156.201 with SMTP id wg9mr8728845wjb.59.1418233788794; Wed, 10 Dec 2014 09:49:48 -0800 (PST) Received: from mpn-glaptop.corp.google.com ([2620:0:105f:310:381f:eb80:e0ce:71dc]) by mx.google.com with ESMTPSA id ly9sm6744297wjb.24.2014.12.10.09.49.47 for <19338@debbugs.gnu.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Dec 2014 09:49:47 -0800 (PST) From: Michal Nazarewicz To: 19338@debbugs.gnu.org Subject: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results Date: Wed, 10 Dec 2014 18:49:43 +0100 Message-Id: <1418233785-18020-1-git-send-email-mpn@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338 X-Mailman-Approved-At: Wed, 10 Dec 2014 12:53:34 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) From: Michal Nazarewicz * lisp/emacs-lisp/eldoc.el (eldoc-print-current-symbol-info): If local `eldoc-documentation-function' returns no docstring and the variable has a non-nil default value, try it as well. This allows setting up a global documentation function which will still be used if given major mode has its own. --- etc/NEWS | 6 ++++-- lisp/emacs-lisp/eldoc.el | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 407df82..50338cf 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -199,8 +199,10 @@ typing RET. result of the calculation into the current buffer. ** ElDoc -*** New minor mode global-eldoc-mode -*** eldoc-documentation-function now defaults to nil +*** New minor mode `global-eldoc-mode' +*** `eldoc-documentation-function' now defaults to nil +*** Default value of `eldoc-documentation-function now' is consulted if +local function does not return any documentation. ** eww diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 6dddf5b..06ee164 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -345,7 +345,13 @@ This variable is expected to be set buffer-locally by modes that support ElDoc." (when eldoc-last-message (eldoc-message nil) nil)) - (eldoc-message (funcall eldoc-documentation-function))))) + (eldoc-message + (or (funcall eldoc-documentation-function) + ;; If local documentation function did not return anything, try + ;; global one. + (when (local-variable-p 'eldoc-documentation-function) + (let ((func (default-value 'eldoc-documentation-function))) + (when func (funcall func))))))))) ;; When point is in a sexp, the function args are not reprinted in the echo -- 2.2.0.rc0.207.ga3a616c From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 10 12:53:38 2014 Received: (at 19338) by debbugs.gnu.org; 10 Dec 2014 17:53:38 +0000 Received: from localhost ([127.0.0.1]:41934 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XylSD-0003Ab-Ez for submit@debbugs.gnu.org; Wed, 10 Dec 2014 12:53:38 -0500 Received: from mail-wg0-f52.google.com ([74.125.82.52]:39407) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XylOd-00033g-Sb for 19338@debbugs.gnu.org; Wed, 10 Dec 2014 12:49:56 -0500 Received: by mail-wg0-f52.google.com with SMTP id x12so4284316wgg.25 for <19338@debbugs.gnu.org>; Wed, 10 Dec 2014 09:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=5gzbx+eswN4DRlE/AD9bW8/CVlhIyb39naRer7BbSj0=; b=L67xKC/nVJ+e5hCU9I75w9/U4MHX1lb+su+Asq9tnZo1mdDihskondJFBFvEPOqyLc Zt5SMHrgORD7dXQH82U6Dbcfai7c8/Xre3nKSiN04ZSQXRVFUmVp5UMaqdjulHbpiTez RfyDsaMM6inFdpU2xYkx8bfm259rJXRBQGl6qJ4OwnLnBWfyMW2Vkyd5HKrcZOueISo5 ubgOwMmWWh3kJbK9E9pOr/iWEGPu7YA150SHr2CFOOgPaKX7HHbZPMotDFy9tGJ0h2Vj +2gkAHDagwWYg4swwGxZe582hNN0RxEnC5tN41E0ghdlrFKLvjCQ1ZMTAg+BlzrHp5Vy Ai8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=5gzbx+eswN4DRlE/AD9bW8/CVlhIyb39naRer7BbSj0=; b=WUPz38EaCI+/y2Z+58SjmEJeSIodbtukIxKsuI8hCh3fRe5ozvB4oiWZzybdG4uBfV si9VTRYZyG+Zz8en3rNKiRaodlcqZYS/7P56Ybn0Q0ahooT6oPxv4pdV/fWWZlEx/bk7 sOc8rwfq5JROTMKMNYRD1niXNixDVFBF8LaUdRoAJ1i1IoOCNAKO5lcgkEo6z1KAEM7F nqX+OwXh8OXKab6qfAOS14lXslz8mXQjPoiomKlFs81Np3OcFNLGwyLkRHSnZPDaibP+ 8HAXKPwbm07t182eFRPB0qHOd21UWLzvutcdJuOQHTFKLK4ruSU0XVrE5phRRlAVPUvT IGbw== X-Gm-Message-State: ALoCoQlZUFWVWDcJX7bnvv6LrIYV7lNikS6SA07zzSs70J9ldjrNaxw5exPvC1g6jILDvpM1zq7G X-Received: by 10.194.62.19 with SMTP id u19mr9280468wjr.0.1418233790131; Wed, 10 Dec 2014 09:49:50 -0800 (PST) Received: from mpn-glaptop.corp.google.com ([2620:0:105f:310:381f:eb80:e0ce:71dc]) by mx.google.com with ESMTPSA id ly9sm6744297wjb.24.2014.12.10.09.49.48 for <19338@debbugs.gnu.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Dec 2014 09:49:49 -0800 (PST) From: Michal Nazarewicz To: 19338@debbugs.gnu.org Subject: [PATCH 2/3] descr-text: add `describe-char-eldoc' describing character at point Date: Wed, 10 Dec 2014 18:49:44 +0100 Message-Id: <1418233785-18020-2-git-send-email-mpn@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1418233785-18020-1-git-send-email-mpn@google.com> References: <1418233785-18020-1-git-send-email-mpn@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338 X-Mailman-Approved-At: Wed, 10 Dec 2014 12:53:34 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) From: Michal Nazarewicz * lisp/descr-text.el (describe-char-eldoc): New function returning basic Unicode codepoint information (e.g. name) about character at point. It is meant to be used as a default value of the `eldoc-documentation-function' variable. (describe-char-eldoc--format, describe-char-eldoc--truncate): New helper functions for `describe-char-eldoc' function. * tests/automated/descr-text-test.el: New file with tests for `describe-char-eldoc--truncate', `describe-char-eldoc--format', and `describe-char-eldoc'. --- etc/NEWS | 4 ++ lisp/descr-text.el | 96 +++++++++++++++++++++++++++++++++++++++ test/automated/descr-text-test.el | 94 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 test/automated/descr-text-test.el diff --git a/etc/NEWS b/etc/NEWS index 50338cf..77a2f9b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -203,6 +203,10 @@ result of the calculation into the current buffer. *** `eldoc-documentation-function' now defaults to nil *** Default value of `eldoc-documentation-function now' is consulted if local function does not return any documentation. +*** `describe-char-eldoc' displays information about character at point, +and can be used as a default value of `eldoc-documentation-function'. It is +useful when, for example, one needs to distinguish various spaces (e.g. ] [, +] [, ] [, etc.) while using mono-spaced font. ** eww diff --git a/lisp/descr-text.el b/lisp/descr-text.el index 1dc43e9..d435fe6 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el @@ -825,6 +825,102 @@ relevant to POS." (define-obsolete-function-alias 'describe-char-after 'describe-char "22.1") +;;; Describe-Char-ElDoc + +(defun describe-char-eldoc--truncate (name width) + "Truncate NAME at white spaces such that it is no longer than WIDTH. + +If NAME consists of white space only, return an empty string. + +Otherwise, if NAME consists of a single word (where word is defined as sequence +of non-white space characters), return that word even if it's longer than WIDTH. + +Otherwise, if first word in NAME is longer or equal WIDTH, return that word with +ellipsis character (\"…\") appended; this results in a string longer than WIDTH. + +Otherwise, take as many words from NAME as possible, separating them with +a single space character, while not exceeding WIDTH characters length limit. If +not all words fit, append ellipsis character (\"…\") at the end; the ellipsis is +counted towards WIDTH." + (let ((words (split-string name))) + (if words + (let ((last words)) + (setq width (- width (length (car words)))) + (while (and (cdr last) + (<= (+ (length (cadr last)) (if (cddr last) 2 1)) width)) + (setq last (cdr last)) + (setq width (- width (length (car last)) 1))) + (let ((ellipsis (and (cdr last) "…"))) + (setcdr last nil) + (concat (mapconcat 'identity words " ") ellipsis))) + ""))) + +(defun describe-char-eldoc--format (ch &optional width) + "Format a description for character CH which is no more than WIDTH characters. + +Full description message has a \"U+: (: )\" +format where: +- is a hexadecimal codepoint of the character (zero-padded to at least + four digits), +- is name of the character. +- is a two-letter abbreviation of the general-category of the character, + and +- is full name of the general-category of the character. + +If WIDTH is non-nil some elements of the description may be omitted to +accommodate the length restriction. Under certain condition, the function may +return string longer than WIDTH, see `describe-char-eldoc--truncate'." + (let ((name (get-char-code-property ch 'name))) + (when name + (let* ((code (propertize (format "U+%04X" ch) + 'face 'font-lock-constant-face)) + (gc (get-char-code-property ch 'general-category)) + (gc-desc (char-code-property-description 'general-category gc))) + + (unless (or (not width) (<= (length name) width)) + (setq name (describe-char-eldoc--truncate name width))) + (setq name (concat (substring name 0 1) (downcase (substring name 1)))) + (setq name (propertize name 'face 'font-lock-variable-name-face)) + + (setq gc (propertize (symbol-name gc) 'face 'font-lock-comment-face)) + (when gc-desc + (setq gc-desc (propertize gc-desc 'face 'font-lock-comment-face))) + + (let ((lcode (length code)) + (lname (length name)) + (lgc (length gc)) + (lgc-desc (and gc-desc (length gc-desc)))) + (cond + ((and gc-desc + (or (not width) (<= (+ lcode lname lgc lgc-desc 7) width))) + (concat code ": " name " (" gc ": " gc-desc ")")) + ((and gc-desc (<= (+ lcode lname lgc-desc 5) width)) + (concat code ": " name " (" gc-desc ")")) + ((or (not width) (<= (+ lcode lname lgc 5) width)) + (concat code ": " name " (" gc ")")) + ((<= (+ lname lgc 3) width) + (concat name " (" gc ")")) + (t name))))))) + +;;;###autoload +(defun describe-char-eldoc () + "Returns a description of character at point for use by ElDoc mode. + +If character at point is a printable ASCII character (i.e. codepoint between 32 +and 127 inclusively), nil is returned. Otherwise a description formatted by +`describe-char-eldoc--format' function is returned taking into account value +of `eldoc-echo-area-use-multiline-p' variable and width of minibuffer window for +width limit. + +This function is meant to be used as a value of `eldoc-documentation-function' +variable." + (let ((ch (following-char))) + (when (and (not (zerop ch)) (or (< ch 32) (> ch 127))) + (describe-char-eldoc--format + ch + (unless (eq eldoc-echo-area-use-multiline-p t) + (1- (window-width (minibuffer-window)))))))) + (provide 'descr-text) ;;; descr-text.el ends here diff --git a/test/automated/descr-text-test.el b/test/automated/descr-text-test.el new file mode 100644 index 0000000..81a4375 --- /dev/null +++ b/test/automated/descr-text-test.el @@ -0,0 +1,94 @@ +;;; descr-text-test.el --- ERT tests for descr-text.el -*- lexical-binding: t -*- + +;; Copyright (C) 2014 Free Software Foundation, Inc. + +;; Author: Michal Nazarewicz + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Commentary: + +;; This package defines regression tests for the descr-text package. + +;;; Code: + +(require 'ert) +(require 'descr-text) + + +(ert-deftest descr-text-test-truncate () + "Tests describe-char-eldoc--truncate function." + (should (equal "" + (describe-char-eldoc--truncate " \t \n" 100))) + (should (equal "foo" + (describe-char-eldoc--truncate "foo" 1))) + (should (equal "foo…" + (describe-char-eldoc--truncate "foo wilma fred" 0))) + (should (equal "foo…" + (describe-char-eldoc--truncate + "foo wilma fred" (length "foo wilma")))) + (should (equal "foo wilma…" + (describe-char-eldoc--truncate + "foo wilma fred" (1+ (length "foo wilma"))))) + (should (equal "foo wilma…" + (describe-char-eldoc--truncate + "foo wilma fred" (1- (length "foo wilma fred"))))) + (should (equal "foo wilma fred" + (describe-char-eldoc--truncate + "foo wilma fred" (length "foo wilma fred")))) + (should (equal "foo wilma fred" + (describe-char-eldoc--truncate + " foo\t wilma \nfred\t " (length "foo wilma fred"))))) + +(ert-deftest descr-text-test-format-desc () + "Tests describe-char-eldoc--format function." + (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)" + (describe-char-eldoc--format ?…))) + (should (equal "U+2026: Horizontal ellipsis (Punctuation, Other)" + (describe-char-eldoc--format ?… 51))) + (should (equal "U+2026: Horizontal ellipsis (Po)" + (describe-char-eldoc--format ?… 40))) + (should (equal "Horizontal ellipsis (Po)" + (describe-char-eldoc--format ?… 30))) + (should (equal "Horizontal ellipsis" + (describe-char-eldoc--format ?… 20))) + (should (equal "Horizontal…" + (describe-char-eldoc--format ?… 10)))) + +(ert-deftest descr-text-test-desc () + "Tests describe-char-eldoc function." + (with-temp-buffer + (insert "a…") + (goto-char (point-min)) + (should (eq ?a (following-char))) ; make sure we are where we think we are + ;; Function should return nil for an ASCII character. + (should (not (describe-char-eldoc))) + + (goto-char (1+ (point))) + (should (eq ?… (following-char))) + (let ((eldoc-echo-area-use-multiline-p t)) + ;; Function should return description of an Unicode character. + (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)" + (describe-char-eldoc)))) + + (goto-char (point-max)) + ;; At the end of the buffer, function should return nil and not blow up. + (should (not (describe-char-eldoc))))) + + +(provide 'descr-text-test) + +;;; descr-text-test.el ends here -- 2.2.0.rc0.207.ga3a616c From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 10 12:53:39 2014 Received: (at 19338) by debbugs.gnu.org; 10 Dec 2014 17:53:39 +0000 Received: from localhost ([127.0.0.1]:41936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XylSE-0003Al-If for submit@debbugs.gnu.org; Wed, 10 Dec 2014 12:53:38 -0500 Received: from mail-wi0-f178.google.com ([209.85.212.178]:65351) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XylOe-00033i-VM for 19338@debbugs.gnu.org; Wed, 10 Dec 2014 12:49:57 -0500 Received: by mail-wi0-f178.google.com with SMTP id em10so5992597wid.17 for <19338@debbugs.gnu.org>; Wed, 10 Dec 2014 09:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=t2tyPFemangkMUkCA05sNk1vKhpqErXyUBJdMqGc6mM=; b=Drc8eiwIStVmYZE0tUOtboaTGDmJnW5s0sKaoBRRD/aUIrMuBXvZgo8Ou1IWJraV3u j/LicjuOfb/B3NZ9lqBmcu0VsdOsrsYI93YOBIN3tz0m2XIlZqe7rF107aV3zQJIaTdx RjXXCu/V6Yz1K4+4fL6KKZ4WUmgwxRZT/7zE9L81bVGUEprsdBqBKuOtM0f/AL0VD0Tq IeHVcDmOf9/5ZG8/Ugj4dA7noxE1ZGlUay32zncoDXDSd6QQPJhcpN+Ia+9H4UhDxC4J QIjOC7PpSocgJau/BegUFGJHOfUR75aJv1Y2b6neLHPsXxczb2WzlF98o0nOU3CqLHsd sl9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=t2tyPFemangkMUkCA05sNk1vKhpqErXyUBJdMqGc6mM=; b=NqReJoDjMpTz3n835n4ni5iz0nHvhiq41hao1S6CykieJaBIvPKNW2ykLJKpEMO7vg 760tZI4ORVXYZnJgN2YHcONPYWO4GdpTvV1h+ETQatFqMfD+R6kkWvk8Qr5ieW8BCQHc FBfkYcRG8xAO1AX212KsRkYU1xWRjlSFrC4bA6Z7tdHlddmumPlzhrMYVdOhpwyuS0QD EOv74G6WcnmJCM0eJ5HNU9rxtnOitTlmaE/fpWvqVH7mSmbcGJF8f8sCAfP78pyl/VSp Q4S0XoEOHXIDIgNxttqwAuQG6OO+bepOnp8xIhC0937vVLwOdgf78UU6CRHZlwV/MbGo 9Vlg== X-Gm-Message-State: ALoCoQlj2asQTniEz2Lu+wbpqtNA1RFpGaqidNQhnH9xhuUebEfDkHxslG8Dsr6/7tPufadzZAA+ X-Received: by 10.194.52.37 with SMTP id q5mr8589254wjo.39.1418233791300; Wed, 10 Dec 2014 09:49:51 -0800 (PST) Received: from mpn-glaptop.corp.google.com ([2620:0:105f:310:381f:eb80:e0ce:71dc]) by mx.google.com with ESMTPSA id ly9sm6744297wjb.24.2014.12.10.09.49.50 for <19338@debbugs.gnu.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Dec 2014 09:49:50 -0800 (PST) From: Michal Nazarewicz To: 19338@debbugs.gnu.org Subject: [PATCH 3/3] eldoc: convert `eldoc-documentation-function' into a defcustom Date: Wed, 10 Dec 2014 18:49:45 +0100 Message-Id: <1418233785-18020-3-git-send-email-mpn@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1418233785-18020-1-git-send-email-mpn@google.com> References: <1418233785-18020-1-git-send-email-mpn@google.com> X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338 X-Mailman-Approved-At: Wed, 10 Dec 2014 12:53:34 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) From: Michal Nazarewicz * lisp/emacs-lisp/eldoc.el (eldoc-documentation-function): Change from defvar to defcustom with `describe-char-eldoc' function as one of the suggested values. --- lisp/emacs-lisp/eldoc.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 06ee164..aeddf90 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -321,8 +321,8 @@ Otherwise work like `message'." ;;;###autoload -(defvar eldoc-documentation-function nil - "Function to call to return doc string. +(defcustom eldoc-documentation-function nil + "Function to call to return doc string for ElDoc mode. The function of no args should return a one-line string for displaying doc about a function etc. appropriate to the context around point. It should return nil if there's no doc appropriate for the context. @@ -334,7 +334,13 @@ the variables `eldoc-argument-case' and `eldoc-echo-area-use-multiline-p', and the face `eldoc-highlight-function-argument', if they are to have any effect. -This variable is expected to be set buffer-locally by modes that support ElDoc.") +Major modes can set this variable buffer-locally to overwrite the global +default, but if local documentation function returns no doc string, the global +one will be tried as well." + :type '(radio (function-item describe-char-eldoc) + function + (const :tag "No documentation function" nil)) + :group 'eldoc) (defun eldoc-print-current-symbol-info () ;; This is run from post-command-hook or some idle timer thing, -- 2.2.0.rc0.207.ga3a616c From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 10 15:05:31 2014 Received: (at 19338) by debbugs.gnu.org; 10 Dec 2014 20:05:31 +0000 Received: from localhost ([127.0.0.1]:41993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XynVq-0006Yz-Sa for submit@debbugs.gnu.org; Wed, 10 Dec 2014 15:05:31 -0500 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:34177) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XynVo-0006Yn-Qk for 19338@debbugs.gnu.org; Wed, 10 Dec 2014 15:05:29 -0500 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id sBAK5Qej019730; Wed, 10 Dec 2014 15:05:27 -0500 Received: by ceviche.home (Postfix, from userid 20848) id 90ECA6610C; Wed, 10 Dec 2014 15:05:26 -0500 (EST) From: Stefan Monnier To: Michal Nazarewicz Subject: Re: bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results Message-ID: References: <1418232280-16915-1-git-send-email-mpn@google.com> <1418233785-18020-1-git-send-email-mpn@google.com> Date: Wed, 10 Dec 2014 15:05:26 -0500 In-Reply-To: <1418233785-18020-1-git-send-email-mpn@google.com> (Michal Nazarewicz's message of "Wed, 10 Dec 2014 18:49:43 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5151=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5151> : inlines <1621> : streams <1354810> : uri <1838052> X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) > - (eldoc-message (funcall eldoc-documentation-function))))) > + (eldoc-message > + (or (funcall eldoc-documentation-function) > + ;; If local documentation function did not return anything, try > + ;; global one. > + (when (local-variable-p 'eldoc-documentation-function) > + (let ((func (default-value 'eldoc-documentation-function))) > + (when func (funcall func))))))))) We don't need that: if the major-mode wants that to happen, it can do that with an appropriate call to add-function, which will take care of delegating to the global value if/when applicable. This works very much like the add-hook's `local' argument. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 10 15:08:50 2014 Received: (at 19338) by debbugs.gnu.org; 10 Dec 2014 20:08:51 +0000 Received: from localhost ([127.0.0.1]:42000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XynZ4-0006ey-Fz for submit@debbugs.gnu.org; Wed, 10 Dec 2014 15:08:50 -0500 Received: from chene.dit.umontreal.ca ([132.204.246.20]:34173) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XynZ1-0006ep-QK for 19338@debbugs.gnu.org; Wed, 10 Dec 2014 15:08:48 -0500 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id sBAK8lgc007923; Wed, 10 Dec 2014 15:08:47 -0500 Received: by ceviche.home (Postfix, from userid 20848) id ECF6B6610C; Wed, 10 Dec 2014 15:08:46 -0500 (EST) From: Stefan Monnier To: Michal Nazarewicz Subject: Re: bug#19338: [PATCH 3/3] eldoc: convert `eldoc-documentation-function' into a defcustom Message-ID: References: <1418233785-18020-1-git-send-email-mpn@google.com> <1418233785-18020-3-git-send-email-mpn@google.com> Date: Wed, 10 Dec 2014 15:08:46 -0500 In-Reply-To: <1418233785-18020-3-git-send-email-mpn@google.com> (Michal Nazarewicz's message of "Wed, 10 Dec 2014 18:49:45 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5151=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5151> : inlines <1621> : streams <1354811> : uri <1838052> X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) > -(defvar eldoc-documentation-function nil > - "Function to call to return doc string. > +(defcustom eldoc-documentation-function nil > + "Function to call to return doc string for ElDoc mode. This variable will be modified programmatically by various Elisp packages, which interacts poorly with Custom. If you want your describe-char-eldoc thingy to be Custom-izable, you'd probably be better served with a describe-char-eldoc-mode minor-mode, which you can then enable via Custom. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 10 16:46:33 2014 Received: (at 19338) by debbugs.gnu.org; 10 Dec 2014 21:46:33 +0000 Received: from localhost ([127.0.0.1]:42071 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xyp5d-0000xV-8V for submit@debbugs.gnu.org; Wed, 10 Dec 2014 16:46:33 -0500 Received: from mail-wg0-f42.google.com ([74.125.82.42]:59551) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xyp5Z-0000xE-Rr for 19338@debbugs.gnu.org; Wed, 10 Dec 2014 16:46:30 -0500 Received: by mail-wg0-f42.google.com with SMTP id z12so4852382wgg.29 for <19338@debbugs.gnu.org>; Wed, 10 Dec 2014 13:46:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:face:date:message-id:mime-version:content-type :content-transfer-encoding; bh=j2EQ1m3bgm9yFbfu+0xbw4bKJp5kWTGJuWB7fRIhYBw=; b=NcqfIrMcp/PQN19Qzu0+Pxh/w9rFpI7/awHjarz7sX125QcTruigP5Q0s/okka6+Dw Ycpn+NC81L9J6JYc2/HhST+rGBCLKrrc7zBQyLdihpWMQTdciQTfDRmi+VSco4ZrT6pJ Ex9ewcFyw6oTAFng8gAvwrLCKiBAUZkqSc/Mx7127FPEOmTNU+SeCa620Ch+o0hFBC1/ XXrysdY+S36uLSmiVzRRHD1Es7qEYE0VOwDiSQhqODTNkQJLVE8YA00zn7XLzIblfM5C XMTHl6jzDObDCbBHUhhxVbzzjhOsU/yLluW8YShTHczf/A0e0gtanrvZWPodHa+X0JPw JaPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to :organization:references:user-agent:face:date:message-id :mime-version:content-type:content-transfer-encoding; bh=j2EQ1m3bgm9yFbfu+0xbw4bKJp5kWTGJuWB7fRIhYBw=; b=lHERAvkaydcu81/v0BqxTlF2a1sU+ZaukZV8VGmhw4rBLHNS21V1MEibbB4QZDVOKV UIPZStPdJwQAipthdw+ufkh+DOscW/Hx8EZV7uYUzJV9paSS8cb+D3qWt/25yBWmpAaN c0oIBrqP8kJ4Hdk7T0d7XV+h0JU9HxUGR73vCBlMh/LpWGHvfVN1nIFmvzYIe0m/Nhba xlLU1ZmxOgN+BbU1gorzEfBFcbwsSl05KimAjk5ftqRM/dsQeS6W4kSDEums+g0u/vgv hl+0QjsHSazOT32/Q8e2dvhbHDDSolMG2VgIWRBnlNMdRiCHbJufpgUvNncEyTcpIk2i wvIw== X-Gm-Message-State: ALoCoQltQvgn/jGOx8F/cg9fhce2jewzgOkYQWlaD/oNdkcTsRziJRNhM//vA08Q7Y0GGis8eGhO X-Received: by 10.194.79.226 with SMTP id m2mr10242688wjx.60.1418247984089; Wed, 10 Dec 2014 13:46:24 -0800 (PST) Received: from mpn-glaptop.roam.corp.google.com ([2620:0:105f:310:381f:eb80:e0ce:71dc]) by mx.google.com with ESMTPSA id j2sm7430159wjs.28.2014.12.10.13.46.22 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 10 Dec 2014 13:46:23 -0800 (PST) From: Michal Nazarewicz To: Stefan Monnier Subject: Re: bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results In-Reply-To: Organization: http://mina86.com/ References: <1418232280-16915-1-git-send-email-mpn@google.com> <1418233785-18020-1-git-send-email-mpn@google.com> User-Agent: Notmuch/0.19~rc1+1~g03aea4f (http://notmuchmail.org) Emacs/25.0.50.2 (x86_64-unknown-linux-gnu) X-Face: PbkBB1w#)bOqd`iCe"Ds{e+!C7`pkC9a|f)Qo^BMQvy\q5x3?vDQJeN(DS?|-^$uMti[3D*#^_Ts"pU$jBQLq~Ud6iNwAw_r_o_4]|JO?]}P_}Nc&"p#D(ZgUb4uCNPe7~a[DbPG0T~!&c.y$Ur,=N4RT>]dNpd; KFrfMCylc}gc??'U2j,!8%xdD Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACQElEQVQ4jW3TMWvbQBQHcBk1xE6WyALX1069oZBMlq+ouUwpEQQ6uRjttkWP4CmBgGM0BQLBdPFZYPsyFUo6uEtKDQ7oy/U96XR2Ux8ehH/89Z6enqxBcS7Lg81jmSuujrfCZcLI/TYYvbGj+jbgFpHJ/bqQAUISj8iLyu4LuFHJTosxsucO4jSDNE0Hq3hwK/ceQ5sx97b8LcUDsILfk+ovHkOIsMbBfg43VuQ5Ln9YAGCkUdKJoXR9EclFBhixy3EGVz1K6eEkhxCAkeMMnqoAhAKwhoUJkDrCqvbecaYINlFKSRS1i12VKH1XpUd4qxL876EkMcDvHj3s5RBajHHMlA5iK32e0C7VgG0RlzFPvoYHZLRmAC0BmNcBruhkE0KsMsbEc62ZwUJDxWUdMsMhVqovoT96i/DnX/ASvz/6hbCabELLk/6FF/8PNpPCGqcZTGFcBhhAaZZDbQPaAB3+KrWWy2XgbYDNIinkdWAFcCpraDE/knwe5DBqGmgzESl1p2E4MWAz0VUPgYYzmfWb9yS4vCvgsxJriNTHoIBz5YteBvg+VGISQWUqhMiByPIPpygeDBE6elD973xWwKkEiHZAHKjhuPsFnBuArrzxtakRcISv+XMIPl4aGBUJm8Emk7qBYU8IlgNEIpiJhk/No24jHwkKTFHDWfPniR4iw5vJaw2nzSjfq2zffcE/GDjRC2dn0J0XwPAbDL84TvaFCJEU4Oml9pRyEUhR3Cl2t01AoEjRbs0sYugp14/4X5n4pU4EHHnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:141210:monnier@iro.umontreal.ca::LPzI2zhJBQdhNv7T:00000000000000000000000000000000000004dQm X-Hashcash: 1:20:141210:19338@debbugs.gnu.org::Thbjbm2D/rJk8/LS:00000000000000000000000000000000000000004cqx Date: Wed, 10 Dec 2014 22:46:21 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Wed, Dec 10 2014, Stefan Monnier wrote: >> - (eldoc-message (funcall eldoc-documentation-function))))) >> + (eldoc-message >> + (or (funcall eldoc-documentation-function) >> + ;; If local documentation function did not return anythin= g, try >> + ;; global one. >> + (when (local-variable-p 'eldoc-documentation-function) >> + (let ((func (default-value 'eldoc-documentation-functio= n))) >> + (when func (funcall func))))))))) > > We don't need that: if the major-mode wants that to happen, it can do > that with an appropriate call to add-function, which will take care of > delegating to the global value if/when applicable. > > This works very much like the add-hook's `local' argument. So the point here is that I don't want major-mode to be aware of what I might have set the default value of `eldoc-documentation-function' to (and work even if I change it at any point). This is also why I made `eldoc-documentation-function' into a defcustom so user can customise the default value regardless of what major-mode is doing. I first tried doing it with `eldoc-mode' but the result didn't seem clean or working correctly when major mode had its own eldoc function set. --=20 Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz = (o o) ooo +------ooO--(_)--Ooo-- From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 10 21:38:49 2014 Received: (at 19338) by debbugs.gnu.org; 11 Dec 2014 02:38:49 +0000 Received: from localhost ([127.0.0.1]:42148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XyteS-00018v-L7 for submit@debbugs.gnu.org; Wed, 10 Dec 2014 21:38:48 -0500 Received: from chene.dit.umontreal.ca ([132.204.246.20]:36284) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XyteQ-00018n-Md for 19338@debbugs.gnu.org; Wed, 10 Dec 2014 21:38:47 -0500 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id sBB2ciP3024420; Wed, 10 Dec 2014 21:38:45 -0500 Received: by ceviche.home (Postfix, from userid 20848) id 5E363660F3; Wed, 10 Dec 2014 21:38:44 -0500 (EST) From: Stefan Monnier To: Michal Nazarewicz Subject: Re: bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results Message-ID: References: <1418232280-16915-1-git-send-email-mpn@google.com> <1418233785-18020-1-git-send-email-mpn@google.com> Date: Wed, 10 Dec 2014 21:38:44 -0500 In-Reply-To: (Michal Nazarewicz's message of "Wed, 10 Dec 2014 22:46:21 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5151=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5151> : inlines <1625> : streams <1354955> : uri <1838084> X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) > So the point here is that I don't want major-mode to be aware of what > I might have set the default value of `eldoc-documentation-function' to The major mode doesn't have to be aware of it. It should simply always delegate to the default function (i.e. ideally use :before-until, of course that requires fixing the default value of eldoc-documentation-function). > (and work even if I change it at any point). Just like the `local' arg of add-hook, add-function correctly handles later changes to the global value of the variable. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 11 11:02:49 2014 Received: (at 19338) by debbugs.gnu.org; 11 Dec 2014 16:02:50 +0000 Received: from localhost ([127.0.0.1]:42910 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz6CU-0007AH-1T for submit@debbugs.gnu.org; Thu, 11 Dec 2014 11:02:49 -0500 Received: from mail-wg0-f52.google.com ([74.125.82.52]:38110) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz6CR-00079x-AG for 19338@debbugs.gnu.org; Thu, 11 Dec 2014 11:02:44 -0500 Received: by mail-wg0-f52.google.com with SMTP id x12so6788424wgg.11 for <19338@debbugs.gnu.org>; Thu, 11 Dec 2014 08:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=rSYw52UfoH9Ic3dx/XlIgTLrEVqFMCgrDFqSYvcOsLQ=; b=cKnvHRvKy/4R/UVOwVCo4N9/dDuTXkEjtmMJzG5wrrDfaMJmn/PSkwSnHgB+7BbM2k CEur+8WbbYy+jYvVszGAOg2bdIMt2c6yyE1EPnefM9AiwxnMHEk3gZPpN8ijn6WXUwAi 6CxtUbvll/TdMT4T9NSqrSAdSLdTtvnyk5a18/ABzICaLPwNjEuE0N9KiAdlWMJ34+Mm 8kpqnFqJpQ24MLsRCbg8mj/pY7xBqh9ekG9Fcp3d0zb6+PeJk4Bg//aRiFG9PYCm4pH0 EOa8UdhyD/1LHXrhWzyPL41XhUENx5dNQNU3iABmAeDHatLMt1S/wHi9/fG/0/G4Wx7f hUNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=rSYw52UfoH9Ic3dx/XlIgTLrEVqFMCgrDFqSYvcOsLQ=; b=fBo0y63BrRn/EvAT15VURncgFNi/jaAZqSzCMz2YVEnMfiwAlbJRcUW3U3wF+KC0qU OPAuqCaeCqNPRj6aLOdk73JhNCg5uuIFMatj5iCUFXYttjd4P2zI/NeMlDmY83kNIiRf j3pVNOJyxbbVlxDPoRuoo0frZAG5YyXRjygq3yv88fNtoLW+T2VNK3BnS7T9TRow6Cfh bWqa0tb5j7TFdhoosVDfy+c00kQIzGCBCj1Cyj6KEd5/0Thdk2DPk1xD+fumJolS00TH 2B/2Vyu0AZajmX57tJKAq/mf236Xx/N1AvwVfYD97oUvT9b/VgwP6VGBqX3CqEUqfb7r tMsA== X-Gm-Message-State: ALoCoQl4FBdv6QTZqCP/mEl/bKf2gUjEGF6dwtyR4XpqtGBVEedvHvbg7wxg5/QbEVuxVaNVXwxC X-Received: by 10.194.92.37 with SMTP id cj5mr18260171wjb.81.1418313757523; Thu, 11 Dec 2014 08:02:37 -0800 (PST) Received: from mpn-glaptop.corp.google.com ([2620:0:105f:310:6593:e074:890e:2cc7]) by mx.google.com with ESMTPSA id h14sm2846092wic.8.2014.12.11.08.02.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Dec 2014 08:02:36 -0800 (PST) From: Michal Nazarewicz To: Stefan Monnier Subject: [PATCHv2 1/2] descr-text: add `describe-char-eldoc' describing character at point Date: Thu, 11 Dec 2014 17:02:31 +0100 Message-Id: <1418313752-13536-1-git-send-email-mpn@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) From: Michal Nazarewicz * lisp/descr-text.el (describe-char-eldoc): New function returning basic Unicode codepoint information (e.g. name) about character at point. It is meant to be used as a default value of the `eldoc-documentation-function' variable. (describe-char-eldoc--format, describe-char-eldoc--truncate): New helper functions for `describe-char-eldoc' function. * tests/automated/descr-text-test.el: New file with tests for `describe-char-eldoc--truncate', `describe-char-eldoc--format', and `describe-char-eldoc'. --- etc/NEWS | 8 +++- lisp/descr-text.el | 96 +++++++++++++++++++++++++++++++++++++++ test/automated/descr-text-test.el | 94 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 test/automated/descr-text-test.el diff --git a/etc/NEWS b/etc/NEWS index 407df82..61f6dcc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -199,8 +199,12 @@ typing RET. result of the calculation into the current buffer. ** ElDoc -*** New minor mode global-eldoc-mode -*** eldoc-documentation-function now defaults to nil +*** New minor mode `global-eldoc-mode' +*** `eldoc-documentation-function' now defaults to `ignore' +*** `describe-char-eldoc' displays information about character at point, +and can be used as a default value of `eldoc-documentation-function'. It is +useful when, for example, one needs to distinguish various spaces (e.g. ] [, +] [, ] [, etc.) while using mono-spaced font. ** eww diff --git a/lisp/descr-text.el b/lisp/descr-text.el index 1dc43e9..d435fe6 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el @@ -825,6 +825,102 @@ relevant to POS." (define-obsolete-function-alias 'describe-char-after 'describe-char "22.1") +;;; Describe-Char-ElDoc + +(defun describe-char-eldoc--truncate (name width) + "Truncate NAME at white spaces such that it is no longer than WIDTH. + +If NAME consists of white space only, return an empty string. + +Otherwise, if NAME consists of a single word (where word is defined as sequence +of non-white space characters), return that word even if it's longer than WIDTH. + +Otherwise, if first word in NAME is longer or equal WIDTH, return that word with +ellipsis character (\"…\") appended; this results in a string longer than WIDTH. + +Otherwise, take as many words from NAME as possible, separating them with +a single space character, while not exceeding WIDTH characters length limit. If +not all words fit, append ellipsis character (\"…\") at the end; the ellipsis is +counted towards WIDTH." + (let ((words (split-string name))) + (if words + (let ((last words)) + (setq width (- width (length (car words)))) + (while (and (cdr last) + (<= (+ (length (cadr last)) (if (cddr last) 2 1)) width)) + (setq last (cdr last)) + (setq width (- width (length (car last)) 1))) + (let ((ellipsis (and (cdr last) "…"))) + (setcdr last nil) + (concat (mapconcat 'identity words " ") ellipsis))) + ""))) + +(defun describe-char-eldoc--format (ch &optional width) + "Format a description for character CH which is no more than WIDTH characters. + +Full description message has a \"U+: (: )\" +format where: +- is a hexadecimal codepoint of the character (zero-padded to at least + four digits), +- is name of the character. +- is a two-letter abbreviation of the general-category of the character, + and +- is full name of the general-category of the character. + +If WIDTH is non-nil some elements of the description may be omitted to +accommodate the length restriction. Under certain condition, the function may +return string longer than WIDTH, see `describe-char-eldoc--truncate'." + (let ((name (get-char-code-property ch 'name))) + (when name + (let* ((code (propertize (format "U+%04X" ch) + 'face 'font-lock-constant-face)) + (gc (get-char-code-property ch 'general-category)) + (gc-desc (char-code-property-description 'general-category gc))) + + (unless (or (not width) (<= (length name) width)) + (setq name (describe-char-eldoc--truncate name width))) + (setq name (concat (substring name 0 1) (downcase (substring name 1)))) + (setq name (propertize name 'face 'font-lock-variable-name-face)) + + (setq gc (propertize (symbol-name gc) 'face 'font-lock-comment-face)) + (when gc-desc + (setq gc-desc (propertize gc-desc 'face 'font-lock-comment-face))) + + (let ((lcode (length code)) + (lname (length name)) + (lgc (length gc)) + (lgc-desc (and gc-desc (length gc-desc)))) + (cond + ((and gc-desc + (or (not width) (<= (+ lcode lname lgc lgc-desc 7) width))) + (concat code ": " name " (" gc ": " gc-desc ")")) + ((and gc-desc (<= (+ lcode lname lgc-desc 5) width)) + (concat code ": " name " (" gc-desc ")")) + ((or (not width) (<= (+ lcode lname lgc 5) width)) + (concat code ": " name " (" gc ")")) + ((<= (+ lname lgc 3) width) + (concat name " (" gc ")")) + (t name))))))) + +;;;###autoload +(defun describe-char-eldoc () + "Returns a description of character at point for use by ElDoc mode. + +If character at point is a printable ASCII character (i.e. codepoint between 32 +and 127 inclusively), nil is returned. Otherwise a description formatted by +`describe-char-eldoc--format' function is returned taking into account value +of `eldoc-echo-area-use-multiline-p' variable and width of minibuffer window for +width limit. + +This function is meant to be used as a value of `eldoc-documentation-function' +variable." + (let ((ch (following-char))) + (when (and (not (zerop ch)) (or (< ch 32) (> ch 127))) + (describe-char-eldoc--format + ch + (unless (eq eldoc-echo-area-use-multiline-p t) + (1- (window-width (minibuffer-window)))))))) + (provide 'descr-text) ;;; descr-text.el ends here diff --git a/test/automated/descr-text-test.el b/test/automated/descr-text-test.el new file mode 100644 index 0000000..81a4375 --- /dev/null +++ b/test/automated/descr-text-test.el @@ -0,0 +1,94 @@ +;;; descr-text-test.el --- ERT tests for descr-text.el -*- lexical-binding: t -*- + +;; Copyright (C) 2014 Free Software Foundation, Inc. + +;; Author: Michal Nazarewicz + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Commentary: + +;; This package defines regression tests for the descr-text package. + +;;; Code: + +(require 'ert) +(require 'descr-text) + + +(ert-deftest descr-text-test-truncate () + "Tests describe-char-eldoc--truncate function." + (should (equal "" + (describe-char-eldoc--truncate " \t \n" 100))) + (should (equal "foo" + (describe-char-eldoc--truncate "foo" 1))) + (should (equal "foo…" + (describe-char-eldoc--truncate "foo wilma fred" 0))) + (should (equal "foo…" + (describe-char-eldoc--truncate + "foo wilma fred" (length "foo wilma")))) + (should (equal "foo wilma…" + (describe-char-eldoc--truncate + "foo wilma fred" (1+ (length "foo wilma"))))) + (should (equal "foo wilma…" + (describe-char-eldoc--truncate + "foo wilma fred" (1- (length "foo wilma fred"))))) + (should (equal "foo wilma fred" + (describe-char-eldoc--truncate + "foo wilma fred" (length "foo wilma fred")))) + (should (equal "foo wilma fred" + (describe-char-eldoc--truncate + " foo\t wilma \nfred\t " (length "foo wilma fred"))))) + +(ert-deftest descr-text-test-format-desc () + "Tests describe-char-eldoc--format function." + (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)" + (describe-char-eldoc--format ?…))) + (should (equal "U+2026: Horizontal ellipsis (Punctuation, Other)" + (describe-char-eldoc--format ?… 51))) + (should (equal "U+2026: Horizontal ellipsis (Po)" + (describe-char-eldoc--format ?… 40))) + (should (equal "Horizontal ellipsis (Po)" + (describe-char-eldoc--format ?… 30))) + (should (equal "Horizontal ellipsis" + (describe-char-eldoc--format ?… 20))) + (should (equal "Horizontal…" + (describe-char-eldoc--format ?… 10)))) + +(ert-deftest descr-text-test-desc () + "Tests describe-char-eldoc function." + (with-temp-buffer + (insert "a…") + (goto-char (point-min)) + (should (eq ?a (following-char))) ; make sure we are where we think we are + ;; Function should return nil for an ASCII character. + (should (not (describe-char-eldoc))) + + (goto-char (1+ (point))) + (should (eq ?… (following-char))) + (let ((eldoc-echo-area-use-multiline-p t)) + ;; Function should return description of an Unicode character. + (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)" + (describe-char-eldoc)))) + + (goto-char (point-max)) + ;; At the end of the buffer, function should return nil and not blow up. + (should (not (describe-char-eldoc))))) + + +(provide 'descr-text-test) + +;;; descr-text-test.el ends here -- 2.2.0.rc0.207.ga3a616c From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 11 11:02:50 2014 Received: (at 19338) by debbugs.gnu.org; 11 Dec 2014 16:02:50 +0000 Received: from localhost ([127.0.0.1]:42912 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz6CX-0007AP-W0 for submit@debbugs.gnu.org; Thu, 11 Dec 2014 11:02:50 -0500 Received: from mail-wi0-f182.google.com ([209.85.212.182]:40919) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz6CS-00079z-SQ for 19338@debbugs.gnu.org; Thu, 11 Dec 2014 11:02:45 -0500 Received: by mail-wi0-f182.google.com with SMTP id h11so9137538wiw.9 for <19338@debbugs.gnu.org>; Thu, 11 Dec 2014 08:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fy0XRibtkWBbqCfMRm4tkgd110XT0l+yBn/ipNXYvwo=; b=nn2bFAE3YT2uT8UTrpwUa3BRf38CIguyu+7NfwBMPsTzDN4WEX5/afewi+SEliQ6sV bVO448hLPO7oG4E0VdCM1M53MJichCtpoteUGZO9uQOXgFeT3e7+6qN37jKyll/E1S/+ TtJOEV5zxSnj9K+Nc7q6FLH+ELLhuluL+cUfXFW7RXWurXRO0+hkuzkUWPfPBm3ZU4lk C86Qfc0lh5KE+DZ4RKUVmLci1R8YWVs6PVQ+Mm9V61aoPf3lMMNlCPmu6DGDba+ZkIQi oVlYVa2UL7HPx5yFY4Rv5A1Qjr2PoyP/TAcuA2LILVxDRNJ9sC9YISNfPnfAqe0Vkxec r+GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fy0XRibtkWBbqCfMRm4tkgd110XT0l+yBn/ipNXYvwo=; b=FlJEpjTlw5DcbI1IAhiWgb+JTE702g7pbwNWADQq5i7YnSfL+4zoCLFAVXiltN8X+n mFguIp3YD3iKe6jL+H+bcODJfJ+6iX1b6nXfvJ6ZWLBwqjDF9sFBN8IcWJLHqpQwBqFy GRThnegIsp4BAPO+9lZ25sjIIltbekywb5nIbRltwcC/ks1DB8pZsa2uBJ4KRau5LLAM bUFAQdNT09MDLfnqeh2xpLZp4hS5MBOldpo9LGJ21+HkrIgRP3tMyCAvSRiez4O2rZ5t 7lKnWXM0nxVmbhC/ASOAUJV8T1JRbrFkqKiD3KYvIZweMjdSnj2rApgSaKv3c85y8d7N 4v5Q== X-Gm-Message-State: ALoCoQkNEiFDH32Sc8gwyPD/XsSYo3uJRmOI1/WRBw4UT+ErzkqR2QxxxJbibK/T3vDY3AlPUSuB X-Received: by 10.180.73.143 with SMTP id l15mr17182001wiv.24.1418313758941; Thu, 11 Dec 2014 08:02:38 -0800 (PST) Received: from mpn-glaptop.corp.google.com ([2620:0:105f:310:6593:e074:890e:2cc7]) by mx.google.com with ESMTPSA id h14sm2846092wic.8.2014.12.11.08.02.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Dec 2014 08:02:38 -0800 (PST) From: Michal Nazarewicz To: Stefan Monnier Subject: [PATCHv2 2/2] eldoc: convert `eldoc-documentation-function' into a defcustom Date: Thu, 11 Dec 2014 17:02:32 +0100 Message-Id: <1418313752-13536-2-git-send-email-mpn@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1418313752-13536-1-git-send-email-mpn@google.com> References: <1418313752-13536-1-git-send-email-mpn@google.com> X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) From: Michal Nazarewicz * lisp/emacs-lisp/eldoc.el (eldoc-documentation-function): Change from defvar to defcustom with `describe-char-eldoc' function as one of the suggested values. Describe how major modes should use `add-function' to alter value of the defcustom. * lisp/hexl.el (hexl-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/ielm.el (inferior-emacs-lisp-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/progmodes/cfengine.el (cfengine3-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/progmodes/elisp-mode (emacs-lisp-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/progmodes/octave.el (octave-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/progmodes/python.el (python-mode): Set `eldoc-documentation-function' using `add-function' so the default value is always used. * lisp/simple.el (read--expression): Set `eldoc-documentation-function' using `add-function' so the default value is always used. --- lisp/emacs-lisp/eldoc.el | 15 ++++++++++++--- lisp/hexl.el | 4 ++-- lisp/ielm.el | 6 +++--- lisp/progmodes/cfengine.el | 3 ++- lisp/progmodes/elisp-mode.el | 4 ++-- lisp/progmodes/octave.el | 3 ++- lisp/progmodes/python.el | 4 ++-- lisp/simple.el | 4 ++-- 8 files changed, 27 insertions(+), 16 deletions(-) diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 2ee3d23..2360954 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -323,8 +323,8 @@ Otherwise work like `message'." ;;;###autoload -(defvar eldoc-documentation-function #'ignore - "Function to call to return doc string. +(defcustom eldoc-documentation-function #'ignore + "Function to call to return doc string for ElDoc mode. The function of no args should return a one-line string for displaying doc about a function etc. appropriate to the context around point. It should return nil if there's no doc appropriate for the context. @@ -336,7 +336,16 @@ the variables `eldoc-argument-case' and `eldoc-echo-area-use-multiline-p', and the face `eldoc-highlight-function-argument', if they are to have any effect. -This variable is expected to be set buffer-locally by modes that support ElDoc.") +Major modes should modify this variable using `add-function', for example: + (add-function :before-until (local 'eldoc-documentation-function) + #'foo-mode-eldoc-function) +so that the global documentation function (i.e. the default value of the +variable) is taken into account if the major mode specific function does not +return any documentation." + :type '(radio (function-item describe-char-eldoc) + function + (const :tag "No documentation function" #'ignore)) + :group 'eldoc) (defun eldoc-print-current-symbol-info () ;; This is run from post-command-hook or some idle timer thing, diff --git a/lisp/hexl.el b/lisp/hexl.el index 5c23f49..e1b1f98 100644 --- a/lisp/hexl.el +++ b/lisp/hexl.el @@ -394,8 +394,8 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode. (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t) ;; Set a callback function for eldoc. - (hexl-mode--setq-local 'eldoc-documentation-function - #'hexl-print-current-point-info) + (add-function :before-until (local 'eldoc-documentation-function) + #'hexl-print-current-point-info) (eldoc-add-command-completions "hexl-") (eldoc-remove-command "hexl-save-buffer" "hexl-current-address") diff --git a/lisp/ielm.el b/lisp/ielm.el index 37e66cc..f776f13 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el @@ -380,7 +380,7 @@ nonempty, then flushes the buffer." (*3 ***) (active-process (ielm-process)) (old-standard-output standard-output) - new-standard-output + new-standard-output ielm-temp-buffer) (set-match-data ielm-match-data) (save-excursion @@ -542,8 +542,8 @@ Customized bindings may be defined in `ielm-map', which currently contains: (set (make-local-variable 'completion-at-point-functions) '(comint-replace-by-expanded-history ielm-complete-filename elisp-completion-at-point)) - (setq-local eldoc-documentation-function - #'elisp-eldoc-documentation-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'elisp-eldoc-documentation-function) (set (make-local-variable 'ielm-prompt-internal) ielm-prompt) (set (make-local-variable 'comint-prompt-read-only) ielm-prompt-read-only) (setq comint-get-old-input 'ielm-get-old-input) diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el index 53d5be9..42de44e 100644 --- a/lisp/progmodes/cfengine.el +++ b/lisp/progmodes/cfengine.el @@ -1350,7 +1350,8 @@ to the action header." (when buffer-file-name (shell-quote-argument buffer-file-name))))) - (setq-local eldoc-documentation-function #'cfengine3-documentation-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'cfengine3-documentation-function) (add-hook 'completion-at-point-functions #'cfengine3-completion-function nil t) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index ba70f90..3094dec 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -229,8 +229,8 @@ Blank lines separate paragraphs. Semicolons start comments. :group 'lisp (lisp-mode-variables nil nil 'elisp) (setq imenu-case-fold-search nil) - (setq-local eldoc-documentation-function - #'elisp-eldoc-documentation-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'elisp-eldoc-documentation-function) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local)) diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 7d96363..90b1e44 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -601,7 +601,8 @@ Key bindings: (add-hook 'before-save-hook 'octave-sync-function-file-names nil t) (setq-local beginning-of-defun-function 'octave-beginning-of-defun) (and octave-font-lock-texinfo-comment (octave-font-lock-texinfo-comment)) - (setq-local eldoc-documentation-function 'octave-eldoc-function) + (add-function :before-until (local 'eldoc-documentation-function) + 'octave-eldoc-function) (easy-menu-add octave-mode-menu)) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 63597d5..586109a 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4378,8 +4378,8 @@ Arguments START and END narrow the buffer region to work on." (current-column)))) (^ '(- (1+ (current-indentation)))))) - (set (make-local-variable 'eldoc-documentation-function) - #'python-eldoc-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'python-eldoc-function) (add-to-list 'hs-special-modes-alist `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#" diff --git a/lisp/simple.el b/lisp/simple.el index 9f44798..806581b 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1407,8 +1407,8 @@ display the result of expression evaluation." (minibuffer-with-setup-hook (lambda () ;; FIXME: call emacs-lisp-mode? - (setq-local eldoc-documentation-function - #'elisp-eldoc-documentation-function) + (add-function :before-until (local 'eldoc-documentation-function) + #'elisp-eldoc-documentation-function) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil t) (run-hooks 'eval-expression-minibuffer-setup-hook)) -- 2.2.0.rc0.207.ga3a616c From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 11 11:56:24 2014 Received: (at 19338) by debbugs.gnu.org; 11 Dec 2014 16:56:24 +0000 Received: from localhost ([127.0.0.1]:42961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz72N-0008Vm-RB for submit@debbugs.gnu.org; Thu, 11 Dec 2014 11:56:24 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:36742) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz72M-0008VM-3e for 19338@debbugs.gnu.org; Thu, 11 Dec 2014 11:56:22 -0500 Received: by mail-pa0-f47.google.com with SMTP id kq14so5398654pab.20 for <19338@debbugs.gnu.org>; Thu, 11 Dec 2014 08:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:face:reply-to:date:in-reply-to :message-id:user-agent:mime-version:content-type :content-transfer-encoding; bh=DWAAAXGSi/BcsYwgW5bMzs7K9NxxzUXNiF8fIUIMimY=; b=Q59MykG+MPFkIXT1dw+8ug8Thm6hNjp2EXkfr6RVOOUq6iimLxLYTTuNDMDEvQrE6N RBEPVDTzG85LM2Gm0Ux1D06+awIYoJNabPW7k0yv4bI/suU8Ax+Xlz6GGQcq/Xro08d3 8OjfTdtVk1yQrKp8BzBIFSRzCo/SSXzIHkPGnz0AgmFCivj4ViP2soA91zzYBbpHftw2 0X62rLpzgPwxIZIYRohPVhXw3FD40VyoiVJY9BExzPTwVhChIaZwavYiFjbClvUvcR3l 4Uwhz+M/lOpBW44PhswMvNXR1wjc33mUyZ6MqF20Nb9hLlkoNcpWweKgk/A8GaNZXM51 4hLA== X-Received: by 10.68.129.6 with SMTP id ns6mr18138836pbb.137.1418316975989; Thu, 11 Dec 2014 08:56:15 -0800 (PST) Received: from fortuna ([114.248.243.62]) by mx.google.com with ESMTPSA id pn8sm1864199pdb.34.2014.12.11.08.56.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Dec 2014 08:56:15 -0800 (PST) From: Leo Liu To: Michal Nazarewicz Subject: Re: bug#19338: [PATCHv2 1/2] descr-text: add `describe-char-eldoc' describing character at point References: <1418313752-13536-1-git-send-email-mpn@google.com> Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAoAgMAAADxkFD+AAAADFBMVEUvT09qWs3/pQD///+J kUVcAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9cBBwMLOd3veKQA AACuSURBVBjTldE9CgIxEAXgB+lEyFUC2wo5ikdZ8DSypxhMY7H9VuIVwlqkGRgnm59VsHGafIQ3 CZlAtmKIRaHETgYa12lqvEsPYKf8wXHsPGfqPaUM0g9aJPKFXkmNQmSDqwzz4Fpgpz+6WAPY2z5o uPJJpu0uypcl4nyCibMLQ8lCiVjayLoQvw5LsVKQuHPRR958HZbOcVsKeepcLxpByjycGvnKmY+c MBvrtyjfe0vmuLvdq/kAAAAASUVORK5CYII= Date: Fri, 12 Dec 2014 00:56:09 +0800 In-Reply-To: <1418313752-13536-1-git-send-email-mpn@google.com> (Michal Nazarewicz's message of "Thu, 11 Dec 2014 17:02:31 +0100") Message-ID: <87iohiunva.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (CentOS Linux 7 (Core)) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: 19338@debbugs.gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 2014-12-11 17:02 +0100, Michal Nazarewicz wrote: > `describe-char-eldoc' displays information about character at point, > +and can be used as a default value of `eldoc-documentation-function'. Boy! don't we have enough ways to annoy users? > It is +useful when, for example, one needs to distinguish various > spaces (e.g. ]=C2=A0[, +]=E2=80=82[, ]=E2=80=89[, etc.) while using mono-= spaced font. C-x =3D Leo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 11 11:59:44 2014 Received: (at 19338) by debbugs.gnu.org; 11 Dec 2014 16:59:44 +0000 Received: from localhost ([127.0.0.1]:42966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz75c-00009M-I0 for submit@debbugs.gnu.org; Thu, 11 Dec 2014 11:59:44 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:20592) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz75a-000097-JL for 19338@debbugs.gnu.org; Thu, 11 Dec 2014 11:59:43 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjwPAOwQflRFxIoH/2dsb2JhbABbgweDYIVaxR0EAgKBJBcBAQEBAQF8hAMBAQMBViMFCwsOJhIUGA0kiEoJ1lkBAQEBAQUBAQEBAR2QbweESAWLAaQugXiCN4FiIYJ3AQEB X-IPAS-Result: AjwPAOwQflRFxIoH/2dsb2JhbABbgweDYIVaxR0EAgKBJBcBAQEBAQF8hAMBAQMBViMFCwsOJhIUGA0kiEoJ1lkBAQEBAQUBAQEBAR2QbweESAWLAaQugXiCN4FiIYJ3AQEB X-IronPort-AV: E=Sophos;i="5.07,502,1413259200"; d="scan'208";a="100204095" Received: from 69-196-138-7.dsl.teksavvy.com (HELO pastel.home) ([69.196.138.7]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Dec 2014 11:59:36 -0500 Received: by pastel.home (Postfix, from userid 20848) id 7ED6D262D; Thu, 11 Dec 2014 11:59:36 -0500 (EST) From: Stefan Monnier To: Michal Nazarewicz Subject: Re: bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results Message-ID: References: <1418232280-16915-1-git-send-email-mpn@google.com> <1418233785-18020-1-git-send-email-mpn@google.com> Date: Thu, 11 Dec 2014 11:59:36 -0500 In-Reply-To: (Stefan Monnier's message of "Wed, 10 Dec 2014 21:38:44 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > course that requires fixing the default value of > eldoc-documentation-function). Which I fixed yesterday, by the way, Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 11 12:22:06 2014 Received: (at 19338) by debbugs.gnu.org; 11 Dec 2014 17:22:06 +0000 Received: from localhost ([127.0.0.1]:43005 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz7RG-0000lA-4J for submit@debbugs.gnu.org; Thu, 11 Dec 2014 12:22:06 -0500 Received: from mail-wg0-f46.google.com ([74.125.82.46]:49092) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xz7RD-0000kc-FL for 19338@debbugs.gnu.org; Thu, 11 Dec 2014 12:22:04 -0500 Received: by mail-wg0-f46.google.com with SMTP id x13so7102854wgg.33 for <19338@debbugs.gnu.org>; Thu, 11 Dec 2014 09:21:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:face:date:message-id:mime-version:content-type :content-transfer-encoding; bh=6nk54adhGNaGsls5T3vqFW2RmgvvK+R90uGCToEuSBA=; b=psfY1EYfcRB4T57aQGr4dIpXv45EvHtN2MCUevFeMUzb1ILEB3hxrBZ0s2HtG0xhFr xefr/EvXwXCdquoIaJ4Ko18SqLaoixV3r58cwdcbsVnwKt9p+3rJvWQ2XvFiBJAFLxcY kyxDLF/Xl9DSd/uycP7jUqe7y6tGJWeAcSMfrHLgb5wG47oiJddBt3b4koW7siVmVIg+ 26OhDO+yCNqxemaJ5+xIlZebHMjabUHBA1vtLYl8QhVXMIgWFHsV4kaApvERgh67MNMo a7AJ1B/sTbF030GKLo5WXE2yaQK1kubGVOorOD+VIbNtKo23rHnZX43URomWvnIqovxP RL9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to :organization:references:user-agent:face:date:message-id :mime-version:content-type:content-transfer-encoding; bh=6nk54adhGNaGsls5T3vqFW2RmgvvK+R90uGCToEuSBA=; b=QHXlcjDu3ZeMbSNmjKlqQOfRpDS6qZT7Q/IS5mhBAupWSOaneMx4+FmRfFgGUJsAHW Q0jvtF1vUpwxkpH+MRLUlrGQ+B+1z1OpaAGOcnXaJSrEqlcgVEh4n8N/vJ9IhIyRaJuJ 0gjtPCcWJgDnvtQ4q57VE5kMZZnoYaJCqy8tRBlIPzJlyBGDsGiYa35trXLf6kcKnKmn kaPEMVt2rfjLUeQj903hGLEW6hG2yTyUYIgWAoQIah9a7tloYgLMnQsBdX0C6oUDRgQa OuaxCjsVirxQfz/b2JZPvwaXdeMUqbrHLRHTJiqLhYVrLRQBQILWJbVmU4tp625v9N0+ dZbg== X-Gm-Message-State: ALoCoQl5MuLxtgsV5542TN4JvceIyFWah5MYMV9nz4N3phc/F7SlWDwSb4vWrXViP9c33ppmGYKq X-Received: by 10.194.201.137 with SMTP id ka9mr19380345wjc.66.1418318512004; Thu, 11 Dec 2014 09:21:52 -0800 (PST) Received: from mpn-glaptop.roam.corp.google.com ([2620:0:105f:310:6593:e074:890e:2cc7]) by mx.google.com with ESMTPSA id vy7sm2446778wjc.27.2014.12.11.09.21.50 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 11 Dec 2014 09:21:51 -0800 (PST) From: Michal Nazarewicz To: Leo Liu Subject: Re: bug#19338: [PATCHv2 1/2] descr-text: add `describe-char-eldoc' describing character at point In-Reply-To: <87iohiunva.fsf@gmail.com> Organization: http://mina86.com/ References: <1418313752-13536-1-git-send-email-mpn@google.com> <87iohiunva.fsf@gmail.com> User-Agent: Notmuch/0.19~rc1+1~g03aea4f (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-unknown-linux-gnu) X-Face: PbkBB1w#)bOqd`iCe"Ds{e+!C7`pkC9a|f)Qo^BMQvy\q5x3?vDQJeN(DS?|-^$uMti[3D*#^_Ts"pU$jBQLq~Ud6iNwAw_r_o_4]|JO?]}P_}Nc&"p#D(ZgUb4uCNPe7~a[DbPG0T~!&c.y$Ur,=N4RT>]dNpd; KFrfMCylc}gc??'U2j,!8%xdD Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACQElEQVQ4jW3TMWvbQBQHcBk1xE6WyALX1069oZBMlq+ouUwpEQQ6uRjttkWP4CmBgGM0BQLBdPFZYPsyFUo6uEtKDQ7oy/U96XR2Ux8ehH/89Z6enqxBcS7Lg81jmSuujrfCZcLI/TYYvbGj+jbgFpHJ/bqQAUISj8iLyu4LuFHJTosxsucO4jSDNE0Hq3hwK/ceQ5sx97b8LcUDsILfk+ovHkOIsMbBfg43VuQ5Ln9YAGCkUdKJoXR9EclFBhixy3EGVz1K6eEkhxCAkeMMnqoAhAKwhoUJkDrCqvbecaYINlFKSRS1i12VKH1XpUd4qxL876EkMcDvHj3s5RBajHHMlA5iK32e0C7VgG0RlzFPvoYHZLRmAC0BmNcBruhkE0KsMsbEc62ZwUJDxWUdMsMhVqovoT96i/DnX/ASvz/6hbCabELLk/6FF/8PNpPCGqcZTGFcBhhAaZZDbQPaAB3+KrWWy2XgbYDNIinkdWAFcCpraDE/knwe5DBqGmgzESl1p2E4MWAz0VUPgYYzmfWb9yS4vCvgsxJriNTHoIBz5YteBvg+VGISQWUqhMiByPIPpygeDBE6elD973xWwKkEiHZAHKjhuPsFnBuArrzxtakRcISv+XMIPl4aGBUJm8Emk7qBYU8IlgNEIpiJhk/No24jHwkKTFHDWfPniR4iw5vJaw2nzSjfq2zffcE/GDjRC2dn0J0XwPAbDL84TvaFCJEU4Oml9pRyEUhR3Cl2t01AoEjRbs0sYugp14/4X5n4pU4EHHnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:141211:sdl.web@gmail.com::H+poH0UMqSNOBACq:000000000000000000000000000000000000000000000pQc X-Hashcash: 1:20:141211:monnier@iro.umontreal.ca::uLAKDGTzmrjcK+xu:00000000000000000000000000000000000000u6+ X-Hashcash: 1:20:141211:19338@debbugs.gnu.org::SnQ+u+jrXvyEC0+p:00000000000000000000000000000000000000002GCm Date: Thu, 11 Dec 2014 18:21:49 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) > On 2014-12-11 17:02 +0100, Michal Nazarewicz wrote: >> `describe-char-eldoc' displays information about character at point, >> +and can be used as a default value of `eldoc-documentation-function'. On Fri, Dec 12 2014, Leo Liu wrote: > Boy! don't we have enough ways to annoy users? It's not enabled by default and you don't have to use it. >> It is +useful when, for example, one needs to distinguish various >> spaces (e.g. ]=C2=A0[, +]=E2=80=82[, ]=E2=80=89[, etc.) while using mono= -spaced font. > C-x =3D C-x =3D (i) is two keystrokes, and (ii) does not even give character's name. C-u C-x =3D (i) is three keystrokes, (ii) pops up a new window, which later needs to be closed somehow, (iii) contents of which is actually terribly hard to read (e.g. name of the character is somewhere in the middle). --=20 Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz = (o o) ooo +------ooO--(_)--Ooo-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 14 14:47:02 2014 Received: (at 19338) by debbugs.gnu.org; 14 Dec 2014 19:47:02 +0000 Received: from localhost ([127.0.0.1]:46268 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0F89-0003Cn-Ar for submit@debbugs.gnu.org; Sun, 14 Dec 2014 14:47:02 -0500 Received: from mtaout24.012.net.il ([80.179.55.180]:46476) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0F83-0003CQ-RY for 19338@debbugs.gnu.org; Sun, 14 Dec 2014 14:46:57 -0500 Received: from conversion-daemon.mtaout24.012.net.il by mtaout24.012.net.il (HyperSendmail v2007.08) id <0NGL008007EVY000@mtaout24.012.net.il> for 19338@debbugs.gnu.org; Sun, 14 Dec 2014 21:38:59 +0200 (IST) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout24.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NGL0050G7WZJM50@mtaout24.012.net.il>; Sun, 14 Dec 2014 21:38:59 +0200 (IST) Date: Sun, 14 Dec 2014 21:46:33 +0200 From: Eli Zaretskii Subject: Re: bug#19338: [PATCHv2 1/2] descr-text: add `describe-char-eldoc' describing character at point In-reply-to: <1418313752-13536-1-git-send-email-mpn@google.com> X-012-Sender: halo1@inter.net.il To: Michal Nazarewicz Message-id: <83egs2xbdy.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 8BIT References: <1418313752-13536-1-git-send-email-mpn@google.com> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org, monnier@IRO.UMontreal.CA X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Michal Nazarewicz > Date: Thu, 11 Dec 2014 17:02:31 +0100 > Cc: 19338@debbugs.gnu.org > > From: Michal Nazarewicz > > * lisp/descr-text.el (describe-char-eldoc): New function returning > basic Unicode codepoint information (e.g. name) about character > at point. It is meant to be used as a default value of the > `eldoc-documentation-function' variable. > (describe-char-eldoc--format, describe-char-eldoc--truncate): > New helper functions for `describe-char-eldoc' function. > > * tests/automated/descr-text-test.el: New file with tests for > `describe-char-eldoc--truncate', `describe-char-eldoc--format', > and `describe-char-eldoc'. Thanks. Allow me a few comments about the documentation parts. > +(defun describe-char-eldoc--truncate (name width) > + "Truncate NAME at white spaces such that it is no longer than WIDTH. > + > +If NAME consists of white space only, return an empty string. > + > +Otherwise, if NAME consists of a single word (where word is defined as sequence > +of non-white space characters), return that word even if it's longer than WIDTH. > + > +Otherwise, if first word in NAME is longer or equal WIDTH, return that word with > +ellipsis character (\"…\") appended; this results in a string longer than WIDTH. > + > +Otherwise, take as many words from NAME as possible, separating them with > +a single space character, while not exceeding WIDTH characters length limit. If > +not all words fit, append ellipsis character (\"…\") at the end; the ellipsis is > +counted towards WIDTH." The lines in this doc string are too long, some of them are longer than 79 characters, which will overflow the typical line width on a TTY. More importantly, this kind of "pseudo-code" description of what the function does is not the best way of documenting a function. It is best to describe it in natural-language terms, and start with the most general, then go to the corner cases. Pseudo-code usually forces you to describe the corner cases first, which is confusing and might lead the reader to wrong conclusions. Likewise with minor details, like the fact that words are separated with a single space: this should be mentioned only after you describe the main job. > + (let ((ellipsis (and (cdr last) "…"))) Btw, will this display OK on a TTY? Not all TTYs support UTF-8. > +Full description message has a \"U+: (: )\" > +format where: > +- is a hexadecimal codepoint of the character (zero-padded to at least > + four digits), > +- is name of the character. We don't use to describe parameters, we use THIS STYLE. > +(defun describe-char-eldoc () > + "Returns a description of character at point for use by ElDoc mode. "Return", not "Returns". > +If character at point is a printable ASCII character (i.e. codepoint between 32 > +and 127 inclusively), nil is returned. Otherwise a description formatted by > +`describe-char-eldoc--format' function is returned taking into account value Here you suddenly switch to passive tense, which is both longer and make the sentence more complicated. Try sticking to active as much as is practical. Thanks again for working on this. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 14 15:41:07 2014 Received: (at 19338) by debbugs.gnu.org; 14 Dec 2014 20:41:07 +0000 Received: from localhost ([127.0.0.1]:46274 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0FyU-0004RJ-0A for submit@debbugs.gnu.org; Sun, 14 Dec 2014 15:41:06 -0500 Received: from mail-wi0-f179.google.com ([209.85.212.179]:47550) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0FyQ-0004Qg-Rz for 19338@debbugs.gnu.org; Sun, 14 Dec 2014 15:41:04 -0500 Received: by mail-wi0-f179.google.com with SMTP id ex7so7155216wid.12 for <19338@debbugs.gnu.org>; Sun, 14 Dec 2014 12:40:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:face:date:message-id:mime-version:content-type :content-transfer-encoding; bh=CN5uMogrIcAzG6+paMUC8G4iaTGZC//BUR+lnlv6uZs=; b=orphj3iMSKB2VJCkF9cUf66j8de9apolVXIbZrFrO8KA0nmo7uKvg5afamx9cze8N/ 4kfcHqa/LmSSKvn5BvqS5q8PHTKe0oQg2SfFsk3oZbru6Rlmfs3bS4pZd1U1CLPeHkkY K7sHD4y+1mXHaeX5su8050XooioezDjjIwyAKuWbxHuB2Ys2RIIqeVfFZC/1yQ7UVH9S Ao/MsnDLLzcyo+F6G5yRWKXVTgJSe2ypDbirW5uTOUT5Q2xrQ0kzywj8qwXLLEfHEFuz fMTYQqAQeLhKR1TejpA3eEJvesvNw74WRlDEHP1VEiwp7+iAEB8aS0TsO89UEcA4TXQw 1gRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to :organization:references:user-agent:face:date:message-id :mime-version:content-type:content-transfer-encoding; bh=CN5uMogrIcAzG6+paMUC8G4iaTGZC//BUR+lnlv6uZs=; b=DfJ1aLsXvqS+W5K/CUvnHEC/MoBf3ioFj20AqoAhRtYuCaODml0r8PdalUpGoJyiJ2 HwcfgEzbUPWeVqta4UFuX2eO9JCzpqj4T4nU5S3f+S0hPm13uWm7W24VZEv/NoQoCJKu 5jfwtjIl6nIy/6MRPSLxEglyppX847HOscI+JHpQStHbBnQuFSpcFOUqVaQS/BojQ2h/ LYp55L37kfpV4/MHIxtbHHZnc4JQj2ldUD0ikOlhZdlcKze3y+Y4IadayPE8pKrnPy4b Knxy8O8vqOnL0AlS4LJ6dqAnFI8yr27NDIvVVr7K+8lO209OezsolxCyOQgUyXmT4unh CEtw== X-Gm-Message-State: ALoCoQlkC9/sRmLJh4FFYaVHhcKdR29tgPk+wRvxnTtkhQoGUM0aUvZq//sFOANq0O+42ML+Bza0 X-Received: by 10.180.206.47 with SMTP id ll15mr26308592wic.34.1418589656985; Sun, 14 Dec 2014 12:40:56 -0800 (PST) Received: from mpn-glaptop.roam.corp.google.com (65-224.197-178.cust.bluewin.ch. [178.197.224.65]) by mx.google.com with ESMTPSA id w10sm10468623wje.10.2014.12.14.12.40.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 14 Dec 2014 12:40:55 -0800 (PST) From: Michal Nazarewicz To: Eli Zaretskii Subject: [PATCHv3 1/2] descr-text: add `describe-char-eldoc' describing character at point In-Reply-To: <83egs2xbdy.fsf@gnu.org> Organization: http://mina86.com/ References: <1418313752-13536-1-git-send-email-mpn@google.com> <83egs2xbdy.fsf@gnu.org> User-Agent: Notmuch/0.19~rc1+1~g03aea4f (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-unknown-linux-gnu) X-Face: PbkBB1w#)bOqd`iCe"Ds{e+!C7`pkC9a|f)Qo^BMQvy\q5x3?vDQJeN(DS?|-^$uMti[3D*#^_Ts"pU$jBQLq~Ud6iNwAw_r_o_4]|JO?]}P_}Nc&"p#D(ZgUb4uCNPe7~a[DbPG0T~!&c.y$Ur,=N4RT>]dNpd; KFrfMCylc}gc??'U2j,!8%xdD Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACQElEQVQ4jW3TMWvbQBQHcBk1xE6WyALX1069oZBMlq+ouUwpEQQ6uRjttkWP4CmBgGM0BQLBdPFZYPsyFUo6uEtKDQ7oy/U96XR2Ux8ehH/89Z6enqxBcS7Lg81jmSuujrfCZcLI/TYYvbGj+jbgFpHJ/bqQAUISj8iLyu4LuFHJTosxsucO4jSDNE0Hq3hwK/ceQ5sx97b8LcUDsILfk+ovHkOIsMbBfg43VuQ5Ln9YAGCkUdKJoXR9EclFBhixy3EGVz1K6eEkhxCAkeMMnqoAhAKwhoUJkDrCqvbecaYINlFKSRS1i12VKH1XpUd4qxL876EkMcDvHj3s5RBajHHMlA5iK32e0C7VgG0RlzFPvoYHZLRmAC0BmNcBruhkE0KsMsbEc62ZwUJDxWUdMsMhVqovoT96i/DnX/ASvz/6hbCabELLk/6FF/8PNpPCGqcZTGFcBhhAaZZDbQPaAB3+KrWWy2XgbYDNIinkdWAFcCpraDE/knwe5DBqGmgzESl1p2E4MWAz0VUPgYYzmfWb9yS4vCvgsxJriNTHoIBz5YteBvg+VGISQWUqhMiByPIPpygeDBE6elD973xWwKkEiHZAHKjhuPsFnBuArrzxtakRcISv+XMIPl4aGBUJm8Emk7qBYU8IlgNEIpiJhk/No24jHwkKTFHDWfPniR4iw5vJaw2nzSjfq2zffcE/GDjRC2dn0J0XwPAbDL84TvaFCJEU4Oml9pRyEUhR3Cl2t01AoEjRbs0sYugp14/4X5n4pU4EHHnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:141214:monnier@iro.umontreal.ca::itdohZ+elAf9vqYk:000000000000000000000000000000000000014NX X-Hashcash: 1:20:141214:19338@debbugs.gnu.org::sleRYzJWjJftNceB:00000000000000000000000000000000000000007gYD X-Hashcash: 1:20:141214:eliz@gnu.org::XEvcJsbSPXPf/U5R:00000CQqD Date: Sun, 14 Dec 2014 21:40:47 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338 Cc: 19338@debbugs.gnu.org, monnier@IRO.UMontreal.CA X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) * lisp/descr-text.el (describe-char-eldoc): New function returning basic Unicode codepoint information (e.g. name) about character at point. It is meant to be used as a default value of the `eldoc-documentation-function' variable. (describe-char-eldoc--format, describe-char-eldoc--truncate): New helper functions for `describe-char-eldoc' function. * tests/automated/descr-text-test.el: New file with tests for `describe-char-eldoc--truncate', `describe-char-eldoc--format', and `describe-char-eldoc'. --- etc/NEWS | 8 +++- lisp/descr-text.el | 97 +++++++++++++++++++++++++++++++++++= ++++ test/automated/descr-text-test.el | 94 +++++++++++++++++++++++++++++++++++= ++ 3 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 test/automated/descr-text-test.el >> + (let ((ellipsis (and (cdr last) "=E2=80=A6"))) On Sun, Dec 14 2014, Eli Zaretskii wrote: > Btw, will this display OK on a TTY? Not all TTYs support UTF-8. It will if TTY supports UTF-8. ;) Perhaps it's not a problem on TTYs that do not because people are unlikely to open documents using Unicode on such TTYs? I used =E2=80=9C=E2=80=A6=E2=80=9D because it's a single character so it do= es not carve cut that much from the WIDTH (alternative =E2=80=9C...=E2=80=9D would be three chara= cters). In any event, changed it to =E2=80=9C...=E2=80=9D. diff --git a/etc/NEWS b/etc/NEWS index e5656fa..53dc795 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -218,8 +218,12 @@ typing RET. result of the calculation into the current buffer. =20 ** ElDoc -*** New minor mode global-eldoc-mode -*** eldoc-documentation-function now defaults to nil +*** New minor mode `global-eldoc-mode' +*** `eldoc-documentation-function' now defaults to `ignore' +*** `describe-char-eldoc' displays information about character at point, +and can be used as a default value of `eldoc-documentation-function'. It = is +useful when, for example, one needs to distinguish various spaces (e.g. ]= =C2=A0[, +]=E2=80=82[, ]=E2=80=89[, etc.) while using mono-spaced font. =20 ** eww =20 diff --git a/etc/NEWS b/etc/NEWS index e5656fa..53dc795 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -218,8 +218,12 @@ typing RET. result of the calculation into the current buffer. =20 ** ElDoc -*** New minor mode global-eldoc-mode -*** eldoc-documentation-function now defaults to nil +*** New minor mode `global-eldoc-mode' +*** `eldoc-documentation-function' now defaults to `ignore' +*** `describe-char-eldoc' displays information about character at point, +and can be used as a default value of `eldoc-documentation-function'. It = is +useful when, for example, one needs to distinguish various spaces (e.g. ]= =C2=A0[, +]=E2=80=82[, ]=E2=80=89[, etc.) while using mono-spaced font. =20 ** eww =20 diff --git a/lisp/descr-text.el b/lisp/descr-text.el index 1dc43e9..56f5866 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el @@ -825,6 +825,102 @@ relevant to POS." =20 (define-obsolete-function-alias 'describe-char-after 'describe-char "22.1") =20 +;;; Describe-Char-ElDoc + +(defun describe-char-eldoc--truncate (name width) + "Truncate NAME at white spaces such that it is no longer than WIDTH. + +Split NAME on white space character and return string with as +many leading words of NAME as possible without exceeding WIDTH +characters. If NAME consists of white space characters only, +return an empty string. Three dots (\"...\") are appended to +returned string if some of the words from NAME have been omitted. + +NB: Function may return string longer than WIDTH if name consists +of a single word, or it's first word is longer than WIDTH +characters." + (let ((words (split-string name))) + (if words + (let ((last words)) + (setq width (- width (length (car words)))) + (while (and (cdr last) + (<=3D (+ (length (cadr last)) (if (cddr last) 4 1)) = width)) + (setq last (cdr last)) + (setq width (- width (length (car last)) 1))) + (let ((ellipsis (and (cdr last) "..."))) + (setcdr last nil) + (concat (mapconcat 'identity words " ") ellipsis))) + ""))) + +(defun describe-char-eldoc--format (ch &optional width) + "Format a description for character CH which is no more than WIDTH chara= cters. + +Full description message has a \"U+HEX: NAME (GC: GENERAL-CATEGORY)\" +format where: +- HEX is a hexadecimal codepoint of the character (zero-padded to at + least four digits), +- NAME is name of the character. +- GC is a two-letter abbreviation of the general-category of the + character, and +- GENERAL-CATEGORY is full name of the general-category of the + character. + +If WIDTH is non-nil some elements of the description may be +omitted to accommodate the length restriction. Under certain +condition, the function may return string longer than WIDTH, see +`describe-char-eldoc--truncate'." + (let ((name (get-char-code-property ch 'name))) + (when name + (let* ((code (propertize (format "U+%04X" ch) + 'face 'font-lock-constant-face)) + (gc (get-char-code-property ch 'general-category)) + (gc-desc (char-code-property-description 'general-category gc= ))) + + (unless (or (not width) (<=3D (length name) width)) + (setq name (describe-char-eldoc--truncate name width))) + (setq name (concat (substring name 0 1) (downcase (substring name = 1)))) + (setq name (propertize name 'face 'font-lock-variable-name-face)) + + (setq gc (propertize (symbol-name gc) 'face 'font-lock-comment-fac= e)) + (when gc-desc + (setq gc-desc (propertize gc-desc 'face 'font-lock-comment-face)= )) + + (let ((lcode (length code)) + (lname (length name)) + (lgc (length gc)) + (lgc-desc (and gc-desc (length gc-desc)))) + (cond + ((and gc-desc + (or (not width) (<=3D (+ lcode lname lgc lgc-desc 7) widt= h))) + (concat code ": " name " (" gc ": " gc-desc ")")) + ((and gc-desc (<=3D (+ lcode lname lgc-desc 5) width)) + (concat code ": " name " (" gc-desc ")")) + ((or (not width) (<=3D (+ lcode lname lgc 5) width)) + (concat code ": " name " (" gc ")")) + ((<=3D (+ lname lgc 3) width) + (concat name " (" gc ")")) + (t name))))))) + +;;;###autoload +(defun describe-char-eldoc () + "Return a description of character at point for use by ElDoc mode. + +Return nil if character at point is a printable ASCII +character (i.e. codepoint between 32 and 127 inclusively). +Otherwise return a description formatted by +`describe-char-eldoc--format' function taking into account value +of `eldoc-echo-area-use-multiline-p' variable and width of +minibuffer window for width limit. + +This function is meant to be used as a value of +`eldoc-documentation-function' variable." + (let ((ch (following-char))) + (when (and (not (zerop ch)) (or (< ch 32) (> ch 127))) + (describe-char-eldoc--format + ch + (unless (eq eldoc-echo-area-use-multiline-p t) + (1- (window-width (minibuffer-window)))))))) + (provide 'descr-text) =20 ;;; descr-text.el ends here diff --git a/test/automated/descr-text-test.el b/test/automated/descr-text-= test.el new file mode 100644 index 0000000..81ae727 --- /dev/null +++ b/test/automated/descr-text-test.el @@ -0,0 +1,94 @@ +;;; descr-text-test.el --- ERT tests for descr-text.el -*- lexical-binding= : t -*- + +;; Copyright (C) 2014 Free Software Foundation, Inc. + +;; Author: Michal Nazarewicz + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Commentary: + +;; This package defines regression tests for the descr-text package. + +;;; Code: + +(require 'ert) +(require 'descr-text) + + +(ert-deftest descr-text-test-truncate () + "Tests describe-char-eldoc--truncate function." + (should (equal "" + (describe-char-eldoc--truncate " \t \n" 100))) + (should (equal "foo" + (describe-char-eldoc--truncate "foo" 1))) + (should (equal "foo..." + (describe-char-eldoc--truncate "foo wilma fred" 0))) + (should (equal "foo..." + (describe-char-eldoc--truncate + "foo wilma fred" (length "foo wilma")))) + (should (equal "foo wilma..." + (describe-char-eldoc--truncate + "foo wilma fred" (+ 3 (length "foo wilma"))))) + (should (equal "foo wilma..." + (describe-char-eldoc--truncate + "foo wilma fred" (1- (length "foo wilma fred"))))) + (should (equal "foo wilma fred" + (describe-char-eldoc--truncate + "foo wilma fred" (length "foo wilma fred")))) + (should (equal "foo wilma fred" + (describe-char-eldoc--truncate + " foo\t wilma \nfred\t " (length "foo wilma fred"))))) + +(ert-deftest descr-text-test-format-desc () + "Tests describe-char-eldoc--format function." + (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)" + (describe-char-eldoc--format ?=E2=80=A6))) + (should (equal "U+2026: Horizontal ellipsis (Punctuation, Other)" + (describe-char-eldoc--format ?=E2=80=A6 51))) + (should (equal "U+2026: Horizontal ellipsis (Po)" + (describe-char-eldoc--format ?=E2=80=A6 40))) + (should (equal "Horizontal ellipsis (Po)" + (describe-char-eldoc--format ?=E2=80=A6 30))) + (should (equal "Horizontal ellipsis" + (describe-char-eldoc--format ?=E2=80=A6 20))) + (should (equal "Horizontal..." + (describe-char-eldoc--format ?=E2=80=A6 10)))) + +(ert-deftest descr-text-test-desc () + "Tests describe-char-eldoc function." + (with-temp-buffer + (insert "a=E2=80=A6") + (goto-char (point-min)) + (should (eq ?a (following-char))) ; make sure we are where we think we= are + ;; Function should return nil for an ASCII character. + (should (not (describe-char-eldoc))) + + (goto-char (1+ (point))) + (should (eq ?=E2=80=A6 (following-char))) + (let ((eldoc-echo-area-use-multiline-p t)) + ;; Function should return description of an Unicode character. + (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)" + (describe-char-eldoc)))) + + (goto-char (point-max)) + ;; At the end of the buffer, function should return nil and not blow u= p. + (should (not (describe-char-eldoc))))) + + +(provide 'descr-text-test) + +;;; descr-text-test.el ends here --=20 2.2.0.rc0.207.ga3a616c From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 20 09:08:27 2015 Received: (at 19338-done) by debbugs.gnu.org; 20 Jan 2015 14:08:27 +0000 Received: from localhost ([127.0.0.1]:50323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YDZTm-0002Vu-SS for submit@debbugs.gnu.org; Tue, 20 Jan 2015 09:08:27 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:49155) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YDZTk-0002Vg-4O for 19338-done@debbugs.gnu.org; Tue, 20 Jan 2015 09:08:24 -0500 Received: by mail-wi0-f174.google.com with SMTP id n3so3418490wiv.1 for <19338-done@debbugs.gnu.org>; Tue, 20 Jan 2015 06:08:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:subject:in-reply-to:organization:references :user-agent:face:date:message-id:mime-version:content-type :content-transfer-encoding; bh=9uMWP180i/fa9/2AKXTyzKxyaDg9PxnDKwF+XAR9sYs=; b=Zh2sJVgGSPx1tx1z0YZmIYZ8dVAeNVwcZW2f/n6EAJKVM16ZGPZy8lK0OTfF9q5V/K sVmE5x7kVPadVwYrpW5CQ9Gu2/9a9qIMQSS2EvPpA07HxMk3eDo6ctMCp6QqQJbN4ZRA UWvl8jYxbpv+pfSVzHGX14Y9HLSAr1WLInSNOLHNggZhsNmRM88zd8xmktfFKrTrtFSJ i8MqOfmdIbDGTkvk1CNI2+MqA5OaN0Y/rj7nqJxSz131dj1/UuSydiZXOsFX7I1YxnKZ FZ/rPdxhxzQpkTGE6uDIvndHc7BwI1luFk8Kfk+I7CPhGBw+J4o1yaIr5rZd5HmSTGyj u2Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:in-reply-to:organization :references:user-agent:face:date:message-id:mime-version :content-type:content-transfer-encoding; bh=9uMWP180i/fa9/2AKXTyzKxyaDg9PxnDKwF+XAR9sYs=; b=EjToNh9sy7IXu1OMQr0vicMXdR7kPzxk0dsIEJ7olvxwYbpPwNaww35etPb8nzfzdt gaydkUzLPIe6RS6g1uFChFrFFMgJwjbghMCyJB5nJLFUe3RL7RHG+TUfendS/hOmYXst TMeDlMl+h0FKvAOWlGn3R9promecgfQTKC7tI15O4LlrM8npCrb+ld79LpZ6vZ0qmfWB TBCsML0uVCzVMsvm3IndviS+uX5r+rZ3MQMjQ9ggkcWpcNDfQN0E0CdY1Z6xCCXdZIVg VXqAcAA7eAIIiikefKCNgi9uUxl7mlXCwIWtMOpo9pPqdlc1MF/Kw6nLfjR+oTcLUNHD 4Eqw== X-Gm-Message-State: ALoCoQkfWGxhMeoNwnkLl/k7njU4cLE+tq5KpeuIFXbxA6dfmrideCpjwyudozUi+66X4BvnW0XV X-Received: by 10.180.95.97 with SMTP id dj1mr46444905wib.43.1421762898111; Tue, 20 Jan 2015 06:08:18 -0800 (PST) Received: from mpn-glaptop ([2620:0:105f:310:359a:ef79:5f3d:4707]) by mx.google.com with ESMTPSA id e18sm21427120wjz.27.2015.01.20.06.08.16 for <19338-done@debbugs.gnu.org> (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 20 Jan 2015 06:08:17 -0800 (PST) From: Michal Nazarewicz To: 19338-done@debbugs.gnu.org Subject: Re: [PATCHv2 2/2] eldoc: convert `eldoc-documentation-function' into a defcustom In-Reply-To: <1418313752-13536-2-git-send-email-mpn@google.com> Organization: http://mina86.com/ References: <1418313752-13536-1-git-send-email-mpn@google.com> <1418313752-13536-2-git-send-email-mpn@google.com> User-Agent: Notmuch/0.19~rc1+1~g03aea4f (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-unknown-linux-gnu) X-Face: PbkBB1w#)bOqd`iCe"Ds{e+!C7`pkC9a|f)Qo^BMQvy\q5x3?vDQJeN(DS?|-^$uMti[3D*#^_Ts"pU$jBQLq~Ud6iNwAw_r_o_4]|JO?]}P_}Nc&"p#D(ZgUb4uCNPe7~a[DbPG0T~!&c.y$Ur,=N4RT>]dNpd; KFrfMCylc}gc??'U2j,!8%xdD Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACQElEQVQ4jW3TMWvbQBQHcBk1xE6WyALX1069oZBMlq+ouUwpEQQ6uRjttkWP4CmBgGM0BQLBdPFZYPsyFUo6uEtKDQ7oy/U96XR2Ux8ehH/89Z6enqxBcS7Lg81jmSuujrfCZcLI/TYYvbGj+jbgFpHJ/bqQAUISj8iLyu4LuFHJTosxsucO4jSDNE0Hq3hwK/ceQ5sx97b8LcUDsILfk+ovHkOIsMbBfg43VuQ5Ln9YAGCkUdKJoXR9EclFBhixy3EGVz1K6eEkhxCAkeMMnqoAhAKwhoUJkDrCqvbecaYINlFKSRS1i12VKH1XpUd4qxL876EkMcDvHj3s5RBajHHMlA5iK32e0C7VgG0RlzFPvoYHZLRmAC0BmNcBruhkE0KsMsbEc62ZwUJDxWUdMsMhVqovoT96i/DnX/ASvz/6hbCabELLk/6FF/8PNpPCGqcZTGFcBhhAaZZDbQPaAB3+KrWWy2XgbYDNIinkdWAFcCpraDE/knwe5DBqGmgzESl1p2E4MWAz0VUPgYYzmfWb9yS4vCvgsxJriNTHoIBz5YteBvg+VGISQWUqhMiByPIPpygeDBE6elD973xWwKkEiHZAHKjhuPsFnBuArrzxtakRcISv+XMIPl4aGBUJm8Emk7qBYU8IlgNEIpiJhk/No24jHwkKTFHDWfPniR4iw5vJaw2nzSjfq2zffcE/GDjRC2dn0J0XwPAbDL84TvaFCJEU4Oml9pRyEUhR3Cl2t01AoEjRbs0sYugp14/4X5n4pU4EHHnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:150120:19338@debbugs.gnu.org::nYxrYI78eQUin4Yd:00000000000000000000000000000000000000004oLs X-Hashcash: 1:20:150120:monnier@iro.umontreal.ca::B9l+VtvYREGb1mw6:0000000000000000000000000000000000000Ghid Date: Tue, 20 Jan 2015 15:08:15 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19338-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Thu, Dec 11 2014, Michal Nazarewicz wrote: > * lisp/emacs-lisp/eldoc.el (eldoc-documentation-function): Change from > defvar to defcustom with `describe-char-eldoc' function as one of the > suggested values. Describe how major modes should use `add-function' to > alter value of the defcustom. FYI, v3 1/2 and this patch pushed to master except without changing the variable to defcustom. --=20 Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz = (o o) ooo +------ooO--(_)--Ooo-- From unknown Tue Aug 19 14:22:54 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 18 Feb 2015 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator