texts: Emacs for Windows: How to M-x compile using MinGW_32

texts:
I have been using Console2 on an MS Windows box to compile and would like to use Emacs instead.  My settings on Console2 are as follows:

shell="c:/mingw/bin/sh.exe --login -i -c 'cd /c/docume~1/admini~1/desktop/;export PATH=/c/mingw/bin:/c/progra~1/git/bin; exec /bin/sh'"

init_dir=""

Q:  How can I configure Emacs to use the MinGW stuff from above so that I can run a command such as (compile "make") in Emacs on a Windows platform?

The following snippet renders an error when trying to compile Emacs from source:  "cmdproxy.exe has encountered a problem and needs to close.  We are sorry for the inconvenience."

  (defun xp-compile ()
(interactive)
(let ((default-directory (w32-short-file-name
                          "c:/Documents and Settings/Administrator/Desktop/emacs"))
      (compilation-environment "PATH=/c/mingw/bin:/c/progra~1/git/bin"))
  (compile "make")))


texts:
I'm using web-mode to edit jsx files and I'm wondering what minor-mode can I use to add folding support. Is there anything out there that works?

Thanks


texts: How to create another instance of (e)shell in a DWIM fashion?

texts:
I have seen several proposals to run more than one instance of eshell (or shell) at a time. See here and here. However, they are inconvenient in my view, using peculiar key chords and forcing you to actively invent ad-hoc buffer names. I'd rather like to have a simple DWIM-like function, e.g. new-eshell, that creates a fresh instance of eshell in an automatically named buffer. Buffer names should be numbered consecutively, i.e., *eshell1*, *eshell2* etc.

Who can help?


texts:
I'm trying multiple methods to load an emacs .el file on startup.

('load-file "~/.emacs.d/extra/outline-presentation-mode.el")

Also:

('load "~/.emacs.d/extra/outline-presentation-mode.el")

Also:

(mapc 'load (file-expand-wildcards "~/.emacs.d/extra/*.el"))

I've also tried adding the extra folder to my path and loading it without the file directory.

If I open emacs and then run:

M-x load-file RET ~/.emacs.d/extra/outline-presentation-mode.el

It works perfectly.

Why isn't it working when I try the same thing from my init.el file? I know the init.el file is running because I set my default bindings with evil-mode using it.

Also tried:

(load "~/.emacs.d/extra/outline-presentation-mode.el")

File I'm loading: https://web.archive.org/web/20160810000826/http://clandest.in/emacs.d/plain/outline-presentation.el


texts: How to adjust image size of an org-babel output permanently?

texts: I know I can add html or latex attributes under the #+result: block after executing the block, but when I re-evaluate the block, it is removed.


texts: How do I make 'org-beginning-of-line' move cursor to the first text in heading body

texts:
For example in a org file (cursor represented as |):

* heading
    this is body |of the heading
    1. some
    2. list

After 'org-beginning-of-line' :

* heading
    |this is body of the heading
    1. some
    2. list

Is there a good way to do this without losing org-mode syntax awareness  org-beginning-of-line provided ?


texts: Using currently the sit-for function, every time i hit any key and cause user input the sit-for will stop. Is there any possibility to have something like sit-for, while being able to move the cursor around an typing and not causing any break of the process in run (with sleeping time intervals in it)?


texts: send orgmode sh babel block to eshell/term in emacs?

texts:
Does anyone know if its possible to send the bash code in a orgmode sh block and run in in a new eshell/term buffer in emacs?
for example as a use case i would like to run/eval a code block like this

#+BEGIN_SRC sh
sudo pacman -Syuu
#+END_SRC

and have the command execute within emacs in term, eshell etc?

is that possible?


texts: Org-mode: disable abbrev-mode in source blocks

texts:
I use org-mode to write an executable paper, combining text and code. I make use of abbrev-mode to insert text more efficiently (e.g. type 'bc' to insert 'because') and to correct spelling errors. Is there any way to switch off abbrev-mode in the source blocks to prevent it expanding my variables?
I did run into this post, but don't see how to use that for my problem. Any help would be appreciated.


texts: How to code a command to `write-region` to a particular file?

texts:
I have a system that I am not allowed permissions to install software but need to copy text from the remote server to the host computer's system clipboard. Because I can't install xclip or xsel and I am using emacs with tmux, the formatting of text gets all screwed up because of the newlines that tmux introduces.  I thought of the possibility of writing regions to a file that I can remotely open the file and manually copy the properly formatted text.
I've created my own keyboard defined macro using write-regions that worked during a current open session of emacs but would have problems upon reopening. Error along the lines of command terminated by ringing the bell.
I've also used the following answer's code but the OP wanted to interactively set the file but in my case the file is known already so there is no need for me to set it each time I use the function.
Is there a way for me to write this function such that the a region automatically writes to ~/copybuffer.txt and doesn't delete the region afterwards. See original QA here and my code edits.
Unfortunately, in my code I see variable is void: start. I clearly don't understand something about defining lisp functions.
(defun copybuffer
  "function takes current region, and writes it to specified file"
  (write-region region-beginning region-end '~/copybuffer.txt' t)))


texts: Scaling of inline SVG previews in org-mode

texts:
If I insert a jpg in my org-mode document, I can preview it and scale its width, like so:

Add the following code to my init.el file:

(setq org-image-actual-width nil)

Then insert this code in my document, where I want the image to appear:

#+ATTR_ORG: :width 300
[[./my_image.jpg]]

On executing org-toggle-inline-images the image appears in the buffer, 300px wide, as expected.

But if I attempt this same operation with an SVG file, I get a blank placeholder. If I then remove the #+ATTR_ORG tag, the SVG appears. (at it's pre-defined width)...

Can anyone tell me how I can resize my SVGs image previews? I am running the macports version of Emacs version 25.1 on El Capitan.

Thanks!


texts: Does package-install do byte-compilation?

texts:
When installing a package from the package menu, can/will package-install do automatic byte compilation of the installed package files? Or is this something the user must do manually himself afterwards?

For example, I have installed auctex from the package menu, but there are no *.elc files in my ~/.emacs.d/elpa/auctex-11.89.5 directory. Also I see from the source of package.el that there is a function package--compile at line 942 (so that should indicate that it can byte-compile)

There is no mention of byte-compilation in the Manual as far as I can see.

I am also wondering that I might have deleted the *.elc files myself and forgotten about it.


texts: Function ‘seq-drop’ is not known to be defined in my package

texts:
I have builded a elisp package. It uses forms like this:

(setq str (seq-drop str 1))

When I byte-compile the package with

$ emacs --batch -f batch-byte-compile albapariet.el

I have the following warning:

In end of data:
albapariet.el:184:1:Warning: the function ‘seq-drop’ is not known to be defined.

How do I get rid of this warning?


texts:
I am using org-mode babel to take notes. I am using source code blocks to write down examples of html interspersed with javascript. I take the notes in a subtree within a pretty big document.
Now, when I edit the source code block I would like to use web mode to have automatic indentation and auto-complete etc. However, somewhere in the document is an unmatched expression, so web-mode will complain. There is no way I will find the unmatched expression (or want to actually).
Is there a way to use web-mode localized so to speak, e.g. only within the source code block? Or could I actually configure org-mode to automatically recognize the language of the source code block and switch modes accordingly w/o having to change manually?


texts: How to make emacs recognize a bash script that ends in .sh?

texts:
I'm trying to get Emacs to understand that my script is bash.

I tried adding -*- bash -*- to the first line of the file, but it still opens in Shell-script[sh] mode. I can rename the file to give it a bash extension (currently it's .sh) but this might break some existing code.

Is there some way to give Emacs this hint?


texts: Test whether current org buffer has at least one heading

texts:
What's a good method of testing whether the current buffer contains at least one heading?

This is the best solution that initially came to mind:

(> (length (org-map-entries nil nil 'file)) 0)


texts: Why in dired+ mode some text is strikethrough?

texts:
Windows 10, Emacs 26.1, Dired+ (download from here https://www.emacswiki.org/emacs/download/dired%2b.el)

Open some directory:

Here result:

Why some text is strikethrough?


texts:
Org-mode has a face org-verbatim. But it does not support ' at begin or end. (same for =)
I use \equal{} to replace = in org-verbatim highlighted string.
But I don't know how to replace '.
Does anybody knows that?

Update:
here is the minimal example:

=$ put 'string'=
=$ put "string"=


texts: How should I get the filename of the original buffer in an indirect cloned buffer?

texts:
I wanted to look at different portions of a buffer in two different frames, as I have two monitors of different shapes that I can't easily span a single frame over. Some googling led me to use clone-indirect-buffer, which works nicely.

However, buffer-file-name for the new buffer is nil. How can I reliably determine the filename of the original buffer (that this one is a clone of)?


texts: Is it possible to archive org-mode agenda entries from a given date range?

texts:
My emacs org-mode agenda files are steadily growing, and many of my projects span several to many years.  In addition, I need to last access the entries after about a year.  Hence rather than (or in addition to) archiving my agenda entries per project, I would like to archive all my agenda entries from a given date range, for example (half) a calendar year.  Is this possible somehow?  Since I need to do this once or twice a year, it isn't too bad if I need more than a few keystrokes for this action (which I could stick in a macro anyway).  Even if the solution would only work for a given month or calendar year, rather than any random date range, it would help me.
My work agenda file has a structure like below.  I would like that structure to be kept in the archive file, in case I ever need to figure out how much time I spent on a given project or on all my teaching years later.
* Research
** Project 1
** Project 2
** Project N
* Teaching
** Class 1
** Class 2


texts: Change company-backends for tramp buffers

texts:
How do I change the company backends for remote buffers? Tramp doesn't seem to provide any useful hooks ...
Related:

Using different theme on tramp buffers (and buffer-related themes in general)?


texts: How to trim whitespace from the end of a multi-line string?

texts:
It seems subr-x's string-trim-right only operates on the last line.

How to strip trailing spaces on all lines in a variable?


texts: How to make the current window display the buffer it was displaying before the current one?

texts:
For example, imagine I have two windows and three buffers. Both windows are displaying buffer 1 and I do the following,

in window 1, switch to buffer 2;
in window 2, switch to buffer 3, then to buffer 2.

Now both widows are displaying buffer 2. This command, invoked in window 1 would switch to buffer 1 and invoked in window 2 would switch to buffer 3. Invoked again it would bring back the selected window to buffer 2, that is, it should just cycle between the last two buffers displayed in the selected window, not transverse the window's buffer history.


texts: Projectile: where is the project name stored / set?

texts:
I'm using Projectile, and after seeing the really awesome .emacs file I decided to copy the lines that set the mode-line to display the project name, like so:

:config
  (projectile-global-mode 1)
  (setq-default ;; <snip>
   projectile-mode-line '(:eval (projectile-project-name))))

I've got this included in my init.el and it almost works - the only problem is that the variable projectile-project-name is nil, so it doesn't actually show the name of the project (and this is even after I've done C-C p p and chosen a project.

How is projectile-project-name set and/or where is that information stored? (Maybe in the .projectile file?)


texts: helm-show-kill-ring disregards the selection

texts:
When I select entries (with C-<SPACE>) in helm-show-kill-ring and press either Enter or F1, it disregards the selection and yanks the entry currently under cursor. Why would this be the case and how can I cause it to yank all the selected entries?

Versions: Emacs 24.5.1, helm-20150626.731


texts: Make SLIME aware of file extensions other than ".lisp"

texts:
I'm a happy user of Emacs and SLIME.

It looks like SLIME is aware of only files with the extension ".lisp" and not others such as ".cl" or ".asd"

How can I make SLIME aware of and work with different file extensions? Thanks.


texts: Is there a way to highlight the (s) expression you are in?

texts: I currently have (paren-set-mode 'paren) in my init.el, and it does a good job of highlighting the area between parentheses. However, I was wondering if there was a way to highlight the expression I am inside of. So if I have this code (fads fasd fasdf^ asdf asfds), with the ^ representing my cursor, could I highlight the expression automatically? Is there a way to do this so that it would also do the same for the do/end blocks like in Elixir and Ruby?


texts: Org Mode use radio target for Chinese Texts

texts:
Radio targets in org-mode work by recognizing spacing between words. This makes the function redundant in when work wth Chinese and Japanese texts.

I discovered an interesting function in ol.el with a comment that says:

  Some languages, e.g., Chinese, do not use spaces to separate words.  Also allow to surround radio targets with line-breakable characters.

(defun org-update-radio-target-regexp ()
  "Find all radio targets in this file and update the regular expression.
Also refresh fontification if needed."
  (interactive)
  (let ((old-regexp org-target-link-regexp)
    ;; Some languages, e.g., Chinese, do not use spaces to
    ;; separate words.  Also allow to surround radio targets with
    ;; line-breakable characters.
    (before-re "\\(?:^\\|[^[:alnum:]]\\|\\c|\\)\\(")
    (after-re "\\)\\(?:$\\|[^[:alnum:]]\\|\\c|\\)")
    (targets
     (org-with-wide-buffer
      (goto-char (point-min))
      (let (rtn)
        (while (re-search-forward org-radio-target-regexp nil t)
          ;; Make sure point is really within the object.
          (backward-char)
          (let ((obj (org-element-context)))
        (when (eq (org-element-type obj) 'radio-target)
          (cl-pushnew (org-element-property :value obj) rtn
                  :test #'equal))))
        rtn))))
    (setq org-target-link-regexp
      (and targets
           (concat before-re
               (mapconcat
            (lambda (x)
              (replace-regexp-in-string
               " +" "\\s-+" (regexp-quote x) t t))
            targets
            "\\|")
               after-re)))
    (unless (equal old-regexp org-target-link-regexp)
      ;; Clean-up cache.
      (let ((regexp (cond ((not old-regexp) org-target-link-regexp)
              ((not org-target-link-regexp) old-regexp)
              (t
               (concat before-re
                   (mapconcat
                    (lambda (re)
                      (substring re (length before-re)
                         (- (length after-re))))
                    (list old-regexp org-target-link-regexp)
                    "\\|")
                   after-re)))))
    (when (featurep 'org-element)
      (org-with-point-at 1
        (while (re-search-forward regexp nil t)
          (org-element-cache-refresh (match-beginning 1))))))
      ;; Re fontify buffer.
      (when (memq 'radio org-highlight-links)
    (org-restart-font-lock)))))

Running the function on the sample text below shows that only 1 and 2 are linked.

 <<<劉邵>>>

1. 劉邵

2. 其邯鄲淳事在〈王粲傳〉，蘇林事在〈劉邵〉、〈高堂隆傳〉，樂詳事在〈杜畿傳〉。

3. 六月，權令將軍賀齊督糜芳、劉邵等襲蘄春，邵等生虜宗。

How do we make radio targets work without the spacing requirement?


texts: Can I focus the echo area when there’s no prompt?

texts:
Suppose I type M-! uname -a RET. A message like this is displayed in the echo area:

Linux pergamon 4.15.0-33-generic #36-Ubuntu SMP Wed Aug 15 16:00:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

I want to mark some part of this message (like 4.15.0-33-generic) and copy it to the kill ring with M-w.

(This example is for the sake of illustration. In reality I want to do this on some other messages that I get in the echo area.)

But how do I focus the echo area so I can operate on its contents?

Unlike in the “Focus echo area” question, I don’t have a prompt active, just a message.

I can type C-h e to view the *Messages* buffer in another window, but that is less convenient.


texts: How do i run zone (zone-when-idle) for all windows?

texts:
Zone Mode is awesome

But when I run it using M-x zone, or by setting zone-when-idle variable it starts animating only one(selected) window.

Is there any way to run it for all windows?


texts:
I am trying to export one repository stash to another.

In terminal I can do

git stash show -p > temp.patch

But when in magit  buffer, if I run z it is not showing any switch for -p before or after s. So, how can I export stash using  magit?


texts: Can Emacs render family emojis? (Emoji ZWJ Sequences)


texts:
I've been maintaining my resume in orgmode for some time now, with export to pdf. I just decided it would be nice to also export to html which has uncovered a problem.

I'm using headings to list my previous jobs, with a macro that puts a date range on the same line, but right aligned. The macro uses latex to do the magic, which you can see below. I've also looked at replacing the macro with a tag, but tags don't seem to allow spaces or dashes.

Wanted to see if anyone here has any smart tricks for the org file so that it will export to both pdf and html nicely.

Here's a MWE of my resume org file:

#+OPTIONS: toc:nil num:nil
#+MACRO: date \hfill\normalfont{\small $1}

* Job 1 {{{date(July 2019 -- Dec 2019)}}}
  /Description of job/

  - This is the macro solution I am currently using. It doesn't export to html very nicely...

* Job 2                                                               :Jul2019Dec2019:
  /Description of second job/

  - Here I am using a tag for the date
  - Problem is that I can't put spaces or dashes in the tag...

Here's the pdf output: https://imgur.com/9syixz3

Here's the html output: https://imgur.com/1rRgPY5


texts: Org-mode: org-export-as-html is detected as XML, not HTML

texts:
I am exporting my org-mode file via org-export-as-html, but when I check the file type via file my/file.html, it is XML. I notice the first three lines in my HTML exported file is the following:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

which is a reasonable explanation. If I manually re-order these lines to the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?xml version="1.0" encoding="iso-8859-1"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

then the file is correctly identified as HTML. How do I correct this issue in my export function? I checked the org-mode docs here but they seem out of date:

http://orgmode.org/manual/HTML-Export-commands.html#HTML-Export-commands

because I do not have their listed commands, but org-export-to-html and org-export-as-html-to-buffer.

Any suggestions would be very helpful.

BTW I am on Emacs 24.3 with Ubuntu 14.04. Here are the first few lines of my org file:

Flatsheet Project Mgmt -*- mode: org -*-
#+TODO: TODO IN-PROGRESS WAITING DONE
#+INFOJS_OPT: view:overview toc:true

* project stuff...
* more project stuff...

UPDATE

I found this link potentially helpful, but their suggestion is not working:

http://doc.norang.ca/org-mode.html

There is a section called 16.8.2 Export HTML without XML header, but their solution below does not work for me:

(setq org-html-xml-declaration (quote (("html" . "")
                                       ("was-html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
                                       ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))))


texts:
Company-mode gives me a popup with options, but once I press C-n to navigate through the options, the popup disappears (I can still cycle through the options , but they are shown inline). I want the popup to remain open until I make my selection. Is this a customizable behavior (for instance, this screencast shows a company-mode popup which remains open while he cycles through values)?

Could some other mode be interfering and closing the popup (e.g., evil-mode)? How would I go about debugging that (I'm new to emacs)? Thanks!


texts: Problem of starting a remote ipython console

texts:
I want to connect to remote ipython server, and follow the doc of the ipython, I start a ipython server in my server by

ipython3 kernel -f ~/.ipython/kernel.json --pprint

and I can start a ipython client in iTerm by

jupyter console --existing path/to/kernel.json --ssh user@192.168.1.111 -simple-prompt

However, I use the above command in emacs by run-python and got

Warning (python): Python shell prompts cannot be detected.
If your emacs session hangs when starting python shells
recover with ‘keyboard-quit’ and then try fixing the
interactive flag for your interpreter by adjusting the
‘python-shell-interpreter-interactive-arg’ or add regexps
matching shell prompts in the directory-local friendly vars:
  + ‘python-shell-prompt-regexp’
  + ‘python-shell-prompt-block-regexp’
  + ‘python-shell-prompt-output-regexp’
Or alternatively in:
  + ‘python-shell-prompt-input-regexps’
  + ‘python-shell-prompt-output-regexps’

The solution in here does not work for me and even if it does, it seems that one can not send code to this *Python* buffer.

So my question is how can I use a remote ipython console and send by codes by python-shell-send-* functions ?

Thanks in advance.


texts: Setting up private layer with local files in spacemacs

texts:
I'm trying to get the unicode-math-input package up and running in spacemacs;
the package depends on math-symbol-lists. Both packages are not featured in the official repositories.

From what I know about spacemacs I think I have to create a custom layer in
.emacs.d/private/. I called the layer math so I have the folder
.emacs.d/private/math/ with two subfolders math/local/unicode-math-input
and math/local/math-symbol-lists (in which i cloned the respective github repositories).

The .emacs.d/private/math/packages.el file looks like this:

(defconst math-packages
  '(
    (math-symbol-lists :location local)
    (unicode-math-input :location local)

    (defun math/init-math ()
        (defun math/init-math-symbol-lists ()
            (use-package math-symbol-lists))

        (defun math/init-unicode-math-input ()
            (use-package unicode-math-input))
    )
   )
)

Further I added the layer to dotspacemacs-configuration-layers:

 dotspacemacs-configuration-layers
 '(
  math
 )

Spacemacs starts without problem, however the input method unicode-math-input can't be selected with M-x set-input-method. What am I missing?
Many thanks in advance!


texts: All todos: how to set different colors for different categories?

texts:
I'm trying to customize my todos a bit. Currently, I use different categories for my todos as such:

* TODO customize colors of categories
  :CATEGORY: emacs
* TODO get groceries
  :CATEGORY: errands

Then when I view my todos via C-c a t, I get a listing of my todos. I have them sorted via category, using

;; Global agenda: sort todos by category
(setq org-agenda-sorting-strategy
      '((agenda category-up)
        (todo priority-down category-up)
        (tags priority-down category-keep)
        (search category-keep)))

Now I would like each category todo to appear in a different color. Alternatively, an easier solution for me might be to put a line break between each section of categories. I don't know how to do either these.

While I'm at it, is there a better way to organize my todos, or is :CATEGORY: the way to go?


texts: How to write an e-lisp function to extract a sub-string between two given characters (not their positions) in a given string?

texts:
I am writing an e-lisp function in my .emacs file to help process Bibtex entries I copy from Google-Scholar. Let's consider this example:

@article{jacobsen2011full,
  title={A full hydro-and morphodynamic description of breaker bar development},
  author={Jacobsen, Niels Gj{\o}l},
  year={2011},
  publisher={DTU Mechanical Engineering}
}

I would like to extract the entry name "jacobsen2011full" that will always be between "{" and "," but the position from the start is not always constant.

So how to go on about that???

I do not process the text inside a buffer. As mentioned I want to write an e-lisp function.


texts: How to stop (aquamacs) emacs opening all new buffers in new (gui) window/emacs frame?

texts:
I've just upgraded my aquamacs installation and a bunch of packages, and now emacs is opening every new buffer in a new (gui) window (aka emacs frame). I don't like this. I want to have every buffer open in a new tab within the same frame.

I already have this tabbar and window config, but it's not doing the trick:

(custom-set-variables
 '(pop-up-frames nil)
 '(pop-up-windows nil))

(use-package tabbar
  :ensure t
  :config
  (tabbar-mode 't))

How do I keep my buffers all in one frame?

I'm using version: Aquamacs 3.5  GNU Emacs 25.3.50.1 (x86_64-apple-darwin16.7.0, NS appkit-1504.83 Version 10.12.6)


texts: show-paren-mode or similar to highlight multi-character parentheses

texts:
In latex, "parentheses" such as \(\), $$ and \[\] are constantly used. Is there a way to customize show-paren-mode or is there some other mode to highlight these multi-character parentheses in latex-mode as well as the traditional ones, ()[]{}?

Taking this to the next level, is there a way to highlight beginning and end of latex environments? As in the example below (item is just an example)

\begin{item}  % <- should be hightlighted together when point is inside
OTHER TEXT
\end{item}    % <- should be hightlighted together


texts: Automatically replace "$" by "\(" in latex-mode

texts:
In latex mode, using \( ... \) is preferred over $ ... $, so in my configuration I have the following

(sp-local-pair modes "$" nil :actions :rem)
(sp-local-pair modes "\\(" "\\)" :trigger "$")

This way, when I try to insert $ the pair \( \) are inserted instead. This works well, however, for some reason if I select some text and press $ the pair \( \) are inserted after the text instead of wrapping the text with them.

If I press \( instead the selected text is wrapped correctly.

Is there a way to fix this so that if I press $ with a selected text, the text is wrapped with \( ... \)?


texts: Boldface and Italics not showing in self-defined font

texts:
I have the following setting in my init.el so that tables with Chinese characters can be displayed properly.

(set-face-attribute
 'default nil
 :font (font-spec :name "-*-Menlo-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1"
                  :weight 'normal
                  :slant 'normal
                  :size 24))
(if (display-graphic-p)
    (dolist (charset '(kana han symbol cjk-misc bopomofo))
      (set-fontset-font
       (frame-parameter nil 'font)
       charset
       (font-spec :name "-*-STFangsong-normal-normal-normal-*-*-*-*-*-p-0-iso10646-1"
          :weight 'normal
          :slant 'normal
          :size 28))))

The table display works perfectly, but I am not able to use emphases with the new font.

I know the STFangsong font supports bold and italic because they display properly in LibreWriter.

Does this have something to do with my settings?

Running this code, however, fixes the Chinese font italics issue but breaks the English font bold.

(defvar emacs-english-font "Monaco"
  "The font name of English.")

(defvar emacs-cjk-font "STFangsong"
  "The font name for CJK.")

(setq emacs-cjk-font "STFangsong")

(defvar emacs-font-size-pair '(26 . 32)
  "Default font size pair for (english . chinese)")

(setq emacs-font-size-pair '(26 . 32))

(defvar emacs-font-size-pair-list
  '(( 5 .  6) (10 . 12)
    (13 . 16) (15 . 18) (17 . 20)
    (19 . 22) (20 . 24) (21 . 26)
    (24 . 28) (26 . 32) (28 . 34)
    (30 . 36) (34 . 40) (36 . 44))
  "This list is used to store matching (englis . chinese) font-size.")

(defun font-exist-p (fontname)
  "Test if this font is exist or not."
  (if (or (not fontname) (string= fontname ""))
      nil
    (if (not (x-list-fonts fontname)) nil t)))

(defun set-font (english chinese size-pair)
  "Setup emacs English and Chinese font on x window-system."

  (if (font-exist-p english)
      (set-frame-font (format "%s:pixelsize=%d" english (car size-pair)) t))

  (if (font-exist-p chinese)
      (dolist (charset '(kana han symbol cjk-misc bopomofo))
        (set-fontset-font (frame-parameter nil 'font) charset
                          (font-spec :family chinese :size (cdr size-pair))))))

;; Setup font size based on emacs-font-size-pair
(set-font emacs-english-font emacs-cjk-font emacs-font-size-pair)

Test data:

Test data. 測試文字
*This is in bold 這是粗體*
/This is in italics 這是斜體/


texts: Marking a TODO item DONE does not create a CLOSING timestamp in org-mode

texts:
I'm following this tutorial:

https://orgmode.org/worg/org-tutorials/orgtutorial_dto.html

* Tasks
** DONE start a new org file for tutorial
C-c C-t

modifies the second to line

** DONE start a new org file for tutorial

but is not followed by the expected

CLOSED <timestamp>

What to do?

UPDATE #1:

here's how .emacs.d/init.el is setup:

(require 'package)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)


texts: Why isn't my codeblock executing and displaying the output?

texts:
I have an org-mode file, with org-mode version 9+ (so my understanding is that Babel should be integrated). Then I have the following in the file

#+BEGIN_SRC python :exports both :results output
return 7 + 7
#+END_SRC

#+RESULTS:

I then compile to a PDF file. My understanding is that this should display both the codeblock and the evaluation of the codeblock. However the PDF just displays:

return 7 + 7

I have tried using print instead of return, but same outcome. What am I misunderstanding here?


texts: Can frames be blacklisted so they are skipped by other-frame

texts: Is there a way to blacklist a set of frames so that other-frame ignores / skips them?


texts: How interpret the Lisp way to include arguments in functions?

texts:
I have some difficulties to understand how Lisp wanted to receive the arguments. When I look into the documentation about arguments in functions, I need to name the arguments exactly as in the source code, when calling the same function.

When I look into the documentation of Emacs function indent-region, I get the following:

= runs the command indent-region, which is an interactive compiled
Lisp function in `indent.el'.

It is bound to =, <menu-bar> <emacs-lisp> <indent-region>, C-M-\.

(indent-region START END &optional COLUMN)

Indent each nonblank line in the region.
A numeric prefix argument specifies a column: indent each line to that column.

Then I create a function, that pass the arguments to the function itself, as described in the documentation:

(defun foo (start end)
  (interactive)
  (indent-region start end)
  )

I see no difference when comparing with how another custom functions handles the functionality. When I visually selected a region, and call the function, I got the error that the arguments are of the wrong type.

So this led me to wonder why the start and end arguments are not accepted in this case?


texts: Adding tilde to electric pairs in org mode

texts:
I am trying to add the verbatim character ~ (tilde) as an electric-pair character in org-mode. Here is my attempt:

(with-eval-after-load 'org
 (modify-syntax-entry ?/ "(/" org-mode-syntax-table)
 (modify-syntax-entry ?= "(=" org-mode-syntax-table)
 (modify-syntax-entry ?~ "(~" org-mode-syntax-table))

This works for the / and = characters, but not for ~. What do I need to do to add ~?


texts: Can't define a glyph as a word constituent

texts:
I'd like Emacs to treat this

dollar$sign

as one word. So I evaluated this line

(modify-syntax-entry ?$ "w")

to have Emacs treat dollar sign as a word constituent rather than a symbol. However, when I run forward-word from the beginning of the line below, it stops at the dollar sign when I'd like it to stop at the "n" instead.

dollar$sign

How can I define dollar sign as a word constituent and have forward-word ignore it just like when it sees alphabet?


texts:
I want to export an org file containing a tikz diagram to pdf.
I've read the manual.
This is the most minimal example I could come up with:

#+LATEX_HEADER: \usepackage{tikz}

#+begin_src emacs-lisp :results silent
(org-babel-do-load-languages
 'org-babel-load-languages '((latex . t)))
  (setq org-babel-latex-htlatex "htlatex")
  (defmacro by-backend (&rest body)
    `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
#+end_src

#+header: :file (by-backend (html "tree.svg") (t 'nil))
#+header: :imagemagick
#+header: :results (by-backend (pdf "latex") (t "raw"))
#+begin_src latex
  \begin{tikzpicture} %foo
    \draw[thin] (0,0) circle (1);
    %\draw (ba) circle (1);
  \end{tikzpicture}
#+end_src

To execute I put the cursor in the elisp block and do C-c C-c, then M-x org-latex-export-to-pdf

This yields:

  Process completed with errors: [package error]

Interestingly it works when I remove just one of the 2 comments (or replace ba by 0,0)

Upon doing M-x org-latex-export-to-latex I can see that the code block evaluates to

\begin{tikzpicture} \%foo
  \draw[thin] (0,0) circle (1);
  \%\draw (ba) circle (1);
\end{tikzpicture}

The comments aren't ignored but the % are escaped!  (And the package error is probably how latex deals with unknown tokens foo and ba)

How can I keep the comments in my code and still compile?

Org-mode version 8.2.10
GNU Emacs 25.2.2

Progress:
jagrg is correct I don't get the error with emacs -Q.
I have now 2 types of errors:

emacs -Q --load debug_init

1) With debug_init being either of the following files:

(require 'package)
(add-to-list 'load-path "/usr/share/emacs25/site-lisp/mu4e")
(require 'mu4e)
--- or ---
;;(require 'package)
(add-to-list 'load-path "/usr/share/emacs25/site-lisp/mu4e")
(require 'mu4e)

results in Process completed with errors: [package error]
and If I remove %foo it compiles.
(I can also just fix up the generated .tex file)

2) with emacs -Q or either of the following init files:

(require 'package)
;;(add-to-list 'load-path "/usr/share/emacs25/site-lisp/mu4e")
;;(require 'mu4e)
--- or ---
(require 'package)
(add-to-list 'load-path "/usr/share/emacs25/site-lisp/mu4e")
;;(require 'mu4e)

I get by-backend: Symbol’s function definition is void: case

Update 2
Symbol’s function definition is void is solved, thanks jagrg!

current setup:

myinit:

(require 'cl-lib)
(org-babel-do-load-languages
 'org-babel-load-languages '((latex . t)))
(setq org-babel-latex-htlatex "htlatex")
(defmacro by-backend (&rest body)
 `(cl-case (if (boundp 'backend)
               (org-export-backend-name backend) nil) ,@body))

main.org:

#+LATEX_HEADER: \usepackage{tikz}
#+header: :file (by-backend (html "tree.svg") (t 'nil))
#+header: :imagemagick
#+header: :results (by-backend (pdf "latex") (t "raw"))
#+begin_src latex
  \begin{tikzpicture} %foo
    \draw[thin] (0,0) circle (1);
    %\draw (ba) circle (1);
  \end{tikzpicture}
#+end_src

open with emacs -Q --load myinit main.org then type M-x -l-pd
resulting in Process completed with errors: [package error]

Update 3
changing "raw" to "results" does the trick.


texts: Why text yanked into the Isearch search string is always in lower case?

texts:
Emacs 26.1

I select the next text:

NO_PERMISSION_GRANTED_ACCESS_FINE_LOCATION_and_ACCESS_COARSE_LOCATION

C-s , then paste text onto the search string.

Here result:

Why text is not in UPPER CASE? It's always in lower case?


texts: How to perform lookups using lsp-mode on code inside comments?

texts:
I would like to be able to perform lsp-mode operations on code comments, for example I would like to be able to run lsp-find-definition on this.

void my_fn(struct Foo bar)
{
   /** This is a doxygen comment, this is some code: `bar.member` */
   //                                                     ^ my cursor is here!
}

Is there a way to place my cursor over the code in the comment and perform a lookup on bar.member just as it would if it was not in a comment?


texts: Can't assign to hline relative reference

texts:
I have the following org-mode table:

#+BEGIN: columnview :hlines 1 :id global
| /Project/      | Mon | Tue | Wed |  Thu | Fri |  Sat | Sun | /Total/ |
|----------------+-----+-----+-----+------+-----+------+-----+---------|
| AnotherProduct |     |     |     |      |     | 2.50 |     |         |
| Prototype      |     |     |     | 3.50 |     |      |     |         |
|----------------+-----+-----+-----+------+-----+------+-----+---------|
| /Daily/        |     |     |     |      |     |      |     |         |
#+TBLFM: @I$9..@II$9=vsum($2..$8);%.2f;::@II$2..@III$9='(format "%3.2f" (apply '+ '(@I..@II)));N;

and I get the error can't assign to hline relative reference when I run M-x org-table-recalculate. I looked over the org-mode references documentation and the gmane.org forums, but I did not find any reasons as to why the hline relative references could not be assigned.

This issue is related to the timesheet package on MELPA. I have filed an issue here: https://github.com/tmarble/timesheet.el/issues/3 but hopefully I have found the underlying problem, and hopefully it is reasonably fixable.

Here is some relevant info:

Org-mode version 8.3.1 (8.3.1-87-g4ef2c0-elpa @ /home/luke/.emacs.d/elpa/org-20150824/)
emacs-version: 24.5.1
ArchLinux OS: Linux 4.1.6-1-ARCH #1 SMP PREEMPT Mon Aug 17 08:52:28 CEST 2015 x86_64 GNU/Linux


texts:
On this video stream, the window on right displays the keybindings typed with its corresponding command bound.
Is there any package that does that, or a way to achieve it?


texts: How to display a babel tangled source code block in org-mode?

texts:
I have simple code blocks that I would like to show the noweb generated source for inside the same org-mode file.  eg:

#+NAME: example
#+BEGIN_SRC java :classname Test :results code  :exports both :tangle yes :noweb yes

<<preface>>
String result = "hello world";
<<end>>

#+END_SRC

where preface and end are something like this:

#+NAME: teststart
#+BEGIN_SRC java  +n :results none :exports code :tangle yes :noweb yes
public class Test {
  public static void main(String[] args)
  {
#+END_SRC

#+NAME: testend
#+BEGIN_SRC java +n :classname Test :results none :exports code :tangle yes :noweb yes
      System.out.print(result);
    }
  }
#+END_SRC

I can do a file include, eg:

#+INCLUDE: "./Test.java" src java

and see it in exports, but not the org-mode file itself.


texts:
Linux Mint ,
Emacs 27.2
Dired, Dired+, Dired-k
As a result here is the dired mode view

As you can see, the names of files:

to.do.org
to.do.org_archive_2017
to.do.org_archive_2019

are gray. Can I remove this gray color?


texts: How to export LaTeX snippets to HTML via SVG rather than PNG?

texts:
The org-mode source

#+OPTIONS: toc:nil creator:nil author:nil timestamp:nil num:t validate:nil
#+OPTIONS: tex:imagemagick
#+LaTeX_HEADER: \usepackage{tikz}

\begin{tikzpicture}
   \draw (0,0) circle (3cm);
\end{tikzpicture}

exports to HTML like a charm. However, the LaTeX snippet is converted to PNG format. Is there a simple way to persuade the system to use SVG rather than PNG?


texts: When setting item to DONE, how do I automatically change following item to NEXTACTION?

texts:
So I, like many others, use org-mode to implement GTD to manage my life. One thing that happens since I'm in school is long-term projects, which have milestones. In and of themselves these milestones are strictly sequential events, and within these milestones even usually there are strictly sequential events.

As it stands now, I mark all the items that are blocked because of the current NEXTACTION as TODO. Whenever I finish a task and mark it DONE, I have the mental burden of then reviewing my project support materials to determine what becomes the new NEXTACTION. This is fine, but inefficient if I already know the order of events. Is there a way to automatically change the next item down (in a list, actual next line, any way) to NEXTACTION when I mark an item DONE?


texts:
This is rather strange though it seems merely an aesthetic issue.

I use something like

(setq org-ellipsis "  ")

to customize the ellipsis. However, whatever characters I choose, there is always a line under the new "ellipsis". For the above setting, it simply shows like this

* a Title___

I have tried to start emacs at the terminal with -q option, but the problem always exists. Notice that the underline does not appear if I just use the default .... I actually had this problem for some time now, and once in a while, a new update in org can eliminate the annoying underline, but then again it appears in the next update. My org is up to date as of today (8/23/2018). I'm using macOS high Sierra.

Can someone give me advice on how to remove the underline?

Thanks in advance!


texts: Emacs in OSX Terminal.app not filling entire window

texts:
I recently (finally) figured out how to get a monokai theme onto my emacs in the default Terminal app, but emacs still isn't filling up the entire window.

There's a small, but noticeable color discrepancy on the corners.

How do I make Emacs fill up the whole Terminal screen?

Note: This occurs in both windowed and "fullscreen" mode. My resolution is 1440 x 900 (Macbook Air 2015 resolution). However, I do use multiple monitors frequently, so a general solution would be very much preferred. Thank you!


texts:
I am using Ibuffer for better buffer management and the display format is set to elide long buffer names. This is good but sometimes I would also like to see the full name (like when positioning the point over the buffer entry). Is there a way to ask IBuffer to display the full name (non elided), lets say, in the minibuffer when the point is over a buffer line?

There are lots of posts around on how to change the ibuffer format string to accommodate longer buffer names but this is not exactly the same thing: sometimes the buffer names (or the paths for example) are so long that they cannot reasonably fit the screen so leaving lots of space for them in the format string would be counter productive. However having a way to quickly see the full name would be great!

EDIT: After some searching around: when the line below (where the minibuffer appears) is used to display a message then it is called echo area.

There is a special text property that is called help-echo that is made especially for tool-tip style applications as described in the Emacs manual. The hint assigned by ibuffer to these entries is the tool-tip that gets displayed on mouse hover:

mouse-1: mark this buffer
mouse-2: select this buffer
mouse-3: operate on this buffer.

As described once again by the Emacs Manual this can be automatically displayed in the echo area by setting help-at-pt-display-when-idle to t.

However this would ruin mouse tool-tips; maybe one could/should implement this as a configurable option. Another option would be the point-entered text property.

I have only a very approximate idea of how to actually implement this change. Any suggestions are welcome.


texts: Should I be worried about the inability to undo a Custom Theme?

texts:
I am relatively new to emacs and am liking it... so much so that I'd like to customize the look and feel.

I'm aware the Custom Theme is the new way and is different from Color Theme.

The one thing that gives me pause is that Custom Theme cannot be undone. That freaks me out.

As I understand it, this means that if/when I uninstall Custom Theme 1 and install a new Custom Theme 2, the first one might leave remnants behind that still linger when I use Theme 2. Some of those remnants could conflict and give strange appearances (strange meaning different what Theme 2 intended).

How pervasive is this problem of Custom Themes leaving remnants behind? In practice, are there "good-behaving" Custom Themes that clean up after themselves when uninstalled? If things go bad, is the only option to go nuclear (i.e., re-install emacs, saving my init file)?


texts: unexpected long indent after colon in web-mode

texts:
I have some trouble locating the source of 8 tabs and 3 spaces more than the previous indentation when I'm inside js inside web-mode. These appear after a line that ends with a colon. Example (note that in emacs these are tabs of width 4, except the last 3 spaces which are actually spaces):

        // bind event to schedule visibility toggle:
                                           $('input#scheduleswitch').parent().change(function() {

Anyone a suggestion what might be causing this long indent?
Could it be a case-statement related indentation?


texts: How to use italic in quoted text in org-mode

texts:
Let us say I have the following code in an org file that I want to export to LaTeX and pdf.

#+BEGIN_QUOTE
  These kinds of models show that coalition building might be important.\\
  [[citep:Pamp2015][Page 15]]
#+END_QUOTE

How can I put every text quote in italics?


texts:
I'm using multiple-cursors, setting it up with use-package. By default, when multiple-cursors mode is enabled, <return> is bound to multiple-cursors-mode. I'm trying to override that adding this after :config in the use-package declaration:

(define-key mc/keymap (kbd "<return>") nil)

So, this is part of my init.el:

(use-package multiple-cursors
  :ensure t
  :bind (("s-d" . mc/mark-next-like-this)
         ("s-D" . mc/mark-all-dwim)
         ("s-L" . mc/edit-beginnings-of-lines)
         ("s-<mouse-1>" . mc/add-cursor-on-click))
  :config
  (define-key mc/keymap (kbd "<return>") nil)
    )

Unfortunately, when multiple-cursors mode is enabled, C-h k tells me

<return> runs the command multiple-cursors-mode (found in mc/keymap)

I tried putting the :config bit before :bind just in the off chance it had something to do with the way :bind works, but that didn't make a difference.


texts: Include lines in tangled source code but not in executed code block

texts:
The title might be slightly confusing. What I mean is this. Let's say I have a code block which has some error checking code. If there is an error, the (tangled) program should not continue past that point. Let's say I work with python. If I have a source code like this
if len(dummy_list) == 0:
  print("Error!!!")
  sys.exit(0)

Executing this in a code block makes EMACS hang. So I don't want this line to be executed in my source block. But I want this line to be present in the tangled source code. Moreover, it would be great if there was a way to destroy the current running session when I counter an error. Is there a way to achieve this?


texts: Newbie trying to understand emacs filing system

texts:
This is my first time here. I asked my question over at /r/emacs on reddit, however so far I am left with some unanswered questions. I'll copy paste my question along with the link to my post which has more information.

Original Post

Hi,

Before emacs I thought I knew my computer, now after learning, or trying to learn emacs I am not so sure and feel like an 80 year old with dementia. Anyways, I am not sure if this happens to everyone or I am just not doing it right.

Back to my question. I am learning emacs to write screenplays and notes and also use it as a planner/organizer/manager. I plan to make it my one stop from writing to having my film list to small notes and books and what have you. I am mighty impressed with all the packages available which will make writing much fun.

While previously I worked with Files and Folders and it got a bit too messy. I understand there is an extension called helm which makes file management a breeze. I've been playing with packages and Dired. I understand how emacs works and how it goes about doing its business. I think about files and folders and emacs talks about directory and sub-directory (sub-folders).

Let me run you through what I did and how I messed up or I think I messed up, again :

I unzipped emacs to > C:\Users\MyName\OneDrive\emacs

My .emacs folder lands up in C:\Users\MyName\AppData\Roaming.emacs.d

Along with 3 emacs files / #.emacs# / .emacs and .emacs~ in
C:\Users\MyName\AppData\Roaming

When I type C-x C-f it takes me to C:\Users\MyName\OneDrive\emacs\bin/

When I look up other tutorials I notice that their emacs files are in their home directory and not else where. Also when I customize it does make changes to one of the files in C:\Users\My\AppData\Roaming however the package gets installed in C:\Users\MyName\AppData\Roaming.emacs.d\elpa

and then the customization never shows up even after package-initialize and package-require. So I am guessing my Emacs isn't picking up on the right file or I messed up.
Can I not have .emacs.d and those 3 files in my home directory
C:\Users\MyName\OneDrive\emacs\bin/

How have you set up your emacs?

What is the best way to go about file management and not have things cluttered and mixed up.

Is there some sort of an optimal setup?

Thanks for your help.

This thread is the solution I am trying to implement.


texts: How can I toggle displaying images in eww without a page refresh?

texts:
I use eww to browse the internet and more often than not I do not want images to load, there doesn't seem to be much in terms of customizations built in for eww and none dealing with images.

Currently I have a system setup that allows me to start and stop showing images in eww but only after a page refresh, what I want is a way to toggle images on and off without refreshing the page.

Here is my current method which takes advantage of the internals of shr-put-image which eww uses.

(defvar display-graphic-override nil
  "Used to override `display-graphic-p' behavior.
Should either be nil, or a list where the car is the override.")

(defadvice display-graphic-p (around sometimes-lie activate)
  "Use the override if it is non nil."
  (if display-graphic-override
      (car display-graphic-override)
    ad-do-it))

(defadvice eww-render (around no-images activate)
  "Temporarily lie about supporting graphics"
  (let ((display-graphic-override '(nil)))
    ad-do-it))

I have also tried toggling the 'invisible text property where images are but that doesn't seem to work.


texts: mu4e or mu cannot find a search term with a period

texts:
I use mu4e and sometimes I cannot find a message with a search term including a period. For example, if I search for Google.org, I see:

No matching messages found

but if I search for "impact challenge", I see a message with Google.org in the subject line:

8660  28/06/2019 PS   noreply@withgoo... Google.org Impact Challenge on Safety: Submission Received

I am able to find messages when the period is in the email address, e.g. the above message when I search for withgoogle.com.

The documentation on searching does not mention a special role for periods.

Am I missing something or is this a bug?

Update: here is the raw message with headers up to the body, replacing emails, IP addresses, signatures, and the like with <>. The period is in the From header.

Return-Path: <>
Delivered-To: unknown
Received: from <> (<>) by <> with
  POP3-SSL; 17 Jun 2019 15:41:16 -0000
Delivered-To: <>
Received: from <> ([10.2.0.17])
    by <> (Dovecot) with LMTP id O82AO0mkB10uMQAAZlJlVA
    for <>; Mon, 17 Jun 2019 15:37:08 +0100
Received: from <> ([127.0.0.1])
    by <> (Dovecot) with LMTP id RUIOEYJjB13EOAAAqE/zKQ
    ; Mon, 17 Jun 2019 15:37:08 +0100
Received: from localhost (localhost [127.0.0.1])
    by <> (Postfix) with ESMTP id 5284020143
    for <>; Mon, 17 Jun 2019 15:37:08 +0100 (BST)
X-Quarantine-ID: <XZvr36t3mmiF>
X-Virus-Scanned: Debian amavisd-new at <>
Authentication-Results: <> (amavisd-new);
    dkim=pass (2048-bit key) header.d=google.com
Received: from <> ([127.0.0.1])
    by localhost (<> [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id XZvr36t3mmiF for <>;
    Mon, 17 Jun 2019 15:37:07 +0100 (BST)
Received: from <> (<> [209.85.222.173])
    by <> (Postfix) with ESMTPS id BD3D75F99A
    for <>; Mon, 17 Jun 2019 15:37:05 +0100 (BST)
Received: by <> with SMTP id r6so6322105qkc.0
        for <>; Mon, 17 Jun 2019 07:37:05 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20161025;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
        bh=<>;
        b=<>
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to;
        bh=<>
        b=<>
X-Gm-Message-State: <>
X-Google-Smtp-Source: <>
X-Received: by 2002:a37:696:: with SMTP id <>;
 Mon, 17 Jun 2019 07:37:04 -0700 (PDT)
MIME-Version: 1.0
References: <>
In-Reply-To: <>
From: "Google.org Impact Challenge on Safety" <safety-challenge@google.com>
Date: Mon, 17 Jun 2019 15:36:27 +0100
Message-ID: <>
Subject: Re: Scope of the safety challenge
To: Miguel Morin <>, safety-challenge@google.com
Content-Type: multipart/alternative; boundary="0000000000000bc240058b85ee74"

--0000000000000bc240058b85ee74
Content-Type: text/plain; charset="UTF-8"


texts: How do I change key bindings for org-mode agenda view?

texts:
org-mode agenda view has a bunch of commands accessible with a single key press.

E.g. typing b moves backward in time to display earlier dates, and typing t brings up a dialog to change the TODO state of the item.

I would like to redefine t to toggle between TODO and DONE without any dialog, and also redefine b to reschedule a task at focus to the next week.

How can those built-in commands be redefined?


texts: Color words based on gramatical categories?

texts:
Does there exist any package to color words based on grammatical class? (Noun, verb, adjective... etc).
Something like rainbow-mode for grammar instead of colors.


texts: org-babel results with accented characters

texts:
I have a problem with the output of org-babel code blocks when this output contains accented characters. For example, if I execute this code block:

#+name: test_accented
#+begin_src python :results output
print("éèà")
#+end_src

the result is:

#+RESULTS: test_accented
: Ã©Ã¨Ã

My config relating to encoding is:

;; utf-8 ;;
(setq locale-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)

I use emacs 25.2.2, org-mode 9.2.3 and python 3.6.7. I also tried with another language (ruby) and the result is the same.


texts: Is there an easy way to detect how many `C-u`s a command was given?

texts:
I have made the following function to count how many C-u prefixes a command was given (assuming it is called interactively), but I feel this is a common-enough problem that there should be a built-in function (or a package that solves this problem more robustly).  Is there a better way to do this?

(defun tmp:how-many (arg)
  ;; Return zero if `arg' is 1 or nil
  (if (or (null arg) (equal arg 1)) 0
    ;; If `arg' is a list (as it is when called interactively), extract
    ;; the number.
    (when (listp arg)
      (setq arg (car arg)))
    ;; Recurse
    (if arg
        (1+ (tmp:how-many (/ arg 4)))
      0)))

(defun tmp:test (arg)
  (interactive "P")
  (message "%S" (tmp:how-many arg)))


texts: Programmatically find-and-replace custom sequence

texts:
I need to write a command which will apply to my buffer custom, predefined copy-and-replace sequence.

What I have is:

(defun custom-processor ()
  "Formats logs to human-readable format"
  ((replace-in-the-buffer "\n" "\n\n\n")
   (replace-in-the-buffer "\t" "\n")))

(defun replace-in-the-buffer (from to)
  "Replaces in the current buffer all occurences of from to to (not interactively)"
  (while (re-search-forward from nil t)
    (replace-match to nil nil)))

It is basically working for simple characters like letters or numbers, but the case is I need to use it with new lines (\n) and tabs (\t) - the error I get is:

Debugger entered--Lisp error: (invalid-function (replace-in-the-buffer "\n" "\n\n\n"))
  ((replace-in-the-buffer "\n" "\n\n\n") (replace-in-the-buffer "\011" "\n"))
  custom-processor()
  eval((custom-processor) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

I use EMACS for 10y+ but now just starting to leverage it with Lisp programming. Please help.


texts: How to get cross referencing in a Python project?

texts:
I'd really like full support for cross referencing in Python, in particular in Django. I'm a bit of a n00b when it comes to emacs, but I love it dearly. I've used and been very impressed with the ada-mode in emacs and its cross referencing but that requires compilation artifacts. Is there a way to get emacs to do it with Python?

By "Cross Referencing" I mean that I can jump to the file containing a method definition from any reference in the project.


texts: Error: Wrong type argument: symbolp, (t)

texts:
I'm new to emacs and try to learn elisp. I've read some tutorials and try to build now my own customized emacs. Looking at this blog I want to write a similar script for automatically installing required packages.

In the blog the author defines a variable required-package which binds to a list of required packages. Then he writes (I quote):

; my-packages.el
(require 'cl)

; method to check if all packages are installed
(defun packages-installed-p ()
  (loop for p in required-packages
        when (not (package-installed-p p)) do (return nil)
        finally (return t)))

My goal is to write a similar function which does not depend on the common lisp package (since I would like to learn elisp :)). So I tried:

(defun check-required-packages (list-check)
  "The function check if the packages in LIST-CHECK are installed"
  (let ((return '(t))) ; return list
    (dolist (p list-check return) ; for each p in package execute the body and finally return RERTURN.
      (when (not (package-installed-p p))
    (add-to-list return nil)))
    return))

Having also a variable required-packages binding to such a list leads to the error:

(check-required-packages required-packages)
Wrong type argument: symbolp, (t)

I dont understand this. Since I can define

(setq a '(t))

without a problem.


texts:
I want to use https://github.com/kinjo/org-impress-js.el with emacs-25.1 and the last org-mode.

Here my configuration:

 (eval-after-load "org"
    '(progn
       (add-to-list 'load-path "~/.emacs.d/org-impress-js.el")
       (require 'ox-impress-js)))

When I want to export (C-c C-e j j) I got the message:

  org-impress-js-section: Symbol’s function definition is void:
  org-export-get-headline-id


texts: How to go to the beginning of a word/sexp?

texts:
When the point is not at the beginning of a word/sexp, backward-word / backward-sexp places the cursor at the beginning of that word/sexp. If the point is already at the beginning of a word/sexp, this is of course not the case.

How to go to the beginning of the current word/sexp regardless of the point position?

Edit 1: By current sexp, I mean the smallest sexp containing the point, for example if the cursor is at o in the expression (end-of-line), the current sexp would be end-of-line. If the cursor is at (, the current sexp would be the whole (end-of-line).

Edit 2:
 Another reformulation of this question: how to detect if the point is at the beginning of the current word/sexp?


texts: Disable hl-line-mode only for eshell and ansi-term

texts:
I have global-hl-line-mode setup in my init file:

(use-package hl-line
  :init (global-hl-line-mode 1))

Is it possible to disable it when I am in eshell and ansi-term?
I tried adding a hook like this:

(add-hook 'eshell-mode-hook (hl-line-mode -1))

But it didn't work.


texts: How can I disable line numbers on empty lines?

texts:
I find it easier to visualize double line breaks if there's actually blank space between paragraphs. I never need to see the line number of a blank line, but I do really like seeing a line number when there is text there.
How can I do this easily? (I'm using more or less the default Doom Emacs configuration as of August 2020).


texts: In Gnus, in summary buffer, how would one delete multiple emails (not retire, but actually delete). Deleting singe email (article) is BDEL (or similar), but this doesn't seem to work on any kind of marking I was able to come up with.


texts: How to insert special characters not on a US/UK keyboard?

texts:
At work I use a MacMini connected to an italian layout keyboard (please, look at the image)

I've discovered that Emacs doesn't insert the characters @ and # when I use AltGr+ò and AltGr+à, respectively.

Any clue?


texts: Integrate cua-mode with evil-insert-state

texts: I'm starting to think that using the regular C-x C-c C-v keys for kill-ring operations make sense, as they're used that way in every other program I use regularly. (And I'm starting to develop conflicting muscle memories.) However, I use evil-mode. Is there a way to integrate cua-mode (with keys) and evil-insert-state?


texts:
I was trying to fix the annoying red output in slime. It's OK on light backgrounds but on the dark backgrounds it gets on my nerves.

Some themes fix it. Quick experiment with aurora-theme reveals that slime-repl-inputed-output-face is responsible for the colour.

To fix it I wrote a little function

(defun repl-theme-fix ()
  "Fix REPL theme issues concerning the red annoying text."
  (interactive)
  (print "going to change repl buffer")
  (print (current-buffer))
  (load-theme-buffer-local 'hamburg (current-buffer)))

The problem is I have to run M-x repl-theme-fix each time I start the REPL.

I've tired to experiment with

(add-hook 'lisp-interaction-mode-hook (lambda () (some code here)))

But couldn't make it work not knowing the current-buffer argument needed by the theme.

Another option would be fixing the theme instead of replacing it with hamburg-theme.

What is the best way to fix a theme in emacs startup file?

Searching

In slime repl, when I move cursor on colourized output and press
    C-u C-x =
I get more detailed information, which contains hyperlink to a file where the font for slime-repl-inputed-output-face is defined.

~/quicklisp/dists/quicklisp/software/slime-2.14/contrib/slime-presentations.el

In that file I have found the right code fragment and replaced foreground color with Yellow.

(defface slime-repl-inputed-output-face
  '((((class color) (background light)) (:foreground "Red"))
    (((class color) (background dark)) (:foreground "Yellow"))
    (t (:slant italic)))
  "Face for the result of an evaluation in the SLIME REPL."
  :group 'slime-repl)

It does what I want to do. When theme does not change the colour I still get nice default for dark backgrounds.

But still do not know how to do it in the init file. What is the best way of fixing it?


texts: eww/w3m search based on underlying page source

texts:
Is there a robust/general way in eww browser (or alternatively w3m in emacs) by which I can get the character position in a rendered page from a known character position in the page source?

I'd like to use this to automatically jump to "important" parts of webpages I visit often.

On stackexchange.com I need to scroll down a whole page to see the relevant part (the question section). I would like to setup emacs to jump automatically to the section.

As an example, stackoverflow.com has a question header:

     Stack overflow question title

If I can find this location by html tags in the source, is there a way to then jump to get the corresponding position in the rendered page view.


texts: How to paste a multiline regex from re-builder into `replace-regexp`

texts:
I built with M-x re-builder a regex to match empty quoted lines in emails. In read syntax it is:

"^>\\s-*\n>"

How can I copy this regex in re-builder, so that I can paste it in the first prompt of M-x replace-regexp?

I tried the following:

After writing the regex in re-builder's read mode I switched with Ctrl-C TAB to string syntax and copied the regex via Ctrl-C Ctrl-w. Then I issued M-x replace-regexp and pasted the regex but found "0 occurrences". Additionally I deleted the " quotes characters from the pasted text and try again, but still got no matches. I guess, something goes wrong with the newline character...


texts: auto-complete-c-headers just works with C. No result with C++

texts:
I installed the auto-complete-c-headers package and added the following in my Emacs configuration file
; start auto-complete with emacs
(require 'auto-complete)
; do default config for auto-complete
(require 'auto-complete-config)
(ac-config-default)
; let's define a function which initializes auto-complete-c-headers and gets called for c/c++ hooks
(defun my:ac-c-header-init ()
(require 'auto-complete-c-headers)
  (add-to-list 'ac-sources 'ac-source-c-headers)
  (add-to-list 'achead:include-directories '"/usr/include/c++/4.8
 /usr/include/x86_64-linux-gnu/c++/4.8
 /usr/include/c++/4.8/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
"))
; now let's call this funcion from c/c++ hooks
(add-hook 'c++-mode-hook 'my:ac-c-header-init)
(add-hook 'c-mode-hook 'my:ac-c-header-init)

I included the directories listed by the command gcc -xc++ -E -v -.
The autocomplete works fine with C header files, but does nothing with the C++ ones.


texts: How to change the background/foreground color of some characters/words?

texts:
I know by M-x set-background-color or M-x set-foreground-color one can change the background/foreground of the the entire buffer. Of course this color change only persists in the current session.

In the same way how can one change the background/foreground color of some characters/words?

For example if in a buffer I have something like below

I would like to change the background/foreground color of some characters like below:

And I would like that this color change to be persistent in the current session unless I delete these colorful character.


texts: How to change Emacs windows from vertical split to horizontal split?

texts:
Window A
++++++++
Window B

Is there a way to switch to

Window A : Window B

Is there a way to switch view without closing windows?


texts: What causes these extra spaces in front of the package menu header?

texts:
I want to get rid of these extra spaces that is in the left.

I have tried the following after reading a bit on propertize:

(setq-local header-line-format
            (propertize header-line-format 'display '((space :align-to 0))))


texts:
On the following setup:

GNU Emacs 24.4.1 (i586-pc-linux-gnu, GTK+ Version 3.14.5) of 2015-03-07 on binet, modified by Debian
Evil version 1.1.6

If I enter M-x calendar, I find that several of the keybindings listed in the manual don't work. For example, instead of scrolling forward by 3 months, C-v instead enters Visual Block Mode.

Without uninstalling evil-mode, by which means can I prevent the default keybindings being intercepted, so that they will function as described in the Emacs manual.


texts: Find and remove consecutive duplicated words while ignoring case

texts:
I am trying to find and remove duplicated words in a LaTeX file.

Right now I am using query-replace-regexp with the regular expression
\b\(\w+\)[ #]+\1 where # stands for line-break (C-q C-j). This does not ignore case, however, and misses the following repetition of the word 'the':

I am the new organ player. The the new keymaster.

Are regular expressions sufficient for this or it's better
to program a lisp function to go word by word, checking whether consecutive words are the same?


texts: How to disable warning in js2-mode: function does not always return a value?

texts: Is it possible to disable warning for functions that not always return value in js2-mode?


texts: Multi-processing via TRAMP with asynchronous shell commands

texts:
I found the following code in TRAMP:

(defun tramp-adb-handle-shell-command
  (command &optional output-buffer error-buffer)
  "Like `shell-command' for Tramp files."
  (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command))
     ;; We cannot use `shell-file-name' and `shell-command-switch',
     ;; they are variables of the local host.
     (args (list "sh" "-c" (substring command 0 asynchronous)))
     current-buffer-p
     (output-buffer
      (cond
       ((bufferp output-buffer) output-buffer)
       ((stringp output-buffer) (get-buffer-create output-buffer))
       (output-buffer
        (setq current-buffer-p t)
        (current-buffer))
       (t (get-buffer-create
           (if asynchronous
           "*Async Shell Command*"
         "*Shell Command Output*")))))
     (error-buffer
      (cond
       ((bufferp error-buffer) error-buffer)
       ((stringp error-buffer) (get-buffer-create error-buffer))))
     (buffer
      (if (and (not asynchronous) error-buffer)
          (with-parsed-tramp-file-name default-directory nil
        (list output-buffer (tramp-make-tramp-temp-file v)))
        output-buffer))
     (p (get-buffer-process output-buffer)))

    ;; Check whether there is another process running.  Tramp does not
    ;; support 2 (asynchronous) processes in parallel.
    (when p
      (if (yes-or-no-p "A command is running.  Kill it? ")
      (ignore-errors (kill-process p))
    (tramp-compat-user-error p "Shell command in progress")))

    (if current-buffer-p
    (progn
      (barf-if-buffer-read-only)
      (push-mark nil t))
      (with-current-buffer output-buffer
    (setq buffer-read-only nil)
    (erase-buffer)))

    (if (and (not current-buffer-p) (integerp asynchronous))
    (prog1
        ;; Run the process.
        (apply 'start-file-process "*Async Shell*" buffer args)
      ;; Display output.
      (pop-to-buffer output-buffer)
      (setq mode-line-process '(":%s"))
      (shell-mode))

      (prog1
      ;; Run the process.
      (apply 'process-file (car args) nil buffer nil (cdr args))
    ;; Insert error messages if they were separated.
    (when (listp buffer)
      (with-current-buffer error-buffer
        (insert-file-contents (cadr buffer)))
      (delete-file (cadr buffer)))
    (if current-buffer-p
        ;; This is like exchange-point-and-mark, but doesn't
        ;; activate the mark.  It is cleaner to avoid activation,
        ;; even though the command loop would deactivate the mark
        ;; because we inserted text.
        (goto-char (prog1 (mark t)
             (set-marker (mark-marker) (point)
                     (current-buffer))))
      ;; There's some output, display it.
      (when (with-current-buffer output-buffer (> (point-max) (point-min)))
        (display-message-or-buffer output-buffer)))))))

In particular,

    ;; Check whether there is another process running.  Tramp does not
    ;; support 2 (asynchronous) processes in parallel.
    (when p
      (if (yes-or-no-p "A command is running.  Kill it? ")
      (ignore-errors (kill-process p))
    (tramp-compat-user-error p "Shell command in progress")))

means that if one runs async-shell-command once in a TRAMP buffer, then one cannot run another one in parallel.

In fact, if one runs async-shell-command in one TRAMP buffer and tries to run another async-shell-command in another unrelated TRAMP buffer (representing different connection, e.g. local sudo), this will also fail with the prompt to kill the first one.

That limitation appears weird to me, especially the second case.  To further support my point, if one runs shell in a TRAMP buffer and runs it one or many more times, one will get as many concurrent shells via that TRAMP connection as requested.  So why async-shell-command is the underdog here?  I'm not a fan of running fully-blown shells when it's not necessary.


texts: Successive versions of packages accumulating in the ~/.emacs.d/elpa folder

texts:
I noticed that successive versions of packages have been accumulating in my ~/.emacs.d/elpa folder, like so:

drwxr-xr-x   3 joon users 4,0K 20 avril 15:49 auto-complete-20150408.1132
drwxr-xr-x   3 joon users 4,0K 16 juin  17:14 auto-complete-20150615.34
drwxr-xr-x   3 joon users 4,0K  1 juil. 18:00 auto-complete-20150618.1949
drwxr-xr-x   2 joon users 4,0K 31 mai   21:53 avy-20150530.111
drwxr-xr-x   2 joon users 4,0K  4 juin  16:42 avy-20150603.919
drwxr-xr-x   2 joon users 4,0K 12 juin  17:07 avy-20150608.404
drwxr-xr-x   2 joon users 4,0K 16 juin  17:14 avy-20150615.1048
drwxr-xr-x   2 joon users 4,0K  1 juil. 18:00 avy-20150701.532
drwxr-xr-x   2 joon users 4,0K  7 juil. 19:53 avy-20150707.811

Is this normal? Is there a quick way to get rid of old versions ?


texts: How can I ensure that Org-Mode is Up-To-Date in init.el?

texts:
I want my init.el file to get the latest version of org from orgmode.org before loading my pretty-init.org.

My init.el:

(add-to-list 'package-archives
             '("org" . "http://orgmode.org/elpa/"))
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
  (add-to-list 'package-archives
               '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)

(when (boundp 'package-pinned-packages)
  (setq package-pinned-packages
        '((org . "org"))))

;; I don't want the version hardcoded here, but without it
;; package-installed-p will find the built-in org package
(unless (package-installed-p 'org '20151005)
  (package-install 'org))

When I run this I get the error (wrong-type-argument arrayp org) on the call (package-install 'org).

I think it has something to do with the existence of the built-in org package because if I run (package-install 'nlinum) when nlinum is installed already, I get the same error.

I'm running the latest build of emacsbinw64 and I can install the newest org package if I use M-x list-packages (though it doesn't work through M-x package-install because it doesn't show up in the completion list).


texts: What means Unmerged into origin/master in magit?

texts:
In the magit buffer I see Unmerged into origin/master, yet I'm not noticing see any issues while merging with magit or with git on the commandline.
Searching for the the subject brought me here[0], yet I don't understand it's meaning.
Maybe someone can shed some light here for me.
[0] https://magit.vc/manual/magit/Getting-Started.html


texts: list of current variables in a buffer for Python code

texts:
I would like to find a way to reproduce the "Workspace" of Matlab or the equivalent "Variables" window of the awesome pudb debugger directly in emacs for python code: it is a window which details the current state of variables, which is particularly useful when debugging or understanding numerical simulation codes.

Here is a screenshot of pudb highlighting the feature I am talking about:

If it doesn't exist already (which would surprise me a lot), I suppose that it could be possible to automatically create a buffer running the IPython built-in whos function refreshing at each stop of the debugger...

Unfortunately, I am a newbie in Lisp...

Thanks a lot for any kind of support.


texts: Override the default font for emoji characters

texts:
My fonts setup is
(setq default-frame-alist '((font . "DejaVu Sans Mono-10")))

(defun my-emoji-fonts ()
  (set-fontset-font t 'symbol "Twemoji")
  (set-fontset-font t 'symbol "Noto Color Emoji" nil 'append)
  (set-fontset-font t 'symbol "Symbola" nil 'append))
(if (daemonp)
    (add-hook 'server-after-make-frame-hook #'my-emoji-fonts)
  (my-emoji-fonts))

With it most emoji display nice and coloured, except those for which DejaVu provides its own glyph, then that overrides the coloured one. How can I avoid that?

U+1F682 and U+2615. They don't let me sleep :/
describe-char reports that the train is displayed with ftcrhb:-GOOG-Twemoji-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1 (#x3C6), while the coffee uses ftcrhb:-PfEd-DejaVu Sans Mono-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1 (#xA6C).

Solution
Turned out to be more complicated than I had thought. First, I had to turn off use-default-font-for-symbols in order to make Emacs honor the fontsets. (I use the first person because I don't feel like saying "do this and that". I got it working by trial and error.) This allows an Emoji font to override the default one when both provide glyphs for the same character:
(setq use-default-font-for-symbols nil)

Now however all greek letters, mathematical symbols and so on had switched to Twemoji or Symbola. I didn't want that, so I what I had to do was

restore DejaVu Sans Mono as the main symbols font;
make Twemoji override DejaVu for some specified character ranges;
finally, make Symbola act like a font of last resort.

The only arrangement of set-fontset-font with which I was able to pull it off is this:
(defun my-emoji-fonts ()
  (set-fontset-font t 'unicode (face-attribute 'default :family))
  (set-fontset-font t '(#x2300 . #x27e7) "Twemoji")
  (set-fontset-font t '(#x2300 . #x27e7) "Noto Color Emoji" nil 'append)
  (set-fontset-font t '(#x27F0 . #x1FAFF) "Twemoji")
  (set-fontset-font t '(#x27F0 . #x1FAFF) "Noto Color Emoji" nil 'append)
  (set-fontset-font t 'unicode "Symbola" nil 'append))

I chose the range from #x2300 to #x1FAFF but had to break it in correspondence of #x27e8 and x27e9 (i.e. ⟨ and ⟩) because I noticed that Symbola was overriding those two specific characters, though they are available in DejaVu Sans Mono. Thanks zzkt and rpluim for helping me out.


texts:
My config is a literate org-mode file.

On my Linux machine, the code blocks are highlighted with the relevant syntax highlighting (i.e. Elisp).

But on my Mac, I get this error when I load the buffer:

org-mode fontification error

How do I fontify the code blocks, and avoid that error?


texts:
Say I have a function that is called on an idle timer:

(defun tmp:create () (mkdir "test"))
(run-with-idle-time 3 nil #'tmp:create)

How can I test that this function works?

Using something like

(ert-deftest async () ""
  (should-not (file-exists-p "test"))
  (sleep-for 4)
  (should (file-exists-p "test")))

doesn't work.


texts: Dired: How to find all files under a directory that match a glob pattern (wildcards)?

texts:
Emacs 26.1, Windows 10

In my directory: d:/TEMP/test/ I has 2 text files. Also in subdirectories I has 2 text files.

If I want to find all files in directory d:/TEMP/test/ I do:

C-x d d:/TEMP/test/*.txt `RET`

As result it show me all text files.
Here result:

Nice. But if I want to find all txt files in subdirectories I use this:

C-x d d:/TEMP/test//.txt RET

But It not work. Not find all txt file in all subdirectories.
Show message:

No such directory

Why?

Here result:

After press Enter


texts: Segmentation fault when creating new frames

texts:
I am reproducibly experiencing segmentation faults on Emacs 26.3 under Debian Buster when creating a new frame, which seems to be related to setting fonts for new frames.

In order to illustrate I have the following minimal init.el file:

(defun ah/setup-gui-frame (frame)
    (let* ((variable-pitch-serif-tuple
        (cond
         ((x-list-fonts "Garamond") '(:font "Garamond"))
         (nil (warn "Cannot find a Serif Font."))))
       (headline `(:inherit default :weight bold))
       )
      (custom-theme-set-faces
       'user
       `(variable-pitch            ((t (,@variable-pitch-serif-tuple :height 160))))
       )
      )
  )

(add-hook 'after-make-frame-functions
    (lambda (frame)
        (when (display-graphic-p frame)
      (ah/setup-gui-frame frame))))

(add-hook 'org-mode-hook 'variable-pitch-mode)
(add-to-list 'default-frame-alist '(font-backend . "xft"))

The ah/setup-gui-frame function is in reality larger since I want to use the same init file on different machines where different sets of fonts might be installed, and I'm also setting some org-mode faces in there -- but this minimal example already shows the bad behavior.

Now, when I start Emacs and open an org-mode file, the buffer contents are not displayed in Garamond, but in the system's default sans-serif font.

When I now open a new frame with C-x 5 2, the org-mode file in both the new and the old frame are displayed in Garamond.

I can now open new frames with C-x 5 2, but when I open the fourth additional (in total) frame, Emacs quits with a segmentation fault.

When instead of setting the variable-pitch-serif-tuple and instead directly set the font's name, like this

   `(variable-pitch            ((t (:font "Garamond" :height 160))))

the same happens (except that the segmentation fault occurs one frame "earlier").

The same happens when running Emacs as a deamon and connecting with emacsclient.  (That's why this is so annoying: I'm using emacsclient a lot, and therefore I can easily have more than 5 frames open at any one time).

How do I properly set font faces for GUI frames when using emacs --daemon?

UPDATE: As recommended in the comments, I did submit a bug report to the Emacs bug tracker, and the problem was since solved.  The fix is already merged in the master branch and will be in the next release.


texts:
I found a way to auto indent when I type one of }, ; or ) using this code:

(setq mode-autoindent-list '(javascript-mode js-mode php-mode web-mode))
(defun mode-autoindent ()
  (when (and (member major-mode mode-autoindent-list) (looking-back "[});]"))
    (indent-for-tab-command)))

(add-hook 'post-self-insert-hook 'mode-autoindent)

inspired by the code in this answer on stack overflow Auto indent after inserting a semicolon or curly brace

Is there a better way, maybe build in mode?


texts: why dash didn't show up with list-packages

texts:
I was trying to install dash using elpa but failed.

I can't understand why it shows dash[no match] by following M-x package-install RET dash RET as in the snapshot. can anyone let me know why? Thank you!

I also tried list-package and dash does not show up in the available list. I am pretty sure I installed dash this way earlier and removed it later.

I described the package-archives variable and it's as below:

package-archives is a variable defined in ‘package.el’.
Its value is
(("org" . "http://orgmode.org/elpa/")
 ("gnu" . "https://elpa.gnu.org/packages/")
 ("melpa" . "https://melpa.milkbox.net/packages/"))
Original value was
(("gnu" . "https://elpa.gnu.org/packages/"))


texts: How to link to a non-existing Org-mode file and then create it?

texts:
I would like to use Org-mode as a local wiki, and I have just discovered how to link Org-mode files (Cf. http://orgmode.org/manual/External-links.html#External-links).

Now I'd like to link a non-existing Org-mode and when running some command on the link of clicking it, opening it that new Org-mode file in a buffer – similar to creating a new wiki page.

How to achieve this?  Is there some built-in method in Org-mode?


texts: How do I add a time-stamped note to the LOGBOOK drawer

texts:
According to the documentation of Drawers, I should be able to add a time-stamped note to the LOGBOOK drawer using the command C-c C-z.

However, when I try to do this with my cursor on a TODO task, a note with timestamp is added above the task and without a LOGBOOK drawer:

- Note taken on [2020-03-14 Sat 11:50] \\
  Started working on nice task
* TODO Nice task

When I do the same thing under a task, I get the following result, still without a LOGBOOK drawer:

* TODO Hard task
  - Note taken on [2020-03-14 Sat 11:51] \\
    Man, this task is very hard. I don't know if I can do it...

Finally, when I manually add a LOGBOOK drawer myself and navigate the cursor into the LOGBOOK drawer area, the note gets added above the drawer:

* TODO Clock hours
  - Note taken on [2020-03-14 Sat 11:52] \\
    Add a note to the logbook of this task to see if it works...
:LOGBOOK:

:END:

Am I doing something wrong or is the aforementioned documentation wrong? The only thing I want to do is add notes with a timestamp to a task to be able to log my progress and thoughts.


texts:
How to remap C-x with key-chord mode.

(key-chord-define-global "uu" 'what-goes-here?)

https://www.emacswiki.org/emacs/KeyChord


texts: Possible to take whitespace into account with prettify symbols? (without removing whitespace)

texts:
With a C like language, it might be nice to be able to display: (var * t) as (var x t) - using the unicode multiply symbol.

However this causes problems with casting. eg:void fn(MyStruct *s) becomes void fn(MyStruct xs).

Is there a way to only replace a symbol when its surrounded by white-space? 1

Matching " * " works but removes the spaces on either side.

Am aware spacing in this context is just a convention, nevertheless, would be interested to know if its possible.


texts:
I recently explored the Emacs Mac Port developed by Yamamoto Mitsuharu. It feels great and I would like to try using it instead of vanilla GNU Emacs. However, I have some code in my init files which is incompatible with the Mac Port version. I would like to know how to conditionally disable this code.

I'm essentially looking for something like this:

(unless (boundp 'emacs-mac-port-version)
  ;; do this stuff only in vanilla Emacs
)

So how can I detect that I am on the Emacs Mac Port from Elisp?


texts: how do I write a projectile-switch-action that changes the current working directory to the chosen project's root dir?

texts:
I want that when I choose a project from the list presented by projectile-switch-project, projectile changes the current working directory to the chosen project's root directory.

I tried this:

;; cd into dir i want, including git-root
  (defun cd-dwim ()
      (cd (projectile-project-root)))
  (setq projectile-switch-project-action 'cd-dwim)

Did not work. It projectile-project-root does not receive the new path from the project I just chose.

I'd love if I was able to write something like this:

(setq projectile-switch-project-action
'projectile-get-the-root-directory-of-the-project-I-just-chose)

Is it possible?


texts:
I can't find a concise answer to this question, only big manuals for which I'm not sure reading them will give me the answer...
Spacemacs & haskell-mode are now giving me tag navigation by default (appeared with a MELPA upgrade, it's a feature I didn't have before).
I'm using it now, however each time I change folder with tag navigation, emacs is asking:

  Keep current list of tags tables also? (y or n)

I've seen that other question and so I see that the tags-add-tables setting is the way to go, however I honestly have no idea whether I want to answer yes or no... Is there a builtin emacs manual I can look at with brief information on the topic of tag tables, that would explain which is the compromise here?

Honestly I would expect spacemacs, or maybe haskell-mode to make that decision for me :-(


texts: How do I set a custom name for a feed in elfeed?

texts:
I use elfeed to follow some blogs and news sites. One on them is Arne Metz's "Simplify C++". This feed does not set its name so in the elfeed-search buffer this field is left empty. This makes it difficult to quickly scan the list of feeds to read.

I have tried to find information on how to manually set the feed name in my init.el file but failed to find an answer that works. Is it even possible?

Configuration of elfeed in my init.el looks like the following:

(use-package elfeed
  :ensure t
  :config
  (setq elfeed-feeds '(("http://bobby.clearit.se:8080/jenkins/job/scm/rssAll" build jenkins)
               ("http://planet.emacsen.org/atom.xml" emacs)
               ("https://stackoverflow.com/feeds/tag/emacs" emacs stack)
               ("https://www.masteringemacs.org/feed" emacs)
               ("http://endlessparentheses.com/atom.xml" emacs)
               ("https://oremacs.com/" emacs)
               ("http://pragmaticemacs.com/feed/" emacs)
               ("https://arne-mertz.de/feed/" cpp)
               ("https://isocpp.org/blog/rss/category/news" cpp)
               ("https://www.fluentcpp.com/feed/" cpp)))
  :bind
  ("C-x w" . elfeed))

Is it possible to manually set the feed name from within the use-package declaration?


texts: Emacs forces me to write HTML tags instead of PHP code

texts:
When I edit a PHP file, and when to type for example <?php I get the cursor moved to the lower buffer suggesting me to write an HTML tag instead:

How to circumvent this issue?


texts: How to get fuzzy matching with helm in describe-*?

texts: I have fuzzy matching in helm-apropos with helm-apropos-fuzzy-match set to true. I would like to get fuzzy matching for descibe-function and describe-variable and the like, too. How can I enable it for these?


texts: Get org link to insert link description automatically?

texts:
Q: How can I get a custom org link function to insert a description automatically?

I'd like to store org links to files in a dired buffer, but would prefer that the link description be the file name sans path rather than report the full path, ie:

file:~/the/full/path/myfile.ext     ; default, but no thanks
myfile.ext                          ; what I want

Now: org-store-link hardcodes links from dired to provide the default.  Instead, I've written a custom function (cribbing from the hard-coded function) and added it to org-store-link-functions:

(defun dired-store-link ()
  (when (derived-mode-p 'dired-mode)
    (let ((file (dired-get-filename nil t)))
      (setf file (if file
                     (abbreviate-file-name (expand-file-name file))
                   default-directory))
      (org-store-link-props :type        "dired"
                            :link        file
                            :description (file-name-nondirectory file))
      file)))

(add-to-list 'org-store-link-functions #'dired-store-link)

So far so good, and it works as expected, but for one thing:

When calling org-insert-link with the built-in, default behavior, it simply inserts the link without asking me for a description.
When calling org-insert-link with my custom function, it prompts me to enter a description (which it correctly populates with the file name stored in the :description property).

I'd rather not be prompted for the description each time, and want org-insert-link to use the value of :description that the custom function sets.

How can I convince org-insert-link to use the :description automatically without prompting me for it?


texts: flycheck/bash - i'd like to declare that the next line was intentional

texts:
When using the shellcheck checker, Flycheck will warn me that the "$@" in the following will be expanded on the client rather than the ssh server.  Which is a helpful warning, but yeah I know and I'm good.  So is it possible to suppress this warning; better yet if it's for just this one line.

  function f(){ ssh foo "$@" ; }


texts:
What I want to do: have the function evil-delete do one more task after its usual code.  (I'm presuming that evil-delete is the underlying workhorse that is called by evil-delete-line and about five other functions.)  evil-delete takes optional parameters.

In a scheme, I'd write:

(define  original-evil-delete  evil-delete) ; capture the original binding

(define (evil-delete-then-gui-set-selection . args)
    "Delete, and copy deleted-text into the OS clipboard."
    (prog1 (apply original-evil-delete args)
           (gui-set-selection 'CLIPBOARD (current-kill 0))))

(set!  evil-delete  evil-delete-then-gui-set-selection)
; I want this "new" binding to be used in other functions that call `evil-delete`.

But between lisp's defvar-vs-defun distinction, possibly-dynamic scoping, and forwarding optional-args, I'm having a bit of trouble translating this scheme to elisp.  Any help appreciated.  (I don't think I need to worry about "interactive", at least?)

Also, if there is a better way of doing this -- e.g. some hook available -- then I'd appreciate hearing that too.  Finally, it's not out-of-question that I instead make new versions of the ~dozen "wrapper" functions and re-bind all the keys to use these new versions, thereby avoiding most issues except forwarding-default-args.


texts: compilation sentinel: symbol's value as variable is void for quote, >, <, =, etc

texts:
I'm working on a script that can compile multiple directories and then provide the first error to a file. Currently, I am tackling the issue of running make in multiple directories portion. I am making use of the compilation-finish-function hook in order to continue the compilation in the next directory. However, in this function, I get the following error:
error in process sentinel: Symbol's value as variable is void: >
The way the following script works is as follows:

Currently (and unfortunately) using a globally defined DIRS symbol that stores the list of directories
my-compilation-finish-function operates on the DIRS list, popping the first element and setting DIRS to rest of the list
compile-in-dir-helper runs the make command on the new directory
compile-in-dir runs is the only interactive command and relies on the compilation hook to finish compilation in the rest of the directories

I need some kind of conditional in the hook, otherwise an infinite loop condition can occur with an empty directory variable is passed to the helper function indefinitely. I'm not sure why the sentinel is complaining of the condition function, however.
(setq
  DIRS
   '(
    "dir1"
    "dir2"
    "dir3"
    ))

(defun my-compilation-finish-function (buffer desc)
;;;    (message "Buffer %s: %s" buffer desc)
;;;  (if (< (length 'DIRS) 0)
     (cond (> (length DIRS) 0) (
;;;  (cond '(eql 1 0) (
        (setq directory (car DIRS))
        (compile-in-dir-helper directory)
        (setq DIRS (cdr DIRS)))))
(add-hook 'compilation-finish-functions 'my-compilation-finish-function)

(defun compile-in-dir-helper (dir)
  (setq make_cmd (concatenate 'string "make -j1 -C" dir))
  (compile make_cmd))

(defun compile-in-dir ()
  (interactive)
  (compile "make -j1 -C ~/dir0"))


texts: (goto-char (region-end)) doesn't set the point to the end of the region

texts:
I have written a small elisp script which should  put oneline or multiline comments based on the current buffer's major mode. The source file is here: https://github.com/amirteymuri/Com/blob/master/com.el

The insert-comm+ function which should insert the multiline comments however puts the ending multline-comment string not at the end of the marked region, but some characters before it (depending on major-mode the amount of characters change also). Can someone see where the problem is happening?
This is the insert-comm+ definition:

(defun insert-comm+ ()
  "Inserts multiliners to a marked region or a line."
  (interactive)
  (let* ((comm-list (comm+))
     (comm-begin (concat (first comm-list) "\n"))
     (comm-end (concat "\n" (second comm-list))))
    (if (use-region-p)
      (let ((b (region-beginning))
            (e (region-end)))
       (progn
        (goto-char b)
        (insert comm-begin)
        (goto-char (1+ e))
        (insert comm-end)))
      (progn
       (insert comm-begin)
       (insert comm-end)
       (backward-char (length comm-end))))))


texts: How to use face-remap-set-base to substitute a face for another?

texts:
I'd like to locally remap a face to other custom face.  The docstring reads:

(face-remap-set-base FACE &rest SPECS)
Set the base remapping of FACE in the current buffer to SPECS. This
causes the remappings specified by ‘face-remap-add-relative’ to apply
on top of the face specification given by SPECS.
The remaining arguments, SPECS, should form a list of faces. Each list
element should be either a face name or a property list of face
attribute/value pairs, like in a ‘face’ text property.

Armed with this knowledge, I tried:
(defface my/exceptional-face
  '((t (:background "red")))
  "My exceptional face.")

(face-remap-set-base 'font-lock-keyword-face '(my/exceptional-face))

In a Lisp buffer, M-x eval-buffer RET, I'd expect the keywords to show up with a red background.  However, this fails with:
(wrong-type-argument listp my/exceptional-face)

Indeed, the face-remap-set-base function reads:
 (defun face-remap-set-base (face &rest specs)
  (while (and (consp specs) (not (null (car specs))) (null (cdr specs)))
    (setq specs (car specs)))
  (if (or (null specs)
      (and (eq (car specs) face) (null (cdr specs)))) ; Error raised here
      ;; Set entry back to default
      (face-remap-reset-base face)
    ;; Set the base remapping
    ...snip...))

It thus seems that there's no way I can pass a single face to this function.  Using:
(face-remap-set-base 'font-lock-keyword-face '(my/exceptional-face nil))

…seems to work though.  Is that the expected behavior, or is this a bug?


texts: How do I attach a custom function to process org-mode babel shell output?

texts:
I have a a function

(defun display-ansi-colors ()
  (interactive)
  (let ((inhibit-read-only t))
    (ansi-color-apply-on-region (point-min) (point-max))))

that I got from here: http://stackoverflow.com/questions/23378271/how-do-i-display-ansi-color-codes-in-emacs-for-any-mode

I'd like to run it automatically after org-babel-sh-evaluate or org-babel-execute:shell to strip the ANSI color codes from the output and colorize the org-mode #+RESULTS block.

Many thanks.


texts:
Is there a way to make Gnus store sent emails in the inbox folder?

I would like to see all mail, i.e., received and sent mail, in my mail threads in my inbox.