From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Entering emojis Date: Wed, 27 Oct 2021 14:18:40 +0200 Message-ID: <87a6iud5jz.fsf@gnus.org> References: <87cznths5j.fsf@gnus.org> <83zgqxymd3.fsf@gnu.org> <878rygj4gt.fsf@gnus.org> <83wnm0zz0q.fsf@gnu.org> <874k94j3rn.fsf@gnus.org> <83v91kzydh.fsf@gnu.org> <87tuh4holf.fsf@gnus.org> <822aec9d01909cecfc6c@heytings.org> <87a6iwhltf.fsf@gnus.org> <83tuh4zfg5.fsf@gnu.org> <87y26gfobr.fsf@gnus.org> <87tuh4f1ie.fsf@gnus.org> <87pmrrg8gu.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22660"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Jonas Bernoulli Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Oct 27 14:28:39 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mfi2o-0005cG-Tk for ged-emacs-devel@m.gmane-mx.org; Wed, 27 Oct 2021 14:28:39 +0200 Original-Received: from localhost ([::1]:51972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfi2n-000172-Nr for ged-emacs-devel@m.gmane-mx.org; Wed, 27 Oct 2021 08:28:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhtO-0001da-B3 for emacs-devel@gnu.org; Wed, 27 Oct 2021 08:18:54 -0400 Original-Received: from quimby.gnus.org ([2a01:4f9:2b:f0f::2]:40514) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfhtL-0003lq-Hd for emacs-devel@gnu.org; Wed, 27 Oct 2021 08:18:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=njO/ILgcJcDCn2bmGZDm7XAq4x1YbCa3TL2SDTB8M6Y=; b=QEDEV+vOTulTG3pn3spgtRzIeS oi1JF+26TgES71X3icD8AoV96HOtJ+TSnYgp1+CJC0GOTq4R23ojmfI2qocLotBYsDYzRdVgHjCit whlYMz69tKT8wRYriQgGyBSw3nZkbyPs/ZozZN2B24t+aEMh7YTL3Zkykt4zFkEtnq9U=; Original-Received: from [84.212.220.105] (helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mfhtF-0005fS-5w; Wed, 27 Oct 2021 14:18:47 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAD1BMVEX98sP657fap5Cn a1T///9/WVUcAAAAAWJLR0QEj2jZUQAAAAd0SU1FB+UKGwwOOY9ptEwAAAG6SURBVDjLhZTZkcQg DEQRk4CEEwCRwCLln9u2wAee/VjXVA3wrLtxSv89RVVFGCvaTom6WwNosWmJL8CHrbXO3fVLnD2R MJbl8cKEM/N1nvrtJAmeXAfNwOQ7IFIa+Iu4bjcR4qMGmCfu9bHILlQlycxKNlcfpwCrzLTHAGi0 fOcnOBK2AOkbICkjBpjO8l5gHsR67nQHNCiV01V7dXbcvnN9A2L6C1gQ4yqEXmDGEJ1WX8FTdq0x kb3yGUO7O4vobgEypAGoda3vdA2TcxthVV8WaEn3Yoe7vUAydAUm3XkbeeTl1LsVFlU0QB7G/eNj NqVY6rbi0wRuqHPOwL0djw4PnK9xUOHex9k4VPcTL58Osl5CKe3YAZCH/4TufcY1oik67pizYASU LVaR5zLLFX2DjKGf2GK9AJpHJCgbwuQzyEoH0sBbITV0gorrOWCC+iHxSiFMXDXoeQGZupnWH2Z0 NterMj44ACMzJilnW2JCoRaKKzaoaB/pvgOMqiry554Rwx4QogDAFWmIrc8oCEOguJ00Djd9tENI I86FO8bX2l8gaJfslwbfDjlNYIEGpdP3DYRLk/1pv7taMPY8hQ/oAAAAJXRFWHRkYXRlOmNyZWF0 ZQAyMDIxLTEwLTI3VDEyOjE0OjU3KzAwOjAw72dKqwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0x MC0yN1QxMjoxNDo1NyswMDowMJ468hcAAAAASUVORK5CYII= X-Now-Playing: Aksak Maboul's _Figures (1)_: "Silhouettes" In-Reply-To: <87pmrrg8gu.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 26 Oct 2021 16:35:13 +0200") Received-SPF: pass client-ip=2a01:4f9:2b:f0f::2; envelope-from=larsi@gnus.org; helo=quimby.gnus.org X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:277947 Archived-At: Lars Ingebrigtsen writes: > I haven't looked at transient.el internals in details, but extending a > columnar display to variable-pitch circumstances usually isn't a lot of > work: You basically just use window-text-pixel-size to get the width of > the texts, and align with an :align-to display spec. > > Have you looked at extending transient this way? I've now done so -- by adding a new slot to the transient-prefix class. I don't know whether that's the most likely place to stash the info, but this seems to work. Perhaps stashing it in transient-columns would make more sense... Or at least propagating it there. What do you think? (It should be fully backwards compatible -- the output when not supplying this keyword should be identical to the old output.) diff --git a/lisp/transient.el b/lisp/transient.el index c33a4c722a..13dfbf53ec 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -590,7 +590,8 @@ transient-prefix (transient-suffix :initarg :transient-suffix :initform nil) (transient-non-suffix :initarg :transient-non-suffix :initform nil) (incompatible :initarg :incompatible :initform nil) - (suffix-description :initarg :suffix-description)) + (suffix-description :initarg :suffix-description) + (variable-pitch :initarg :variable-pitch :initform nil)) "Transient prefix command. Each transient prefix command consists of a command, which is @@ -2941,6 +2942,18 @@ transient--insert-group (unless (string-match-p ".\n\\'" str) (insert ?\n))))) +(defun transient--pixel-width (string) + (with-temp-buffer + (insert string) + (if (not (get-buffer-window (current-buffer))) + (save-window-excursion + ;; Avoid errors if the selected window is a dedicated one, + ;; and they just want to insert a document into it. + (set-window-dedicated-p nil nil) + (set-window-buffer nil (current-buffer)) + (car (window-text-pixel-size nil (line-beginning-position) (point)))) + (car (window-text-pixel-size nil (line-beginning-position) (point)))))) + (cl-defmethod transient--insert-group ((group transient-columns)) (let* ((columns (mapcar @@ -2951,11 +2964,18 @@ transient--insert-group (push desc rows)) rows)) (oref group suffixes))) + (vp (oref transient--prefix variable-pitch)) (rs (apply #'max (mapcar #'length columns))) (cs (length columns)) - (cw (mapcar (lambda (col) (apply #'max (mapcar #'length col))) + (cw (mapcar (lambda (col) + (apply #'max (mapcar (if vp + #'transient--pixel-width + #'length) + col))) columns)) - (cc (transient--seq-reductions-from (apply-partially #'+ 3) cw 0))) + (cc (transient--seq-reductions-from + (apply-partially #'+ (if vp 30 3)) + cw 0))) (if transient-force-single-column (dotimes (c cs) (dotimes (r rs) @@ -2966,11 +2986,21 @@ transient--insert-group (insert ?\n))) (dotimes (r rs) (dotimes (c cs) - (insert (make-string (- (nth c cc) (current-column)) ?\s)) - (when-let ((cell (nth r (nth c columns)))) - (insert cell)) - (when (= c (1- cs)) - (insert ?\n))))))) + (if vp + (progn + (when-let ((cell (nth r (nth c columns)))) + (insert cell)) + (if (= c (1- cs)) + (insert ?\n) + (insert + (propertize + " " 'display + `(space :align-to (,(nth (1+ c) cc))))))) + (insert (make-string (- (nth c cc) (current-column)) ?\s)) + (when-let ((cell (nth r (nth c columns)))) + (insert cell)) + (when (= c (1- cs)) + (insert ?\n)))))))) (cl-defmethod transient--insert-group ((group transient-subgroups)) (let* ((subgroups (oref group suffixes)) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no