From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eduardo Ochs Newsgroups: gmane.emacs.help Subject: Re: Mouse activated button in modeline Date: Sun, 21 Jul 2024 22:46:35 -0300 Message-ID: References: <10DZZ3c_ssrHn8C6ULFl21Gjy5bHodK7L5A5SGPGeynF7sAT7r0rhcXzn0wQ2ojWizyEdWd1fSZT0S-HFQxPCDDvKPYvnygRKEmnLPzOF9g=@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19061"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 22 03:47:35 2024 Return-path: Envelope-to: geh-help-gnu-emacs@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 1sVi9H-0004pJ-2X for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 22 Jul 2024 03:47:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVi8a-0002PY-Il; Sun, 21 Jul 2024 21:46:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sVi8Z-0002PC-Dq for help-gnu-emacs@gnu.org; Sun, 21 Jul 2024 21:46:51 -0400 Original-Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVi8X-0005Nz-Ks for help-gnu-emacs@gnu.org; Sun, 21 Jul 2024 21:46:51 -0400 Original-Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-e087641d2a2so1414428276.0 for ; Sun, 21 Jul 2024 18:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721612808; x=1722217608; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=czg2zS2VH9Z7nigxkdkExhl6IIPS0u3PM3F/Lp4tDg4=; b=mz2zubS5zuzhtI0YE2dgxI8qR8YymPHT5zve6YxeHPJLcVEoDGo2g2YFE3b0x6XDf2 EcQtmgrWFHpOKzUk59fuafrARTaMmyVUlnNHmHWtfgWJjLadVIk6j1o1zWhGQ3KLqvPj JzgYkLcPdLZfPrmQZYr2YBoGnuOK5KfpaqTPOQzI/jWghZwUO7ZZE6hlyGY0reBVxrB9 JTVzKTxADxxtddF/x688VtcFCZ9yguxGyfh15/b4I4SQ10UKh2HZOINiCN/aV/SEMvOp jjxXPJ/WVlDUlrENGUjJIXR+8BD3Ms25k1pCJdZDEKG9Ldn+MBN+Z1awOFeBrcKePfH2 kbHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721612808; x=1722217608; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=czg2zS2VH9Z7nigxkdkExhl6IIPS0u3PM3F/Lp4tDg4=; b=IR1aETxFhP5137oPsihrbnsAlb7nCl71pt2wv25E1PJVx+3IwKt2mqf4WnS1aX9VpA 1dvCsHAE6OhwRNBV555olW72GOFyiyQCuu/2JCKA31HdI1JIrjw3kj2aqUFc6pMJxmym yPH8nUfmvUJj/C+qSbkX5M+mBEcD/uNhVr88CvOPFC3bp54vq0rUA63QCWQtfojzdrxD vMin/xrqkQ901EIqehumyKl2eDC+75mA0hgDcGIBJ5pSfLiOi7BS1xYCIgNktKBnNqAH vAenI/60nDQCVBYqftjwFjmdVsZtDbyTO0YZxPVsqISOR345pGhkHRyQrXcuN7qbCVFU +AfA== X-Gm-Message-State: AOJu0YztjGBtP5tdT2He7RGAZyuiFJxsg8FtIwKi3xCImfzN4f8YVqjw AKiE/CBhWDVN8pMtLKMx3zScGZYC/yfMpWHdKYhG/Ltriw6WChQoBkPBTBzboRo4w6gayGbLPpB jwtY61hEl12ESn9iou4OkvlJhT737wyY0 X-Google-Smtp-Source: AGHT+IGSlNG0yGnzvxqjWwtWWXdzz/N7GCT3q4vnrXwCouUHUrVAZRroHPvoguazePu0mf6Fd8ozPD5nRV8BeXTp3F0= X-Received: by 2002:a05:690c:2fc1:b0:665:7661:2b7a with SMTP id 00721157ae682-66ad8dc2403mr55922847b3.25.1721612808135; Sun, 21 Jul 2024 18:46:48 -0700 (PDT) In-Reply-To: <10DZZ3c_ssrHn8C6ULFl21Gjy5bHodK7L5A5SGPGeynF7sAT7r0rhcXzn0wQ2ojWizyEdWd1fSZT0S-HFQxPCDDvKPYvnygRKEmnLPzOF9g=@protonmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::b2a; envelope-from=eduardoochs@gmail.com; helo=mail-yb1-xb2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:147299 Archived-At: Here my mode line says U:**- TODO Bot L122542 (Fundamental eev) and when I hover the mouse over the first "*" it says: Buffer is writable mouse-1: toggle Cheers, Eduardo Ochs http://anggtwu.net/#eev On Sun, 21 Jul 2024 at 16:53, Heime wrote: > On Monday, July 22nd, 2024 at 6:15 AM, Heime > wrote: > > > I would like to have a button in modeline I can mouse click to toggle > the file to read-only on-off. > > Why does the following not show the mouse activated button > > (defface mode-line-read-only-face > '((t :background "red" :foreground "white" :weight bold))) > > (defun toggle-read-only-status () > (interactive) > (if buffer-read-only > (read-only-mode -1) > (read-only-mode 1))) > > (defun read-only-button () > (if buffer-read-only > (propertize " RO " > 'face 'mode-line-read-only-face > 'help-echo "Read-Only Buffer - Click to toggle." > 'mouse-face 'mode-line-highlight > 'local-map (make-mode-line-mouse-map > 'mouse-1 'toggle-read-only-status)) > > (propertize " -- " > 'help-echo "Writable Buffer - Click to toggle." > 'mouse-face 'mode-line-highlight > 'local-map (make-mode-line-mouse-map > 'mouse-1 'toggle-read-only-status)))) > > (setq-default mode-line-format > '("%e" '(:eval (read-only-button)) "")) > > > > >